Download FileStream/utils/broadcast_helper.py from AZLABS/telegbot: direct link, hf CLI and curl.
- Browser
- Download file 674 Bytes
-
https://huggingface.co/spaces/AZLABS/telegbot/resolve/main/FileStream/utils/broadcast_helper.py
- Command line
-
hf download hf://spaces/AZLABS/telegbot/FileStream/utils/broadcast_helper.py
-
curl -L -o broadcast_helper.py https://huggingface.co/spaces/AZLABS/telegbot/resolve/main/FileStream/utils/broadcast_helper.py
674 Bytes
| 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) | |
| return 200, None | |
| except FloodWait as e: | |
| await asyncio.sleep(e.value) | |
| 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: | |
| return 500, f"{user_id} : {traceback.format_exc()}\n" | |