@@ -698,21 +698,39 @@ fn split_long_message(text: &str) -> Vec<String> {
698698async fn reply_markdown ( bot : Bot , msg : Message , text : String ) -> ResponseResult < ( ) > {
699699 let escaped = markdown_v2_escape ( & text) ;
700700 if escaped. len ( ) <= MAX_MESSAGE_LENGTH {
701- bot. send_message ( msg. chat . id , escaped)
701+ if let Err ( e) = bot
702+ . send_message ( msg. chat . id , escaped)
702703 . parse_mode ( ParseMode :: MarkdownV2 )
703704 . reply_to ( msg. id )
704705 . await
705- . map ( |_| ( ) ) ?;
706+ {
707+ log:: warn!(
708+ "MarkdownV2 failed for short message, falling back to plain text: {}" ,
709+ e
710+ ) ;
711+ let _ = bot. send_message ( msg. chat . id , text) . reply_to ( msg. id ) . await ;
712+ }
706713 return Ok ( ( ) ) ;
707714 }
708- // Message is too long → split and send as multiple replies (all with MarkdownV2)
715+
716+ // Message is too long → split and send as multiple replies
717+ // (try MarkdownV2 per chunk, fallback to plain text if it fails)
709718 for chunk in split_long_message ( & escaped) {
710- let _ = bot
711- . send_message ( msg. chat . id , chunk)
719+ if let Err ( e ) = bot
720+ . send_message ( msg. chat . id , chunk. as_str ( ) )
712721 . parse_mode ( ParseMode :: MarkdownV2 )
713722 . reply_to ( msg. id )
714- . await ;
715- // We intentionally ignore per-chunk errors so the rest of the text still gets delivered
723+ . await
724+ {
725+ log:: warn!(
726+ "MarkdownV2 failed for long message chunk, falling back to plain text: {}" ,
727+ e
728+ ) ;
729+ let _ = bot
730+ . send_message ( msg. chat . id , chunk. as_str ( ) )
731+ . reply_to ( msg. id )
732+ . await ;
733+ }
716734 }
717735 Ok ( ( ) )
718736}
0 commit comments