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.
This commit is contained in:
wedarobi
2023-03-05 23:11:45 +05:30
committed by GitHub
parent 9b566b8521
commit aedb94c0ef
+1 -1
View File
@@ -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())