mirror of
https://github.com/father-bot/chatgpt_telegram_bot.git
synced 2026-06-13 03:54:57 +03:00
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:
+1
-1
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user