From a0e65d8bd9b9b61d1e6b608fc19d7706a4f46c23 Mon Sep 17 00:00:00 2001 From: F4ria Date: Mon, 15 Apr 2024 18:55:30 +0800 Subject: [PATCH] start a new chat if the message starts with 'new ' --- handlers/chatgpt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/handlers/chatgpt.py b/handlers/chatgpt.py index 215f716..f42d999 100644 --- a/handlers/chatgpt.py +++ b/handlers/chatgpt.py @@ -48,6 +48,9 @@ def chatgpt_handler(message: Message, bot: TeleBot) -> None: ) player_message.clear() return + if m[:4].lower() == "new ": + m = m[4:].strip() + player_message.clear() who = "ChatGPT" # show something, make it more responsible @@ -106,6 +109,9 @@ def chatgpt_pro_handler(message: Message, bot: TeleBot) -> None: ) player_message.clear() return + if m[:4].lower() == "new ": + m = m[4:].strip() + player_message.clear() who = "ChatGPT Pro" reply_id = bot_reply_first(message, who, bot) @@ -128,7 +134,7 @@ def chatgpt_pro_handler(message: Message, bot: TeleBot) -> None: if chunk.choices[0].delta.content is None: break s += chunk.choices[0].delta.content - if time.time() - start > 1.7: + if time.time() - start > 2.0: start = time.time() bot_reply_markdown(reply_id, who, s, bot, split_text=False) @@ -193,7 +199,7 @@ def chatgpt_photo_handler(message: Message, bot: TeleBot) -> None: if chunk.choices[0].delta.content is None: break s += chunk.choices[0].delta.content - if time.time() - start > 1.7: + if time.time() - start > 2.0: start = time.time() bot_reply_markdown(reply_id, who, s, bot, split_text=False)