media limit

This commit is contained in:
2019-08-19 22:05:45 +03:00
parent 029d08d2aa
commit 8d564fb31b
2 changed files with 16 additions and 0 deletions
+11
View File
@@ -2,6 +2,7 @@
import logging
import traceback
from datetime import datetime, timedelta
from html import escape
from queue import Queue, Empty
from time import sleep
@@ -232,6 +233,16 @@ def users_list(bot: Bot, update: Update):
def _process_message(bot: Bot, m: Message):
if m.sticker or m.animation:
delta = datetime.now() - conn.root.last_media
if delta < timedelta(seconds=15):
bot.send_message(
m.from_user.id,
'Не вайпи, до следующей гифки/стикера осталось {} секунд'.format(15 - int(delta.total_seconds()))
)
return
conn.root.last_media = datetime.now()
commit()
current_chat = m.chat_id
users = conn.root.subscribers # type: Dict[int, Subscriber]
if current_chat not in users: