@@ -186,10 +186,14 @@ async def getChatGPT(update, context, title, robot, message, chatid, messageid):
186
186
if "🌐" not in data :
187
187
result = result + data
188
188
tmpresult = result
189
- if re .sub (r"```" , '' , result ).count ("`" ) % 2 != 0 :
189
+ if re .sub (r"```" , '' , result . split ( " \n " )[ - 1 ] ).count ("`" ) % 2 != 0 :
190
190
tmpresult = result + "`"
191
- if result .count ("```" ) % 2 != 0 :
191
+ # if re.sub(r"```", '', result).count("`") % 2 != 0:
192
+ # tmpresult = result + "`"
193
+ if sum ([line .strip ().startswith ("```" ) for line in result .split ('\n ' )]) % 2 != 0 :
192
194
tmpresult = tmpresult + "\n ```"
195
+ # if result.count("```") % 2 != 0:
196
+ # tmpresult = tmpresult + "\n```"
193
197
tmpresult = title + tmpresult
194
198
if "claude" in title :
195
199
tmpresult = claude_replace (tmpresult )
@@ -219,10 +223,15 @@ async def getChatGPT(update, context, title, robot, message, chatid, messageid):
219
223
await context .bot .delete_message (chat_id = chatid , message_id = messageid )
220
224
messageid = ''
221
225
config .API = ''
222
- tmpresult = f"`{ e } `"
226
+ tmpresult = f"{ tmpresult } \n \n `{ e } `"
223
227
print (tmpresult )
224
228
if lastresult != tmpresult and messageid :
225
- await context .bot .edit_message_text (chat_id = chatid , message_id = messageid , text = escape (tmpresult ), parse_mode = 'MarkdownV2' , disable_web_page_preview = True , read_timeout = time_out , write_timeout = time_out , pool_timeout = time_out , connect_timeout = time_out )
229
+ if "Can't parse entities: can't find end of code entity at byte offset" in tmpresult :
230
+ # await context.bot.edit_message_text(chat_id=chatid, message_id=messageid, text=tmpresult, disable_web_page_preview=True, read_timeout=time_out, write_timeout=time_out, pool_timeout=time_out, connect_timeout=time_out)
231
+ await update .message .reply_text (tmpresult )
232
+ print (escape (tmpresult ))
233
+ else :
234
+ await context .bot .edit_message_text (chat_id = chatid , message_id = messageid , text = escape (tmpresult ), parse_mode = 'MarkdownV2' , disable_web_page_preview = True , read_timeout = time_out , write_timeout = time_out , pool_timeout = time_out , connect_timeout = time_out )
226
235
227
236
@decorators .GroupAuthorization
228
237
@decorators .Authorization
0 commit comments