MissKatyPyro/misskaty/core/message_utils.py
deepsource-autofix[bot] 0dbab68a39
Format code with black and isort (#9)
This commit fixes the style issues introduced in 95ecce1 according to the output
from black and isort.

Details: https://deepsource.io/gh/yasirarism/MissKatyPyro/transform/2b5c318f-57d7-4419-8e76-1d6c31d72999/

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2023-01-10 20:20:35 +07:00

45 lines
1.2 KiB
Python

import asyncio
from logging import getLogger
from pyrogram.errors import ChatWriteForbidden, FloodWait, MessageNotModified
LOGGER = getLogger(__name__)
# handler for TG function, so need write exception in every code
async def kirimPesan(msg, text: str, disable_web_page_preview=True, reply_markup=None):
try:
return await msg.reply(text)
except FloodWait as e:
LOGGER.warning(str(e))
await asyncio.sleep(e.value)
return await kirimPesan(text)
except ChatWriteForbidden:
return await msg.leave()
except Exception as e:
LOGGER.error(str(e))
async def editPesan(msg, text: str, disable_web_page_preview=True, reply_markup=None):
try:
return await msg.edit(text)
except FloodWait as e:
LOGGER.warning(str(e))
await asyncio.sleep(e.value)
return await editPesan(msg, text)
except MessageNotModified:
return
except Exception as e:
LOGGER.error(str(e))
async def hapusPesan(msg):
try:
return await msg.delete()
except FloodWait as e:
LOGGER.warning(str(e))
await asyncio.sleep(e.value)
return await hapusPesan(msg)
except Exception as e:
LOGGER.error(str(e))