Store received messages instead of updates
This commit is contained in:
parent
d45833cb6e
commit
42d34d59c8
|
@ -37,7 +37,7 @@ with open('.last_msg','r') as f:
|
|||
|
||||
API = f'https://api.telegram.org/bot{TOKEN}'
|
||||
|
||||
UPDATES = CHAT_PATH+'updates.json'
|
||||
MESSAGES = CHAT_PATH+'messages.json'
|
||||
|
||||
USER_NAMES = {i:config['users'][i] for i in config['users']}
|
||||
GROUP_NAMES = {i:config['groups'][i] for i in config['groups']}
|
||||
|
|
|
@ -28,9 +28,10 @@ def get_updates(offset=0):
|
|||
try:
|
||||
with urllib.request.urlopen(f'{API}/getUpdates?offset={offset}') as request:
|
||||
updates = json.loads(request.read())
|
||||
with open(UPDATES, 'a') as f:
|
||||
with open(MESSAGES, 'a') as f:
|
||||
for i in updates['result']:
|
||||
f.write(json.dumps(i, indent=4)+'\n')
|
||||
if 'message' in i:
|
||||
f.write(json.dumps(i['message'], indent=4)+'\n')
|
||||
except urllib.error.HTTPError as e:
|
||||
print(f'HTTP error {e.code}: {e.reason}')
|
||||
if e.code == 401:
|
||||
|
|
Reference in New Issue