Files
FileStreamBot/FileStream/utils/broadcast_helper.py

20 lines
674 B
Python
Raw Normal View History

2021-04-20 15:14:57 +06:00
import asyncio
import traceback
from pyrogram.errors import FloodWait, InputUserDeactivated, UserIsBlocked, PeerIdInvalid
async def send_msg(user_id, message):
try:
await message.copy(chat_id=user_id)
2021-04-20 15:14:57 +06:00
return 200, None
except FloodWait as e:
await asyncio.sleep(e.value)
2021-04-20 15:14:57 +06:00
return send_msg(user_id, message)
except InputUserDeactivated:
return 400, f"{user_id} : deactivated\n"
except UserIsBlocked:
return 400, f"{user_id} : blocked the bot\n"
except PeerIdInvalid:
return 400, f"{user_id} : user id invalid\n"
except Exception as e:
2022-01-02 19:22:16 +05:30
return 500, f"{user_id} : {traceback.format_exc()}\n"