fix: always use MarkdownV2 for all message types

This commit is contained in:
2026-07-11 21:35:22 +08:00
parent 43994d2b0d
commit 8007fa1cc4
3 changed files with 52 additions and 7 deletions

26
_test_tg.py Normal file
View File

@@ -0,0 +1,26 @@
import yaml, requests, json
with open("config.yaml", "r", encoding="utf-8") as f:
cfg = yaml.safe_load(f)
token = cfg["telegram"]["bot_token"]
chat_id = cfg["telegram"]["chat_id"]
# 测试1: 纯文本无 parse_mode
payload = {
"chat_id": chat_id,
"text": "🔑 Kraken 701383\n账户: test@test.com",
"reply_markup": {"inline_keyboard": [[{"text": "查看原文", "callback_data": "v"}, {"text": "回复", "callback_data": "r"}]]},
}
print("=== Test 1: plain text, no parse_mode ===")
r = requests.post(f"https://api.telegram.org/bot{token}/sendMessage", json=payload, timeout=10)
print(r.status_code, r.text[:300])
# 测试2: 不带 reply_markup
payload2 = {
"chat_id": chat_id,
"text": "🔑 Kraken 701383\n账户: test@test.com",
}
print("\n=== Test 2: no keyboard ===")
r2 = requests.post(f"https://api.telegram.org/bot{token}/sendMessage", json=payload2, timeout=10)
print(r2.status_code, r2.text[:300])