35 lines
870 B
Python
35 lines
870 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())
|