mirror of
https://github.com/Nick80835/microbot
synced 2025-08-24 19:18:36 +00:00
handle worthless exceptions properly
This commit is contained in:
parent
b508240949
commit
edd35a0060
@ -5,7 +5,7 @@ from re import DOTALL, IGNORECASE, escape, search
|
|||||||
from traceback import format_exc, print_exc
|
from traceback import format_exc, print_exc
|
||||||
|
|
||||||
from telethon import events
|
from telethon import events
|
||||||
from telethon.errors.rpcerrorlist import ChatWriteForbiddenError
|
from telethon.errors.rpcerrorlist import ChatWriteForbiddenError, ChatAdminRequiredError
|
||||||
|
|
||||||
from .database import ChatWrapper
|
from .database import ChatWrapper
|
||||||
from .fixes import inline_photos
|
from .fixes import inline_photos
|
||||||
@ -35,8 +35,9 @@ class CommandHandler():
|
|||||||
async def report_incoming_excepts(self, event):
|
async def report_incoming_excepts(self, event):
|
||||||
try:
|
try:
|
||||||
await self.handle_incoming(event)
|
await self.handle_incoming(event)
|
||||||
except:
|
except Exception as exception:
|
||||||
await event.client.send_message(int(self.settings.get_list("owner_id")[0]), str(format_exc()))
|
if not isinstance(exception, (ChatAdminRequiredError, ChatWriteForbiddenError)):
|
||||||
|
await event.client.send_message(int(self.settings.get_list("owner_id")[0]), str(format_exc()))
|
||||||
|
|
||||||
async def handle_incoming(self, event):
|
async def handle_incoming(self, event):
|
||||||
chat_db = ChatWrapper(self.db.get_chat((await event.get_chat()).id))
|
chat_db = ChatWrapper(self.db.get_chat((await event.get_chat()).id))
|
||||||
@ -255,11 +256,6 @@ class CommandHandler():
|
|||||||
else:
|
else:
|
||||||
if command.chance and randint(0, 100) <= command.chance or not command.chance:
|
if command.chance and randint(0, 100) <= command.chance or not command.chance:
|
||||||
await command.function(event)
|
await command.function(event)
|
||||||
except ChatWriteForbiddenError:
|
|
||||||
command.lock_reason = None
|
|
||||||
|
|
||||||
if event.sender_id in command.locked_users:
|
|
||||||
command.locked_users.remove(event.sender_id)
|
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
command.lock_reason = None
|
command.lock_reason = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user