import logging import requests from .. import loader, utils logger = logging.getLogger(__name__) def register(cb): cb(TagallMod()) def chunks(lst, n): for i in range(0, len(lst), n): yield lst[i:i + n] class TagallMod(loader.Module): strings = {"name": "Tagall"} def __init__(self): self.config = loader.ModuleConfig("DEFAULT_MENTION_MESSAGE", "Привет", "Default message of mentions") self.name = self.strings["name"] async def client_ready(self, client, db): self.client = client async def tagallcmd(self, message): arg = utils.get_args_raw(message) logger.error(message) notifies = [] async for user in self.client.iter_participants(message.to_id): notifies.append("\u206c\u206f") chunkss = list(chunks(notifies, 500)) logger.error(chunkss) await message.delete() for chunk in chunkss: await self.client.send_message(message.to_id, (self.config["DEFAULT_MENTION_MESSAGE"] if not arg else arg) + '\u206c\u206f'.join(chunk))