tomer8007 / kik-bot-api-unofficial

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

Group Name From JID #110

Closed QDNT closed 5 years ago

QDNT commented 5 years ago

im having issues resolving the group name from a JID could someone give an example on how to do this thanks

tomer8007 commented 5 years ago

Did you try request_info_of_jids?

QDNT commented 5 years ago

`def on_roster_received(self, response: FetchRosterResponse): global groups groups.clear() listgroups = str(response.peers) listgroups = listgroups[1: -1]

   for s in listgroups.split(", members="):
        if "Group(" in s:
            group = str(s.split("Group(")[-1]) + ","
            for j in group.split(", name="):
                if "jid=" in j:
                    jid = str(j.split("jid=")[-1])
                    for c in group.split(","):
                        if "code=" in c:
                            code = str(c.split("code=")[-1])
                            for n in group.split(","):
                                if "name=" in n:
                                    name = str(n.split("name=")[-1])
                                    groups.append([code, jid, name])`

no i have not, been away i will look into it. This is my current code that turns all groups in my roaster into an embedded list with their code jid and name. is there a better way of doing this i feel like there is a much easier way that i am missing.

tomer8007 commented 5 years ago

Yes, you really don't need to parse strings like that. That's becuase response.peers is an array of Peers, which are either groups or users. Please see the code to see what fields you can access.