tomer8007 / kik-bot-api-unofficial

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

Prettier logging Ping Method and Catch Temp Ban #238

Closed TheGreatCodeholio closed 8 months ago

TheGreatCodeholio commented 8 months ago

Added Colorful logging with the option to log to a rotated file

Added Ping Method and Pong response

Added method to catch temp bans

tomer8007 commented 8 months ago

Can you attach a screenshot of the colorful logs shown on regular login and chatting?

TheGreatCodeholio commented 8 months ago

Here is a snippet of what the log file looks like. It is NOT colored and is plain text.

2023-10-14 15:28:48,448 INFO [139898453567040/Thread-1 (_on_new_data_received)]: Authenticated successfully.
2023-10-14 15:28:51,690 INFO [139898453567040/Thread-1 (_on_new_data_received)]: Sending authentication certificate
2023-10-14 15:28:51,690 INFO [139898453567040/Thread-1 (_on_new_data_received)]: Requesting roster (list of chat partners)...
2023-10-14 15:28:51,853 INFO [139898453567040/Thread-5 (_on_new_data_received)]: Successfully validated the authentication certificate

Here is the console log with debug level set logs_debug

Here is the console log with Info level set logs_info

self.client = KikClient(self, username, str(password), node, device_id=device_id, android_id=android_id, enable_logging=True, log_file_path="var/test.log", log_level=2)

The reason password is being converted to string is because YAML is literally and if your password is all numbers it sends it as an int type and it causes an exception if not converted first.

The API log can be enabled/disable, if you provide a path it will create a log file, and if you provide a log_level it will use that level for both the file and the console.

tomer8007 commented 8 months ago

From the screenshot I see that some logs are not consistent, e.g [+] Human has read the message. I think all logs should look the same.

TheGreatCodeholio commented 8 months ago

That log item is from the bot itself not from the API. The log changes I made are specific to the API not the bots created with it. A bot created with the API should have its own logging. I can add a similar thing specific to the echo bot if that satisfies your requirements. However my changes were just meant for the API logs not specific bot scripts.

tomer8007 commented 8 months ago

Got it, thanks