11 lines
387 B
Python
11 lines
387 B
Python
import requests, json
|
|
|
|
r = requests.get('https://api.telegram.org/bot5115036608:AAGeyXVq5eNvdAkaCQHU9NfH16uAAiSKiuk/getUpdates?offset=-10')
|
|
d = r.json()
|
|
msgs = [m for m in d.get('result',[]) if 'message' in m]
|
|
print(f"Total messages: {len(msgs)}")
|
|
for m in msgs[-5:]:
|
|
cid = m['message']['chat']['id']
|
|
txt = m['message'].get('text','')[:150]
|
|
print(f" chat={cid} text={txt}")
|