Files
milti_bot/main.py
Andrey K. Choi 933b2eda78
All checks were successful
continuous-integration/drone/push Build is passing
flake8
2025-07-19 19:26:39 +09:00

37 lines
881 B
Python

import asyncio
import os
from aiogram import Bot, Dispatcher, F
from aiogram.types import Message
from aiogram.enums import ParseMode
from dotenv import load_dotenv
from aiogram.client.default import DefaultBotProperties
load_dotenv()
BOT_TOKENS = os.getenv("BOT_TOKENS", "").split(",")
async def send_echo_message(message: Message, bot: Bot):
me = await bot.get_me()
await message.answer(
f"Это бот {me.username}, вы написали \"{message.text}\""
)
async def start_bot(token: str):
bot = Bot(
token,
default=DefaultBotProperties(parse_mode=ParseMode.HTML)
)
dp = Dispatcher()
dp.message.register(send_echo_message, F.text)
await dp.start_polling(bot)
async def main():
await asyncio.gather(*(start_bot(token) for token in BOT_TOKENS if token))
if __name__ == "__main__":
asyncio.run(main())