start a new chat if the message starts with 'new '

This commit is contained in:
F4ria 2024-04-15 18:55:30 +08:00
parent 2248d649fc
commit a0e65d8bd9

View File

@ -48,6 +48,9 @@ def chatgpt_handler(message: Message, bot: TeleBot) -> None:
) )
player_message.clear() player_message.clear()
return return
if m[:4].lower() == "new ":
m = m[4:].strip()
player_message.clear()
who = "ChatGPT" who = "ChatGPT"
# show something, make it more responsible # show something, make it more responsible
@ -106,6 +109,9 @@ def chatgpt_pro_handler(message: Message, bot: TeleBot) -> None:
) )
player_message.clear() player_message.clear()
return return
if m[:4].lower() == "new ":
m = m[4:].strip()
player_message.clear()
who = "ChatGPT Pro" who = "ChatGPT Pro"
reply_id = bot_reply_first(message, who, bot) 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: if chunk.choices[0].delta.content is None:
break break
s += chunk.choices[0].delta.content s += chunk.choices[0].delta.content
if time.time() - start > 1.7: if time.time() - start > 2.0:
start = time.time() start = time.time()
bot_reply_markdown(reply_id, who, s, bot, split_text=False) 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: if chunk.choices[0].delta.content is None:
break break
s += chunk.choices[0].delta.content s += chunk.choices[0].delta.content
if time.time() - start > 1.7: if time.time() - start > 2.0:
start = time.time() start = time.time()
bot_reply_markdown(reply_id, who, s, bot, split_text=False) bot_reply_markdown(reply_id, who, s, bot, split_text=False)