This commit is contained in:
4
main.py
4
main.py
@@ -10,10 +10,12 @@ load_dotenv()
|
|||||||
|
|
||||||
BOT_TOKENS = os.getenv("BOT_TOKENS", "").split(",")
|
BOT_TOKENS = os.getenv("BOT_TOKENS", "").split(",")
|
||||||
|
|
||||||
|
|
||||||
async def send_echo_message(message: Message, bot: Bot):
|
async def send_echo_message(message: Message, bot: Bot):
|
||||||
me = await bot.get_me()
|
me = await bot.get_me()
|
||||||
await message.answer(f"Это бот {me.username}, вы написали \"{message.text}\"")
|
await message.answer(f"Это бот {me.username}, вы написали \"{message.text}\"")
|
||||||
|
|
||||||
|
|
||||||
async def start_bot(token: str):
|
async def start_bot(token: str):
|
||||||
bot = Bot(
|
bot = Bot(
|
||||||
token,
|
token,
|
||||||
@@ -23,8 +25,10 @@ async def start_bot(token: str):
|
|||||||
dp.message.register(send_echo_message, F.text)
|
dp.message.register(send_echo_message, F.text)
|
||||||
await dp.start_polling(bot)
|
await dp.start_polling(bot)
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
await asyncio.gather(*(start_bot(token) for token in BOT_TOKENS if token))
|
await asyncio.gather(*(start_bot(token) for token in BOT_TOKENS if token))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|||||||
Reference in New Issue
Block a user