Handle errors better
This commit is contained in:
parent
5df67e3241
commit
9d41cafb3e
|
@ -35,7 +35,11 @@ async def new_message(event):
|
|||
logging.info('[SEND] {}: {}'.format(name, text))
|
||||
|
||||
data = dict(name=name, message=text)
|
||||
try:
|
||||
await web.post(api('/up/sendmessage'), json=data)
|
||||
except aiohttp.ClientError:
|
||||
logging.exception('Problem sending message to dynmap:')
|
||||
|
||||
|
||||
async def main():
|
||||
global web
|
||||
|
@ -45,6 +49,7 @@ async def main():
|
|||
logging.info('Bridge loaded')
|
||||
|
||||
while True:
|
||||
try:
|
||||
async with web.get(api('/up/world/world/' + str(last_time))) as res:
|
||||
j = await res.json(content_type='text/plain;charset=utf-8')
|
||||
last_time = j['timestamp']
|
||||
|
@ -61,6 +66,8 @@ async def main():
|
|||
logging.info('[RECV] ' + message)
|
||||
await bot.send_message(settings.CHAT_ID, message)
|
||||
last_msg = message
|
||||
except aiohttp.ClientError:
|
||||
logging.exception('Problem getting message from dynmap:')
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user