diff --git a/telegram_bot.py b/telegram_bot.py index 964cccd..4a60782 100755 --- a/telegram_bot.py +++ b/telegram_bot.py @@ -341,7 +341,10 @@ def format_signal_message(report: SignalReport) -> str: f"๐Ÿ“Š Regime: {regime_str} ยท Vol: {vol_str}", ] if report.action_recommendation: - lines.append(f"_{_escape_md(report.action_recommendation)}_") + # Pattern identifiers use underscores, which legacy Telegram Markdown + # can misparse even when escaped inside this italicized action line. + action = report.action_recommendation.replace("_", " ") + lines.append(f"_{_escape_md(action)}_") if report.trade_setup and sig not in (SignalStrength.NEUTRAL,): ts = report.trade_setup diff --git a/test_all.py b/test_all.py index f854353..54b9719 100644 --- a/test_all.py +++ b/test_all.py @@ -1685,6 +1685,15 @@ def _(): assert "Not financial advice" in msg +@test("format_signal_message makes chart pattern actions Markdown-safe") +def _(): + report = SignalReport(symbol="XAU/USD", display_name="XAU/USD", timestamp="now") + report.action_recommendation = "BUY โ€” double_bottom pattern completion" + msg = format_signal_message(report) + assert "_BUY โ€” double bottom pattern completion_" in msg + assert "double_bottom" not in msg + + @test("format_signal_message renders stamped per-TF trail plan") def _(): def _setup(**extra):