From aedb94c0ef0b627dc1c4487015a5a77e5a0d333e Mon Sep 17 00:00:00 2001 From: wedarobi <61944837+wedarobi@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:11:45 +0530 Subject: [PATCH] Don't reset dialog if already new (#83) If the /new command was the last interaction, and the following interaction takes place after the timeout, this prevents showing a redundant "starting new dialog" message. --- bot/bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/bot.py b/bot/bot.py index ed485ad..f04ab67 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -98,7 +98,7 @@ async def message_handle(update: Update, context: CallbackContext, message=None, # new dialog timeout if use_new_dialog_timeout: - if (datetime.now() - db.get_user_attribute(user_id, "last_interaction")).seconds > config.new_dialog_timeout: + if (datetime.now() - db.get_user_attribute(user_id, "last_interaction")).seconds > config.new_dialog_timeout and len(db.get_dialog_messages(user_id)) > 0: db.start_new_dialog(user_id) await update.message.reply_text("Starting new dialog due to timeout ✅") db.set_user_attribute(user_id, "last_interaction", datetime.now())