Update broadcast_example.py

Added an exception in which the bot is the first to start a conversation
This commit is contained in:
bakhrullo 2022-12-27 11:49:02 +03:00 committed by GitHub
parent ae534298e5
commit 15e969cf47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,6 +35,8 @@ async def send_message(user_id: int, text: str, disable_notification: bool = Fal
await bot.send_message(user_id, text, disable_notification=disable_notification)
except exceptions.BotBlocked:
log.error(f"Target [ID:{user_id}]: blocked by user")
except exceptions.CantInitiateConversation:
log.error(f"Target [ID:{user_id}]: bot can't initiate conversation with a user")
except exceptions.ChatNotFound:
log.error(f"Target [ID:{user_id}]: invalid user ID")
except exceptions.RetryAfter as e: