polling-log2
This commit is contained in:
parent
fb977fe529
commit
ff57e35f53
|
@ -18,12 +18,12 @@ async def telegram_api(endpoint: str, json_data=None, **kwargs):
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
url = api_base + f"{endpoint}?{urlencode(kwargs)}"
|
url = api_base + f"{endpoint}?{urlencode(kwargs)}"
|
||||||
if not is_polling:
|
#if not is_polling:
|
||||||
logger.info(f' >>> {url} {json_data if json_data else ""}')
|
logger.info(f' >>> {url} {json_data if json_data else ""}')
|
||||||
async with session.get(url, data=json.dumps(json_data), headers=headers) as response:
|
async with session.get(url, data=json.dumps(json_data), headers=headers) as response:
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
if not is_polling:
|
# if not is_polling:
|
||||||
logger.info(f' <<< {data}')
|
logger.info(f' <<< {data}')
|
||||||
return data
|
return data
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
2
main.py
2
main.py
|
@ -19,7 +19,7 @@ async def start():
|
||||||
offset = 0 # init offset
|
offset = 0 # init offset
|
||||||
while True:
|
while True:
|
||||||
response = await telegram_api("getUpdates", offset=offset, allowed_updates=['message', 'message_reaction'])
|
response = await telegram_api("getUpdates", offset=offset, allowed_updates=['message', 'message_reaction'])
|
||||||
logger.debug(response)
|
# logger.debug(response)
|
||||||
if isinstance(response, dict):
|
if isinstance(response, dict):
|
||||||
result = response.get("result", [])
|
result = response.get("result", [])
|
||||||
for update in result:
|
for update in result:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user