tomer8007 / kik-bot-api-unofficial

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

GroupChat username in get rooster #105

Closed Skalli closed 5 years ago

Skalli commented 5 years ago

Just to make sure I'm not missing anything. But when I send a message in a public GroupChat the JID is different than private group or PM. I figure it's a kik safety mechanism? When I call the get rooster it only returns the JID and display_name but username is not set. (username=Username unavailable) And it doesn't seem to matter if we're dealing with a friend or not?

tomer8007 commented 5 years ago

Are you saying that your JID is different when you're sending messages to a pulic group and when you 're sending messages to a private group? Do you have maybe some code so that I can try to reproduce this?

Skalli commented 5 years ago

Sure, I have based my code on the echo_bot example. So using the callbacks for on_group_message_received and on_chat_message_received. It's completely fine to reproduce it with just on_group_message_received when comparing public or private group. I've added the bot to a public group to test it and also a private group with just me and the bot to test things first. Example one public group (I replaced the id with garbage, but it has the same length and basic format):

Received raw data: b'<message cts="1549825084597" to="l[censored]_jtw@talk.kik.com" xmlns="kik:groups" id="[GUID]" type="groupchat" from="lhlafgi86u7rrasfer8gnaldgjhfdlakhrathapi84andlgerrad_b@talk.kik.com">
    <body>Das h\xc3\xb6re ich auch zum ersten Mal.</body>
    <pb/>
    <preview>Das h\xc3\xb6re i...</preview>
    <kik push="true" qos="true" app="chat" hop="true" timestamp="1549825084597"/>
    <request r="true" d="true" xmlns="kik:message:receipt"/>
    <ri/>
    <g jid="[group_id]@groups.kik.com"/>
    <alias-sender>lhlafgi86u7rrasfer8gnaldgjhfdlakhrathapi84andlgerrad_b@talk.kik.com</alias-sender>
</message>

Also notice the alias-sender element.

Example 2 private group:

'[+] Received raw data: b'<message cts="1549821044885" to="[censored]_jtw@talk.kik.com" xmlns="kik:groups" id="9[GUID]" type="groupchat" from="[regular_ID]@talk.kik.com">
    <body>Bot ist da.</body>
    <pb/>
    <preview>Bot ist da...</preview>
    <kik push="true" qos="true" app="chat" hop="true" timestamp="1549821044885"/>
    <request r="true" d="true" xmlns="kik:message:receipt"/>
    <ri/>
    <g jid="[group_id]@groups.kik.com"/>
</message>'
tomer8007 commented 5 years ago

Hmm, this is quite interesting. It really looks like as you say it's a security measure (especailly with the long alphanumeric string), in order to hide your real JID in public groups. This could make sense considering that sometimes you don't want this information exposed. Does this happen for every message the bot receives in public groups, from anybody?

Skalli commented 5 years ago

Yes, it happens for every contact. Even contacts the bot is friended with like my own JID. When doing the request_info_of_jids with that ID it also gives a different response than doing it with a non alias JID:

<iq to="[bot_jid]_jtw@talk.kik.com/CAN620xxxxxxxxxxxxxxxxxxxxxxxxxx837" id="[UUID]" type="result">
    <query xmlns="kik:iq:friend:batch">
        <success>
            <item jid="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_a@talk.kik.com">
                <username>Username unavailable</username>
                <display-name>[Display Name]</display-name>
                <pic ts="1545993240881">[pfp link]</pic>
                <pubkey/>
            </item>
        </success>
    </query>
</iq>

Instead of the user name it always just prints "Username unavailable". When using the normal JID the Username is given. Same as in kik itself. When opening a profile in a group you can't see the username for a while now. Only when opening a private chat. So I agree it's probably a security feature. Also: for each public group my own user has a different alias JID for the bot. So it can't be compared to another JID from a different group either. WHen people send the friend-attribution it contains the regular JID but still mentions the public group JID where the request came from!

So after all I guess it's not a bug but a security feature. :D

tomer8007 commented 5 years ago

Indeed.