TelegramApi icon indicating copy to clipboard operation
TelegramApi copied to clipboard

Reading the username of a message

Open fbotis opened this issue 8 years ago • 3 comments

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(????);

fbotis avatar Dec 27 '16 10:12 fbotis

AccessHash is received with the TLUser that you get in your implementation of IUserHandler.

rubenlagus avatar Jan 01 '17 16:01 rubenlagus

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);

    }
  });`

fbotis avatar Jan 06 '17 09:01 fbotis

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

rubenlagus avatar Jan 26 '17 00:01 rubenlagus