mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Add Error Handler
Saatnya back fix bugs Signed-off-by: Yasir Aris M <git@yasir.id>
This commit is contained in:
parent
dd51947091
commit
f468909f3e
1 changed files with 13 additions and 0 deletions
|
|
@ -38,6 +38,8 @@ from pyrogram.errors import (
|
||||||
FloodWait,
|
FloodWait,
|
||||||
MessageTooLong,
|
MessageTooLong,
|
||||||
PeerIdInvalid,
|
PeerIdInvalid,
|
||||||
|
RPCError,
|
||||||
|
SlowmodeWait,
|
||||||
)
|
)
|
||||||
from pyrogram.raw.types import UpdateBotStopped
|
from pyrogram.raw.types import UpdateBotStopped
|
||||||
from pyrogram.types import (
|
from pyrogram.types import (
|
||||||
|
|
@ -659,6 +661,17 @@ async def update_restart(_, ctx: Message, strings):
|
||||||
os.execvp(sys.executable, [sys.executable, "-m", "misskaty"])
|
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)
|
@app.on_raw_update(group=-99)
|
||||||
async def updtebot(client, update, users, _):
|
async def updtebot(client, update, users, _):
|
||||||
if isinstance(update, UpdateBotStopped):
|
if isinstance(update, UpdateBotStopped):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue