E
E
ennyti2021-11-01 20:55:21
Bots
ennyti, 2021-11-01 20:55:21

Mut system with timer for moderator bot. How can it be implemented?

I am making a python moderator bot for telegram using the aiogram library and the sqlite3 DBMS. It got to the point that it took a user muta system for a specific period of time in minutes. I decided to implement this using a timer, but I thought that it would not be rational. I came to such a model of the system operation:

A table with the name mutes is created on sqlite3, it contains 3 columns: user_id - username, date - current date, om_date - date of removal of the mute.
Everything should work like this: A user with administrator rights writes a command to the telegram chat !mute with the parameters user_id and time in minutes how much the villain should be limited to the chat (messages of a tortured user will be automatically deleted when sent, and after n messages he will be sent to a ban) . The bot, in turn, must form a record and add the following to the mutes table:
user_id - ID of the villain
date - current date
om_date - current date + n-number of minutes.
A condition is created in the bot itself, if the current time is equal to om_date, then the mut is no longer valid and the user can continue communication.

Since I'm not too strong in python, as in sqlite3, I tried to "pick" something with my own hands, but very quickly my brain began to melt, having looked around a bunch of threads on stackoverflow and didn't find anything sensible. If there are people who have come across such a system who are ready to help with its implementation - I will be grateful, also if my model of this system is too tricky in your opinion and you know how to simplify it - please, correct me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-01
@ennyti

And why all the databases, timer countdowns, etc., if restrictChatMember has a parameter until_datethat is responsible for the blocking time? When the time reaches the until_datelimits, the user is removed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question