@@ -194,12 +194,6 @@ async def generate_answer(question: str, messages: list, conversation_id: str |
194
194
return {"answer" : f"{ default_error_msg } (Unexpected Error)" , "conversation_id" : conversation_id }
195
195
196
196
197
- def escape_markdown (text : str ) -> str :
198
- """Helper function to escape telegram markup symbols for MarkdownV2."""
199
- if not isinstance (text , str ): text = str (text )
200
- escape_chars = r'_*[]()~`>#+-=|{}.!'
201
- return re .sub (f'([{ re .escape (escape_chars )} ])' , r'\\\1' , text )
202
-
203
197
204
198
async def echo (update : Update , context : ContextTypes .DEFAULT_TYPE ) -> None :
205
199
"""Handles non-command messages: get history, query API, save history, reply."""
@@ -224,11 +218,10 @@ async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
224
218
225
219
await save_chat_data (chat_id , current_history , new_conversation_id )
226
220
227
- escaped_answer = escape_markdown (answer )
228
221
try :
229
- await update .message .reply_text (escaped_answer , parse_mode = ParseMode .MARKDOWN_V2 )
222
+ await update .message .reply_text (answer , parse_mode = ParseMode .MARKDOWN )
230
223
except Exception as e :
231
- logger .warning (f"Failed to send MarkdownV2 message to chat { chat_id } : { e } . Retrying with plain text." )
224
+ logger .warning (f"Failed to send Markdown message to chat { chat_id } : { e } . Retrying with plain text." )
232
225
try :
233
226
await update .message .reply_text (answer )
234
227
except Exception as fallback_e :
0 commit comments