Closed LU1ZINH0 closed 3 years ago
To Ban a user you need to use the User ID, the name doesn't matter, check Telegram Bot API and corresponding python-telegram-bot framework function.
Regarding the error, I can't replicate the problem, but seems strange that I haven't saw it in my logs, are you using python3 right?
A simple fix should be to parse/encode the text that going to be printed in "printts()" funcion. Let me fix it...
Done some changes, please try again with lastest version 1.18.1...
Closed due not feedback received.
Hi...
A long time ago, I was using the bot version: Current Bot version: 1.10.4 (06/22/2020) and lately some Russian bots have started to enter, in which it is not possible to mark them to ban. When understanding, Telegram allows you to create accounts without a user profile, so you can't ban them via 'inline'. The problem with this, is that the Russians in particular use crazy characters, and that you can't ban them. In this version, when they enter, at least it shows the "user account", as an example:
2021-02-27 20:53:55: [-00_removed_00] New join detected: Денис Будахян (1674530619) 2021-02-27 20:53:55: [-00_removed_00] Sending captcha message to Денис Будахян: E2DD ... 2021-02-27 20:53:56: [-00_removed_00] Captcha send process complete.
2021-02-27 20:54:56: [-00_removed_00] Captcha reply timed out for user Денис Будахян. 2021-02-27 20:54:56: [-00_removed_00] Captcha not solved, kicking Денис Будахян (1674530619) ... 2021-02-27 20:54:57: [-00_removed_00] Increased join_retries to 5 2021-02-27 20:54:58: [-00_removed_00] Removing messages from user Денис Будахян ... 2021-02-27 20:54:58: [-00_removed_00] Kick / Ban process complete
So, to ban this bot, I need to type: tg: // user? Id = 1674530619
I thought, that this problem had been solved in the Current Bot version: 1.18.0 (02/27/2021)
However, the result was a bot crash, as follows:
2021-02-27 21:49:39: Bot started. 2021-02-27 21:49:39: File /TLG_JoinCaptchaBot/sources/data/allowedusers.txt not found, creating it ... 2021-02-27 21:49:39: File /TLG_JoinCaptchaBot/sources/data/bannedgroups.txt not found, creating it ... 2021-02-27 21:49:39: Resources initialized. 2021-02-27 21:49:39: Setup Bot for Polling. 2021-02-27 21:49:40: Bot setup completed. Bot is now running. 2021-02-27 21:55:09: [-00_removed_00] Scheduled deletion time for message: 27663 2021-02-27 21:55:09: [-00_removed_00] Message to delete not found 2021-02-27 21:55:10: [-00_removed_00] Scheduled deletion time for message: 27664
2021-02-27 18: 57: 47,533 - telegram.utils.promise - ERROR - An uncaught error was raised while running the promise Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/telegram/utils/promise.py", line 56, in run self._result = self.pooled_function (* self.args, ** self.kwargs) File "join_captcha_bot.py", line 536, in new_member_join printts ("[{}] New join detected: {} ({})". format (chat_id, join_user_name, join_user_id)) File "/TLG_JoinCaptchaBot/sources/commons.py", line 67, in printts print ("{}: {}". format (actual_date, to_print)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 57-61: ordinal not in range (128) 2021-02-27 21:58:06: [-00_removed_00] Scheduled deletion time for message: 27667 2021-02-27 21:58:06: [-00_removed_00] Message to delete not found 2021-02-27 21:58:07: [-00_removed_00] Scheduled deletion time for message: 27668 2021-02-27 21:58:07: [-00_removed_00] Message to delete not found
2021-02-27 18: 58: 09,963 - telegram.utils.promise - ERROR - An uncaught error was raised while running the promise Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/telegram/utils/promise.py", line 56, in run self._result = self.pooled_function (* self.args, ** self.kwargs) File "join_captcha_bot.py", line 536, in new_member_join printts ("[{}] New join detected: {} ({})". format (chat_id, join_user_name, join_user_id)) File "/TLG_JoinCaptchaBot/sources/commons.py", line 67, in printts print ("{}: {}". format (actual_date, to_print)) UnicodeEncodeError: 'ascii' codec can't encode character '\ u200e' in position 57: ordinal not in range (128) 2021-02-27 21:58:10: [-00_removed_00] Scheduled deletion time for message: 27669 2021-02-27 21:58:10: [-00_removed_00] Message to delete not found 2021-02-27 21:58:10: [-00_removed_00] Scheduled deletion time for message: 27670 2021-02-27 21:58:10: [-00_removed_00] Message to delete not found ^ C
The first error occurred when this user entered (without quotes): "Илья токсичая жител_ка постмодерниз_ма!"
The second error, with this user (without quotes): "Elena ♥ ️97"
How can I fix this problem?