Telegram Warn Bot made with C# and ♥ by Geras1mleo
I keep track of the warnings and automatically ban members when the maximum amount of warnings has been reached.
First of all you have to add me into your chat. To use a default one, search for @fancy_moderator_bot
Promote me to admin and /warn the bad guy by replying to his message or by mentioning @bad_guy in your command. I will ban users who receive more than a certain number of warnings specified in Configuration.json.
The default value of MaxWarnings is 3, which means that the user will be banned on his 3rd warning.
If the bad guy behaves less badly, you can /unwarn him in the same way. If a member is already banned from chat, I will unban him so he can get back into the group.
All members can check their number of warnings by typing /wcount, or /wcount @bad_guy to check the number of warnings of someone else.
The commands /warn and /unwarn are only available to administrators and the owner of the group.
I can also:
delete "User joined/left chat" - messages...
delete spam (external links / URL's and mentions) of newly joined members (<24 hours in chat, See: NewMemberStatusFromHours)
I will look at the messages in one specific chat (or any chat) and respond/trigger to the most offensive/provocative/funny ones.
I will look at the messages in the chat and notify admins (in private messages) if something illegal has been sent in one specific chat (or any chat). I will delete messages with illegal words and optionally also give an auto warning to the sender.
Modify json configuration files according to your needs:
Replace <Telegram Bot Token> by your own token.
Here are some significant settings for the bot.
You can change them at runtime and then use reload
in console to reload new configurations.
- UpdateDelay: Every given amount of seconds app will save all data of Users, Chats and ChatWarnings.
- MaxWarnings: The number of warnings warned member will be banned on.
- DeleteWarnMessage: Whether command message (
/warn @Geras1mleo
from administrator) needs to be deleted. - DeleteJoinedLeftMessage: Whether "geras1mleo joined chat" - message needs to be deleted.
- DeleteLinksFromNewMembers: Whether bot will delete spam messages (external links or mentions) of newly joined members (<24 hours in chat, see property below).
- NewMemberStatusFromHours: A member of the chat is considered a new member if he/she has been a member of the chat for less than the specified number of hours.
- AllowAdminWarnings: Whether administrators can receive warnings.
- Captions: The following parameters indicate the reactions of bot on certain events:
- OnBotJoinedChatMessage: Greeting message that will be sent when bot is added to chat.
- ChatNotRegistered: When the bot is being used in a chat, it is not intended to be a member of.
- UserNoPermissions: Non-admin user attempts to warn chat member.
- BotHasNoPermissions: Bot require admin rights to warn and ban members.
- InvalidOperation: Use of command (/warn or /unwarn) without mentioning the user or replying to some (suspicious) message.
- UserNotFound: Mentioned user has been not found in this chat.
- WarnedSuccessfully: Post /warn message that will mention warned user and his current amount of warnings.
- UnwarnedSuccessfully: Post /unwarn message that will mention unwarned user and his current amount of warnings.
- BannedSuccessfully: Post /warn message that will mention banned user.
- UnwarnUserNoWarnings: Attempt to use /unwarn on a user without any warnings.
- WarnAdminAttempt: Attempt to use /warn on administrator when AllowAdminWarnings = false.
- UnwarnAdminAttempt: Attempt to use /unwarn on administrator when AllowAdminWarnings = false.
- WarnBotAttempt: Attempt to use /warn on another bot.
- UnwarnBotAttempt: Attempt to use /unwarn on another bot.
- WarnBotSelfAttempt: Attempt to use /warn on the bot itself.
- UnwarnBotSelfAttempt: Attempt to use /unwarn on the bot itself.
- IllegalTriggerWarned: Automatic Illegal trigger warning that will mention warned user and his current amount of warnings.
- IllegalTriggerBanned: Automatic Illegal trigger warning that will mention banned user.
- WCountMessage: Post /wcount message that will mention user and his amount of warnings (only when > 0).
- WCountUserHasNoWarnings: Post /wcount message that will mention user, user has any warnings (= 0).
- WCountAdminAttempt: Attempt to use /wcount on administrator when AllowAdminWarnings = false.
- WCountBotAttempt: Attempt to use /wcount on another bot.
- WCountBotSelfAttempt: Attempt to use /wcount on the bot itself.
Messages that will trigger the bot and send a response to corresponding chat with a triggered message attached in reply of response message.
- Chat: Chat to which the trigger is applicable or null (any chat).
- Messages: Messages array that will trigger the bot.
- Responses: Reactions (1 random response from set) of the bot to the member who triggered it.
- MatchCase: Whether message must match upper/lower case to trigger.
- MatchWholeMessage: Whether message must match whole message to trigger.
Notification is sent to admins (optional Warn sender) when an illegal word is sent in a specific chat (or any chat).
- Chat: Chat to which the notification is applicable or null (any chat).
- WarnMember: Whether the sender of the message is going to receive a warning (IllegalTriggerWarned or IllegalTriggerBanned according to warnings amount).
- DeleteMessage: Whether the message with illegal word needs to be deleted.
- IgnoreAdmins: Whether the trigger will ignore messages from administrators.
- IllegalWords: Words array that will trigger the notification.
- NotifiedAdmins: Array of IDs of administrators that will receive the notification.
- send <Message> => Sending message into one specific chat or all cached chats.
- <Message> => Message to send. Please use "" to indicate message. Markdown formating allowed.
- -c | --chat => Chat with according Chat Id. If not specified, message is sent to all chats.
Example: send -c 123456 "Example message" or send "Hello World!"
- register <Chat Id> => Manipulate registered chats:
- <Chat Id> => Chat to (add to / remove from) the list.
- -l | --list => Show the list of registered chats.
- -r | --remove => Remove one specific chat from list.
Example: register 123456 or register -rm "-69420"
- leave / l <Chat Id> => Leave a specific chat.
- <Chat Id> => Chat that bot will leave.
Example: leave 123456 or l "-69420"
-
reload / r => Reload configurations (See: Configuration, Triggers and IllegalTriggers).
-
save / s => Save last cached data to json files (See: Users, Chats and ChatWarnings).
-
info / i => Show info about cached chats, users and warnings.
-
version / v => Version of bot.
Give it a ⭐ Star!
Drop to Issues
Or: [email protected]
Thanks in advance!