tomer8007 / kik-bot-api-unofficial

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

Add friend should return the public id it was called on in its callback responce [enhancement] #182

Closed QtpyeRose closed 7 months ago

QtpyeRose commented 3 years ago

when you call client.add_friend(jid) in the callback under on_peer_info_received(self, response: PeersInfoResponse): it should return the alias_jid it was called on. otherwise, we can't know which person in a group the private jid it returns belongs to.

right now callback only has the private jid and we don't have any safe way to figure out which alias jid that relates to unless we call client.xiphias_get_users_by_alias(alias_jid) for all members in all groups until we find one with a matching private jid.

while if the call back returns the alias_jid we called it on we can simply make a dictionary like this

users = {}
    def on_peer_info_received(self, response: PeersInfoResponse):
        users[response.users[0].alias_jid] = response.users[0]

def alias_jid_to_private_jid(jid){
    if jid in users:
        return users[jid].jid
    client.add_friend(jid)
    while jid not in users: #this stops it from trying to get the info before the call back gets the info
        pass
    return users[jid].jid
}

this is a request for an enhancement, as I believe that being able to do this would be a very helpful feature and make programs less error prone

tomer8007 commented 7 months ago

Closing because this feature was added by @TheGreatCodeholio