Telegram Tool: Kick Muted Users Lacking Speaking Permission
Preface
Some anti-advertising bots, in order to avoid accidentally kicking legitimate users, only mute users who haven't passed verification instead of kicking them out of the group.As a result, these users leave a record in the group's Exceptions list without speaking permission.
Once Again, Develop with GPT
Based on our previous project https://github.com/crazypeace/tg-clean-exceptions
Refer to the code above to implement the following function
Check all entries in the group's permissions exceptions,and 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 at all, you don't need a vibe-coding assistant, and you don't need the latest model. Any random GPT will do — even if you've hit the GPT-5 quota, GPT-4 is more than enough.
However, just like the situation described in the previous blog post, the overall logic of the script is correct, but when it gets down to the specifics of how to kick a user out of the group, the function calls and parameters get mixed up.
Check the official documentation yourself.
Final Result
Group: test
✅ Keep: 6611601789 (Frog Girl) - Can speak
🚫 Kick: 6701294471 (New Hope) - No speaking permission
Check complete. 2 users checked, 1 kicked.
Uploaded to Github
========
Postscript
The 4 small Telegram antispam-bot-related tools I've published later are all based on telethon. Accordingly, you need to log into a Telegram account — meaning you need to enter a phone number and complete the verification process.
For these occasionally-used tools, you can share the same Telegram account.
I used the same method in the code to specify a session.
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, as long as you put them 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 into the account while using the first tool, you don't need to log in again when continuing to use the other tools — it's just like the second time you use the same tool.


