18 lines
728 B
Python
18 lines
728 B
Python
import requests, json
|
|
|
|
r = requests.get('https://api.telegram.org/bot5115036608:AAGeyXVq5eNvdAkaCQHU9NfH16uAAiSKiuk/getUpdates?offset=0')
|
|
d = r.json()
|
|
msgs = [m for m in d.get('result', []) if 'message' in m and m['message'].get('text') == 'Test topic id']
|
|
for m in msgs:
|
|
msg = m['message']
|
|
tid = msg.get('message_thread_id', 'none')
|
|
cid = msg['chat']['id']
|
|
from_id = msg['from']['id']
|
|
print(f'chat={cid} thread_id={tid} from={from_id} text={msg.get("text","")}')
|
|
if not msgs:
|
|
print('no matching messages found')
|
|
for m in d.get('result', []):
|
|
if 'message' in m:
|
|
mm = m['message']
|
|
print(f" text='{mm.get('text','')[:60]}' thread_id={mm.get('message_thread_id','-')}")
|