diff --git a/constants.py b/constants.py index 9aab3ff..38c8555 100644 --- a/constants.py +++ b/constants.py @@ -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']} diff --git a/scel-buc.py b/scel-buc.py index af6fd0e..99ebaa9 100755 --- a/scel-buc.py +++ b/scel-buc.py @@ -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: