2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-31 14:38:04 +00:00

add a special exception reporting mechanism because fucking heroku

This commit is contained in:
Nick80835
2020-10-03 12:18:34 -04:00
parent 11092e8278
commit 293edf11ed

View File

@@ -3,6 +3,7 @@
import asyncio
from random import randint
from re import escape, search
from traceback import format_exc
from telethon import events
@@ -23,10 +24,16 @@ class CommandHandler():
self.username = client.loop.run_until_complete(client.get_me()).username
self.settings = settings
self.loader = loader
client.add_event_handler(self.handle_incoming, events.NewMessage(incoming=True))
client.add_event_handler(self.report_incoming_excepts, events.NewMessage(incoming=True))
client.add_event_handler(self.handle_inline, events.InlineQuery())
client.add_event_handler(self.handle_callback_query, events.CallbackQuery())
async def report_incoming_excepts(self, event):
try:
await self.handle_incoming(event)
except:
await event.client.send_message(int(self.settings.get_list("owner_id")[0]), str(format_exc()))
async def handle_incoming(self, event):
prefix = "|".join([escape(i) for i in (self.settings.get_list("cmd_prefix") or ['.'])])