From 81bed21a39856448ce28ac351ddad619a890218c Mon Sep 17 00:00:00 2001 From: graynk Date: Fri, 26 Feb 2021 21:39:52 +0500 Subject: [PATCH] throw away old messages in case the bot has been offline for some time --- bot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot.py b/bot.py index 9df818a..554c23c 100644 --- a/bot.py +++ b/bot.py @@ -9,6 +9,7 @@ from google.cloud import speech from google.cloud import storage from pymediainfo import MediaInfo +from datetime import datetime, timezone import os import io @@ -25,10 +26,14 @@ def start(update: Update, context: CallbackContext) -> None: + if (datetime.now(timezone.utc) - update.effective_message.date).days > 3: + return update.effective_message.reply_text("Say stuff, I'll transcribe") def voice_to_text(update: Update, context: CallbackContext) -> None: + if (datetime.now(timezone.utc) - update.effective_message.date).days > 3: + return chat_id = update.message.chat.id file_name = '%s_%s%s.ogg' % (chat_id, update.message.from_user.id, update.message.message_id)