tomer8007 / kik-bot-api-unofficial

Python API for writing unoffical Kik bots that act like humans
MIT License
128 stars 77 forks source link

Display name from alias jid #196

Closed PunkSoul closed 3 years ago

PunkSoul commented 3 years ago

Noob question Trying to get a display name from chat_message.from_jid in a group, seems simple enough, but I've tried options listed in #131 #190 #177 and #174 I run into the same issue each time.

xiphias_get_users, xiphias_get_users_by_alias, and request_info_of_users all return a string of numbers and dashes that is not an alias jid, I'm trying to figure out what it is. Example: a22d4b40-eca2-4b59-b177-1ebd732da40a

I'm sure it's something obvious, I just need a nudge in the right direction. How can I get a user's display name from their alias jid? I can do it with a normal jid...

tomer8007 commented 3 years ago

Can you post examples of the output you get from xiphias_get_users, xiphias_get_users, and request_info_of_users?

bluemods commented 3 years ago

request_info_of_users is the simplest if you just need the name, but if you want to use xiphias methods (as they are better and you get more information like account age)

Use this:

By the way I just noticed for non-alias jids, the display name is omitted. So for those you'll want to use request_info_of_users

    def on_xiphias_get_users_response(self, response: Union[UsersResponse, UsersByAliasResponse]):
        for user in response.users:
            jid = user.alias_jid if user.alias_jid else user.jid
            name = user.display_name

            print("Display name for " + jid + " = " + name)