mirror of
https://github.com/tropicoo/yt-dlp-bot.git
synced 2024-11-10 09:03:02 +08:00
Fix sending message to the user which the user that was not met yet
This commit is contained in:
parent
9ff5f8f7c3
commit
20a4dd5014
1 changed files with 6 additions and 1 deletions
|
@ -4,6 +4,7 @@ from typing import Iterable
|
|||
|
||||
from pyrogram import Client
|
||||
from pyrogram.enums import ParseMode
|
||||
from pyrogram.errors import RPCError
|
||||
|
||||
from bot.core.config.config import get_main_config
|
||||
from bot.core.config.schema import UserSchema
|
||||
|
@ -59,9 +60,13 @@ class VideoBot(Client):
|
|||
self, text: str, user_ids: Iterable[int], parse_mode: ParseMode = ParseMode.HTML
|
||||
) -> None:
|
||||
coros = []
|
||||
self._log.debug('Sending message "%s" to users %s', text, user_ids)
|
||||
for user_id in user_ids:
|
||||
coros.append(self.send_message(user_id, text, parse_mode=parse_mode))
|
||||
await asyncio.gather(*coros)
|
||||
results = await asyncio.gather(*coros, return_exceptions=True)
|
||||
for user_id, result in zip(user_ids, results):
|
||||
if isinstance(result, RPCError):
|
||||
self._log.error('User %s did not receive message: %s', user_id, result)
|
||||
|
||||
async def send_message_all(
|
||||
self, text: str, parse_mode: ParseMode = ParseMode.HTML
|
||||
|
|
Loading…
Reference in a new issue