Skip to content

Commit

Permalink
修复 chatgpt 前后回答一致 telegram 出错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed May 20, 2023
1 parent aebcea1 commit f7e8946
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion AI.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ async def getChatGPT(self, message, update, context):
result = "🤖️ ChatGPT3.5\n\n"
text = message
modifytime = 0
lastresult = ''
message = await context.bot.send_message(
chat_id=update.message.chat_id,
text="思考中💭",
Expand All @@ -129,8 +130,9 @@ async def getChatGPT(self, message, update, context):
tmpresult = result + "`"
if result.count("```") % 2 != 0:
tmpresult = result + "\n```"
if modifytime % 10 == 0:
if modifytime % 10 == 0 and lastresult != result:
await context.bot.edit_message_text(chat_id=update.message.chat_id, message_id=messageid, text=escape(tmpresult), parse_mode='MarkdownV2')
lastresult = result
except Exception as e:
print('\033[31m')
print("response_msg", result)
Expand Down

0 comments on commit f7e8946

Please sign in to comment.