TelegramApi
TelegramApi copied to clipboard
Reading the username of a message
I'm trying to read the username of the user that posted a message on a channel:
TLMessage msg = ...some message int fromId=msg.getFromId();
TLRequestUsersGetFullUser getUser = new TLRequestUsersGetFullUser(); TLInputUser user = new TLInputUser(); user.setUserId(fromId);
//HOW DO I GET access hash field for the user? user.setAccessHash(????);
AccessHash is received with the TLUser that you get in your implementation of IUserHandler.
Thanks for the reply!
Unfortunately, I can't make it work. As far as I saw the users should come in the ApiCallback.onUpdate method but it is never called in my case...
` this.api = new TelegramApi(apiState, appInfo, new ApiCallback() {
@Override
public void onUpdatesInvalidated(TelegramApi api) {
System.out.println("onUpdatesInvalidated:" + api);
}
@Override
public void onUpdate(TLAbsUpdates updates) {
System.out.println("!!!!!!!!!!onUpdate" + updates);
}
@Override
public void onAuthCancelled(TelegramApi api) {
System.out.println("onAuthCancelled:" + api);
}
});`
Hi, you should be able to get it checking sample project at https://github.com/rubenlagus/Deepthought, users are managed at https://github.com/rubenlagus/Deepthought/blob/master/Deepthought/src/main/java/org/telegram/plugins/echo/handlers/UsersHandler.java exactly