13 lines
600 B
Python
13 lines
600 B
Python
import requests, time
|
|
r = requests.get('https://api.telegram.org/bot5115036608:AAGeyXVq5eNvdAkaCQHU9NfH16uAAiSKiuk/getUpdates', params={'timeout': 10, 'allowed_updates': ['callback_query']}, timeout=15)
|
|
d = r.json()
|
|
print('ok:', d.get('ok'))
|
|
print('count:', len(d.get('result', [])))
|
|
for u in d.get('result', []):
|
|
types = [k for k in u if k != 'update_id']
|
|
print(' update %s: %s' % (u['update_id'], types))
|
|
if 'callback_query' in u:
|
|
cb = u['callback_query']
|
|
print(' data: %s' % cb.get('data',''))
|
|
print(' from: %s' % cb.get('from',{}).get('first_name',''))
|