notification

This commit is contained in:
Karol Wypchlo 2021-03-01 17:22:43 +01:00
parent fb0ab9bb50
commit 1c9bdd4dc6
1 changed files with 3 additions and 3 deletions

View File

@ -19,7 +19,7 @@ async def block_skylinks_from_airtable():
if airtable.status_code != 200: if airtable.status_code != 200:
message = "Airtable blocklist integration responded with code " + str(airtable.status_code) + ": " + (airtable.text or "empty response") message = "Airtable blocklist integration responded with code " + str(airtable.status_code) + ": " + (airtable.text or "empty response")
return print(message) or await send_msg(client, message, force_notify=False) return print(message) or await send_msg(client, message, force_notify=True)
skylinks = [entry['fields'][AIRTABLE_FIELD] for entry in airtable.json()['records']] skylinks = [entry['fields'][AIRTABLE_FIELD] for entry in airtable.json()['records']]
print("Airtable returned " + str(len(skylinks)) + " skylinks to block") print("Airtable returned " + str(len(skylinks)) + " skylinks to block")
@ -37,7 +37,7 @@ async def block_skylinks_from_airtable():
return print("Skylinks successfully added to siad blocklist") return print("Skylinks successfully added to siad blocklist")
else: else:
message = "Siad blocklist endpoint responded with code " + str(response.status_code) + ": " + (response.text or "empty response") message = "Siad blocklist endpoint responded with code " + str(response.status_code) + ": " + (response.text or "empty response")
return await print(message) or send_msg(client, message, force_notify=False) return await print(message) or send_msg(client, message, force_notify=True)
async def exit_after(delay): async def exit_after(delay):
await asyncio.sleep(delay) await asyncio.sleep(delay)
@ -48,7 +48,7 @@ async def on_ready():
try: try:
await block_skylinks_from_airtable() await block_skylinks_from_airtable()
except: # catch all exceptions except: # catch all exceptions
await send_msg(client, "```\n{}\n```".format(traceback.format_exc()), force_notify=False) await send_msg(client, "```\n{}\n```".format(traceback.format_exc()), force_notify=True)
asyncio.create_task(exit_after(3)) asyncio.create_task(exit_after(3))
client.run(bot_token) client.run(bot_token)