Skip to content

Commit

Permalink
Add Error Handler
Browse files Browse the repository at this point in the history
Saatnya back fix bugs

Signed-off-by: Yasir Aris M <[email protected]>
  • Loading branch information
yasirarism authored Jan 10, 2025
1 parent dd51947 commit f468909
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions misskaty/plugins/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
FloodWait,
MessageTooLong,
PeerIdInvalid,
RPCError,
SlowmodeWait,
)
from pyrogram.raw.types import UpdateBotStopped
from pyrogram.types import (
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f468909

Please sign in to comment.