deanpowers commited on
Commit
513dcc9
Β·
1 Parent(s): 32c8ed5

telegram: entire message body now rendered at 1.5x (every line an H2 heading in Rich Messages)

Browse files
Files changed (4) hide show
  1. CHANGELOG.md +8 -0
  2. local_app.py +9 -8
  3. modules/telegram_alert.py +7 -4
  4. trader/app.py +0 -0
CHANGELOG.md CHANGED
@@ -94,6 +94,14 @@ All notable changes to Blind Monkeys. Format loosely follows
94
  place. Secrets remain env-injected via Secret Manager; nothing sensitive
95
  in source.
96
 
 
 
 
 
 
 
 
 
97
  ### Changed (off-repo: trader service)
98
  - **Per-grid Telegram profit messages** β€” grid round-trip profits are now sent
99
  as individual Telegram messages via a 2-minute cron (`grid-profit-events` β†’
 
94
  place. Secrets remain env-injected via Secret Manager; nothing sensitive
95
  in source.
96
 
97
+ - **All Telegram message text enlarged to ~1.5Γ—** β€” previously only the
98
+ timestamp heading was H2; now every line of every message body also renders
99
+ as an H2 heading in the Rich Message markdown (the only mechanism for
100
+ larger text β€” classic messages have no font-size markup). Applies to all
101
+ channels via the shared stamp helpers in the trader, main app, and
102
+ alerts module; classic fallback unchanged. Trader rev 00154, main app
103
+ rev 00428.
104
+
105
  ### Changed (off-repo: trader service)
106
  - **Per-grid Telegram profit messages** β€” grid round-trip profits are now sent
107
  as individual Telegram messages via a 2-minute cron (`grid-profit-events` β†’
local_app.py CHANGED
@@ -2572,16 +2572,17 @@ def api_diagnostic():
2572
  # ===================================================================
2573
 
2574
  def _tg_stamp(text):
2575
- """Prepend a heading-size timestamp (H2 β‰ˆ 1.5Γ— body text, per Dean's
2576
- request 2026-11-05) to a Telegram message, in Yerevan time (UTC+4).
2577
- Returns Rich Message markdown: classic messages have no font-size
2578
- markup, and no Telegram message has font-color markup, so the stamp
2579
- is an H2 heading with the green 🟒 marker. Body newlines get GFM hard
2580
- breaks so line-based messages don't merge."""
2581
  from datetime import datetime, timezone, timedelta
2582
  stamp = datetime.now(timezone(timedelta(hours=4))).strftime("%Y-%m-%d %H:%M:%S")
2583
- body = text.replace("\n", " \n")
2584
- out = f"## 🟒 {stamp}\n{body}"
 
 
2585
  if len(out) > 32000:
2586
  out = out[:32000] + "…"
2587
  return out
 
2572
  # ===================================================================
2573
 
2574
  def _tg_stamp(text):
2575
+ """Render a Telegram message at ~1.5Γ— normal text size (Dean
2576
+ 2026-11-05): each line β€” including the green 🟒 timestamp heading β€”
2577
+ becomes an H2 markdown heading in a Rich Message. Classic messages
2578
+ have no font-size markup, so H2 headings are the only way to enlarge
2579
+ text. Timestamp in Yerevan time (UTC+4)."""
 
2580
  from datetime import datetime, timezone, timedelta
2581
  stamp = datetime.now(timezone(timedelta(hours=4))).strftime("%Y-%m-%d %H:%M:%S")
2582
+ lines = ["## 🟒 " + stamp]
2583
+ for ln in text.split("\n"):
2584
+ lines.append("## " + ln if ln.strip() else "")
2585
+ out = "\n".join(lines)
2586
  if len(out) > 32000:
2587
  out = out[:32000] + "…"
2588
  return out
modules/telegram_alert.py CHANGED
@@ -23,13 +23,16 @@ def send_telegram_message(text: str) -> bool:
23
 
24
  from datetime import datetime, timezone, timedelta
25
  stamp = datetime.now(timezone(timedelta(hours=4))).strftime("%Y-%m-%d %H:%M:%S")
26
- # Primary: Rich Message β€” the stamp is an H2 heading (~1.5Γ— body size,
27
- # per Dean's request 2026-11-05). Body newlines get GFM hard breaks
28
- # (two trailing spaces) so line-based messages don't merge.
 
 
 
29
  try:
30
  r = requests.post(f"https://api.telegram.org/bot{token}/sendRichMessage", json={
31
  "chat_id": chat,
32
- "rich_message": {"markdown": f"## 🟒 {stamp}\n" + text.replace("\n", " \n")},
33
  }, timeout=15)
34
  if r.status_code == 200:
35
  return True
 
23
 
24
  from datetime import datetime, timezone, timedelta
25
  stamp = datetime.now(timezone(timedelta(hours=4))).strftime("%Y-%m-%d %H:%M:%S")
26
+ # Primary: Rich Message β€” every line (stamp + body) rendered as an H2
27
+ # heading (~1.5Γ— normal text size, per Dean's request 2026-11-05);
28
+ # classic messages have no font-size markup.
29
+ lines = ["## 🟒 " + stamp]
30
+ for ln in text.split("\n"):
31
+ lines.append("## " + ln if ln.strip() else "")
32
  try:
33
  r = requests.post(f"https://api.telegram.org/bot{token}/sendRichMessage", json={
34
  "chat_id": chat,
35
+ "rich_message": {"markdown": "\n".join(lines)},
36
  }, timeout=15)
37
  if r.status_code == 200:
38
  return True
trader/app.py CHANGED
The diff for this file is too large to render. See raw diff