tomer8007 / kik-bot-api-unofficial

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

List groups and join them #207

Closed arzaev closed 1 year ago

arzaev commented 2 years ago

Hi! I am trying to make bot for join groups. Can someone write functions for getting list of groups and join them?

StethoSaysHello commented 2 years ago

Huh, I'm surprised nobody else has answered this yet, been over a week. Sorry for my late response! I use search_group _(line 398 in client.py)_ to search for groups, and join_group_with_token _(line 327 in client.py)_ to join them.

You're going to need to make your own fork, because GroupSearchResponse doesn't return tokens by default _(you need one for join_group_with_token)_, and group joining seems to only work when an account passes a safetynet check, sooo...

I changed GroupSearchResponse on line 181 in roster.py to just return tokens and group names/tags to use in group joining. You'll need to login manually the the account you use for your bot on an android device, then in client_legacy.py replace device_id on line 34, and android_id on line 36 with the details from your device. I also replace kik_node in client.py starting on line 35, I'm unsure if this is necessary though. Group searching will work without these steps, but usually not group joining. Also keep in mind that group joining sometimes times out even when you pass safetynet checks, so slap in some error handling, I personally stick it in a while loop and have it try 5 times before giving up.

Hope this helps! If you need me to write you up an example of the changes to make in a fork or some example source code, reply to this and let me know.

tomer8007 commented 2 years ago

@StethoSaysHello Why not submit a PR for this?

StethoSaysHello commented 2 years ago

Because I'm not experienced, I just barely started learning python this year, I hardly know how pull requests work and a big API like this probably isn't the best place to start, lol. Sorry!

Join tokens are pretty long, I can see why it wasn't added to the return on search_group, that'd be a lot of clutter. This could potentially be resolved by splitting it into two functions though, like search_group and get_group_token maybe? Just an idea.

I'm not sure if the safetynet check bypass I mentioned has a 100% success rate or not, I figured BlueMods would have submitted a PR in the past if that was the case considering he mentioned this bypass way back in #64.

Sitiaro commented 2 years ago

In on_group_message_recieved, add this:

        # for token stuff
        if chat_message.body.lower().startswith('search'):
            search = chat_message.body.split(' ')
            searching = search[1]
            token = self.client.search_group(searching)
            print(token)

        # joining using the token
        if chat_message.body.lower() == 'join':
            self.client.join_group_with_token('group_hashtag', 'gjid', group_token_here)

The group token is accepted in bytes so make sure to follow the format. Ex. for that would be: b'token'

To automate all of that, you can declare global vars and make them autofill the 2nd half.

bluemods commented 2 years ago

Because I'm not experienced, I just barely started learning python this year, I hardly know how pull requests work and a big API like this probably isn't the best place to start, lol. Sorry!

Join tokens are pretty long, I can see why it wasn't added to the return on search_group, that'd be a lot of clutter. This could potentially be resolved by splitting it into two functions though, like search_group and get_group_token maybe? Just an idea.

I'm not sure if the safetynet check bypass I mentioned has a 100% success rate or not, I figured BlueMods would have submitted a PR in the past if that was the case considering he mentioned this bypass way back in #64.

They've done several patches since then

The unfortunate side effect of this API supporting group joins (and @Jaapp- 's PR adding the functionality) is that it has caused irrevocable damage to the platform by making it much easier for thot bot spammers to get their start. I would advise you to keep any method you have of increasing your join success rate to yourself, as if you make it public, expect more spam in your public groups. I've learned that the thot bots use this API, and any improvements made to it are immediately used by them to further hurt the platform.

My reason of researching it was to figure out why Kik blocks it so frequently (and seemingly without a reason), what the cause is, and how to remove it so real users don't have to deal with it. They don't make it easy; you have to think outside the box.

TLDR: Keep your research private, as it mainly helps people who want to continue spamming groups with advertisements.

StethoSaysHello commented 2 years ago

TLDR: Keep your research private, as it mainly helps people who want to continue spamming groups with advertisements.

Note taken! I'll be more cautious with similar situations in the future. That also explains a lot, thanks for the input!