tomer8007 / kik-bot-api-unofficial

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

Bot stops listening to events after a while #163

Closed learningpythons closed 1 year ago

learningpythons commented 4 years ago

Hello, it was already discussed on another thread (https://github.com/tomer8007/kik-bot-api-unofficial/issues/71) that the bot will hang when internet disconnects, i think i can solve this by myself. What is happening to me is that even if internet is on, the bot stop listening to events after a while (let's say 5 minutes). So if i send a message from another account to the bot account it won't be logged by the bot. How can I solve this?

tomer8007 commented 4 years ago

You need to understand why the bot stops listening for events. Try to enable DEBUG logs if you haven't already done so and see if there any connection related logs.

learningpythons commented 4 years ago

I turned on the debugger but there is no output.

Doktor-Apokalypse commented 2 years ago

Every 2 minutes I call...

self.client.send_stanza("< ping / >")

(no spaces between quotes) ...and now doesn't disconnect even if no communication with bot in gc or dm

TriSerpent commented 2 years ago

Every 2 minutes I call...

self.client.send_stanza("< ping / >")

(no spaces between quotes) ...and now doesn't disconnect even if no communication with bot in gc or dm

Send_stanza is just for auth, it doesn't take args like that. Also the function is in auth_stanza not client anyways. There's your issue i guess, ping it with a callback instead.

Doktor-Apokalypse commented 2 years ago

Modified my client.py

def send_stanza(self, XMPP_msg) stanza = XMPP_msg.encode()

self.loop.call_soon_threadsafe(

self.connection.send_raw_data, stanza)

Know it def works because when set logging.DEBUG can see the pong response from kik to every ping i send

tomer8007 commented 1 year ago

Closing this in favor of #71 .