/
memoto
/
pingAllBot
Обзор
Документация
Войти
/
memoto
/
pingAllBot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
bot/bot.py
62 строки
2 KB
memoto
initial upload
17 дек 2025, 22:52
17 дек 2025, 22:52
16e4052
Код
Авторство
О чём код?
import asyncio import random from aiogram import Bot, Dispatcher, types from aiogram.fsm.storage.memory import MemoryStorage from bot.config import load_config from bot.storage import normalize_users EMOJIS = ["🔥", "⚡", "⭐", "💥", "🎯", "🍀", "🌟"] async def is_admin(bot: Bot, message: types.Message) -> bool: member = await bot.get_chat_member( message.chat.id, message.from_user.id ) return member.status in ("creator", "administrator") async def send_mentions(bot: Bot, message: types.Message, users: list[str]): users = normalize_users(users) chunks = [users[i:i+5] for i in range(0, len(users), 5)] for chunk in chunks: text = " ".join( f"{random.choice(EMOJIS)} {u}" for u in chunk ) await bot.send_message( chat_id=message.chat.id, text=text, reply_to_message_id=message.message_id ) async def main(): config = load_config() bot = Bot(token=config["bot_token"]) dp = Dispatcher(storage=MemoryStorage()) @dp.message() async def handler(message: types.Message): text = (message.text or message.caption or "").lower() if not text.startswith("@"): return if not await is_admin(bot, message): return config = load_config() groups = config["groups"] final_users = [] for group in groups: if f"@{group}" in text: final_users.extend(groups[group]) if final_users: await send_mentions(bot, message, final_users) await dp.start_polling(bot) if __name__ == "__main__": asyncio.run(main())