Telegram Tool: Kick Muted Users Lacking Speaking Permission
有一些anti-spam bots, in order to avoid accidentally kicking out users, only set users who have not passed the verification to be muted, without kicking them out of the group.
When there are many such records, doing it manually one by one is too time-consuming.
So, let's let a program do it for us.
Then, these users will leave a record without speaking permission in the group's Exceptions list.
When there are many such records, doing it manually one by one is too time-consuming.
So, let's let a program do it for us.
Once again, developed using GPT.
Based on our previous project https://github.com/crazypeace/tg-clean-exceptions
Refer to the code above to implement the following features
Check all the settings in the exceptions of the group's permissions,
Check all the settings in the exceptions of the group's permissions,
If a user does not have speaking permission, kick that user out of the group.
As you can see, for such a simple project, you don't need an IDE development tool, nor a vibe programming assistant, nor the latest model. Any GPT will do. Even if you hit the GPT-5 quota, GPT-4 is enough.
However, as in the previous blog post, the overall framework logic of the program is correct, but when it comes to how to kick a user out of the group, the called functions and parameters can be confusing.
Check the official documentation yourself.
Final effect
Group: test
✅ Keep: 6611601789 (Frog Girl) - Can speak
🚫 Kick: 6701294471 (New Hope) - No speaking permission
Check completed, 2 people checked, 1 kicked out
Upload to Github
========
Postscript
The 4 small Telegram anti-spam bot-related tools I published later are all based on telethon. Accordingly, you need to log in to a Telegram account, which means you need to enter a phone number and complete the verification process.
For such occasionally used tools, you can share the same Telegram account.
I used the same method of specifying session in the code.
client = TelegramClient('session_' + phone_number, api_id, api_hash)
So the specified session file name is the same. In other words, these tools can share one session. Just put these tools in the same directory.
root@rn-TEST:~/tg-antispam-bot-tool# tree .
.
|-- session_+8613812345678.session
|-- tg-clean-exceptions-0.py
|-- tg-get-group-member-0.py
|-- tg-get-group-recent-msg-senderid-0.py
`-- tg-kick-no-permission-user-0.py
If you log in to the account when using the first tool, then you don't need to log in when continuing to use other tools, just like when you use the same tool the second time.
========


