Compare commits

...

2 Commits

Author SHA1 Message Date
Tamara Schmitz 03e1ab7479
add missing import 2023-05-24 17:49:39 +02:00
Tamara Schmitz 1ad3de611b
Revert "Revert "decrease telegram timeout, add sleep for ratelimit""
This reverts commit 5e371768e3.
2023-05-24 17:49:06 +02:00
1 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@ from bot import Bot
import logging
from report import Report
from twx.botapi import TelegramBot as Telegram
from time import sleep
logger = logging.getLogger(__name__)
@ -14,9 +15,9 @@ class TelegramBot(Bot):
try:
updates = tb.get_updates(offset=seen_tg + 1,
allowed_updates="message",
timeout=15).wait()
timeout=5).wait()
except TypeError:
updates = tb.get_updates(timeout=15).wait()
updates = tb.get_updates(timeout=5).wait()
reports = []
if updates == None:
return reports
@ -87,8 +88,8 @@ class TelegramBot(Bot):
text = text[:4096 - 2] + " \N{Horizontal ellipsis}"
try:
for subscriber_id in user.get_telegram_subscribers():
sleep(0.5)
tb.send_message(subscriber_id, text).wait()
sleep(0.5)
except Exception:
logger.error('Error telegramming: ' + user.get_city() + ': '
+ str(report.id), exc_info=True)