Log Telegram API response message_id to find duplicate source
This commit is contained in:
@@ -81,7 +81,15 @@ def send_telegram_direct(chat_id: str, token: str, text: str) -> None:
|
||||
url = f'https://api.telegram.org/bot{token}/sendMessage'
|
||||
data = json.dumps({'chat_id': chat_id, 'text': text}).encode()
|
||||
req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application/json'})
|
||||
urllib.request.urlopen(req, timeout=10)
|
||||
try:
|
||||
resp = urllib.request.urlopen(req, timeout=10)
|
||||
resp_body = resp.read()
|
||||
import re
|
||||
msg_id = re.search(r'"message_id":(\d+)', resp_body.decode('utf-8', errors='replace'))
|
||||
print(f'[agent-runner] Telegram sendMessage -> msg_id={msg_id.group(1) if msg_id else "?"} hash={h}')
|
||||
except Exception as e:
|
||||
print(f'[agent-runner] Telegram sendMessage FAILED: {type(e).__name__}: {e} hash={h}')
|
||||
raise
|
||||
|
||||
|
||||
def get_or_create_session(actor_id: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user