tomer8007 / kik-bot-api-unofficial

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

Listing group members #162

Closed bobbyJame closed 3 years ago

bobbyJame commented 3 years ago

This isn't really an issue but I am wondering if you know of a way to list members of a group and check admin statuses of members, I've looked at some of the closed issues and don't seem to be getting anywhere.

If you have an example for listing group members or checking member admin status, it would be greatly appreciated.

tomer8007 commented 3 years ago

If the group is in your roster, I think the list of members should be there. You can see all the information in the Group object. Try something like:

def on_roster_received(self, response: FetchRosterResponse):
        for peer in response.peers:
            if isinstance(peer, Group):
                group_members = peer.members

You can also you the is_admin property.

bobbyJame commented 3 years ago

ON ifinstance(peer, Group) I get error 'Group' is not defined

bobbyJame commented 3 years ago

With is_admin I just receive 'User' object has no attribute 'is_admin'.

I need to check if the member sending the message is admin.

bobbyJame commented 3 years ago

So I have managed to get it to print out the members and whether they're admin but it looks like this: <kik_unofficial.datatypes.peers.GroupMember object at 0x7fac8841c460> is admin

my code: for peer in response.peers: if str(peer).startswith("Group("): for member in peer.members: print(member) if member.is_admin == True: print(member, "is admin")

tomer8007 commented 3 years ago

What's the problem with that? You seem successful

bobbyJame commented 3 years ago

How can I retrieve the jid of the member instead of <kik_unofficial.datatypes.peers.GroupMember object at 0x7fac8841c460>

bobbyJame commented 3 years ago

It is only showing object locations when I iterate through the members field

tomer8007 commented 3 years ago

member.jid

bobbyJame commented 3 years ago

Ok got it now. Thank you very much.