Skip to content

Commit c979d80

Browse files
committed
fix: formatting
1 parent e848ad7 commit c979d80

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

bot.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ async def generate_answer(question: str, messages: list, conversation_id: str |
194194
return {"answer": f"{default_error_msg} (Unexpected Error)", "conversation_id": conversation_id}
195195

196196

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-
203197

204198
async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
205199
"""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:
224218

225219
await save_chat_data(chat_id, current_history, new_conversation_id)
226220

227-
escaped_answer = escape_markdown(answer)
228221
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)
230223
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.")
232225
try:
233226
await update.message.reply_text(answer)
234227
except Exception as fallback_e:

0 commit comments

Comments
 (0)