FEATURE: mute and warnings

- добавил методы для мута на день/неделю/навсегда
- теперь при нарушении правила 6(имя) мы пишем сообщение о нарушении только 1 раз, дальше просто удаляем сообщения юзера и копим его нарушения. Если нарушений 3 и более то выдаем автоматически мут на 1 день
This commit is contained in:
kotolex
2024-01-15 20:32:30 +05:00
parent 3ab94ead5c
commit ef3698a39d
4 changed files with 57 additions and 3 deletions
+21
View File
@@ -3,6 +3,7 @@ import asyncio
import html
import logging
import random
from time import time
from telebot import types
@@ -12,6 +13,9 @@ from .models import all_chat_quotes, add_quote, is_quote_in_chat, delete_quote_i
from .robot import bot
TYPING_TIMEOUT = 0.13 / 4 # Reading time is quarter of the same text writing time
FOR_EVER_TIMEOUT = 0
ONE_DAY_TIMEOUT = 86400
ONE_WEEK_TIMEOUT = 86400 * 7
def speak(chance_of: int, chat_id: int) -> None | str:
@@ -36,6 +40,23 @@ async def act(message: types.Message):
await send_quote(len(quote) * 0.13, message, quote)
async def mute_forever(chat_id: int, user_id: int):
await mute(chat_id, user_id, FOR_EVER_TIMEOUT)
async def mute_for_one_day(chat_id: int, user_id: int):
await mute(chat_id, user_id, ONE_DAY_TIMEOUT)
async def mute_for_one_week(chat_id: int, user_id: int):
await mute(chat_id, user_id, ONE_WEEK_TIMEOUT)
async def mute(chat_id, user_id, period):
logging.info(f"[MUTED] User {user_id} has been muted for: {period} seconds")
await bot.restrict_chat_member(chat_id, user_id, until_date=time() + period)
@bot.message_handler(func=is_white_id, commands=["add"])
async def add_stan_quote(message: types.Message):
if message.reply_to_message and message.reply_to_message.text: