Add Error Handler

Saatnya back fix bugs

Signed-off-by: Yasir Aris M <git@yasir.id>
This commit is contained in:
Yasir Aris M 2025-01-10 18:05:28 +07:00 committed by GitHub
parent dd51947091
commit f468909f3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,6 +38,8 @@ from pyrogram.errors import (
FloodWait,
MessageTooLong,
PeerIdInvalid,
RPCError,
SlowmodeWait,
)
from pyrogram.raw.types import UpdateBotStopped
from pyrogram.types import (
@ -659,6 +661,17 @@ async def update_restart(_, ctx: Message, strings):
os.execvp(sys.executable, [sys.executable, "-m", "misskaty"])
@app.on_error(errors=(Exception, FloodWait, RPCError, SlowmodeWait))
async def error_handlers(_: "Client", __: "Update", error: "Exception") -> None:
    if isinstance(error, (FloodWait, SlowmodeWait)):
        await asyncio.sleep(error.value)
    # else:
        # if config.DEBUG_MODE:
        #   LOGGER.error(repr(error))
        # else:
        #    return None
@app.on_raw_update(group=-99)
async def updtebot(client, update, users, _):
if isinstance(update, UpdateBotStopped):