I have 2 telegram bots that should expect a new message in the chat. At the beginning, when a message appears, both bots must remember the message, then the first one constantly remembers the messages, the second after some time 10 seconds, for example, while the first one works constantly.
I tried to implement this method, but it doesn’t work, does anyone have any ideas on how to fix this code? Also, does anyone know methods of working with teleton when the chat mode is slow? Thanks everyone and I hope you can help
from telethon import TelegramClient, sync, events, utils, functions, types
bot1 = TelegramClient()
bot2 = TelegramClient()
@bot1.on(events.NewMessage(chats=[channel_chat]))
async def handler(event):
print("bot 1")
@bot2.on(events.NewMessage(chats=[channel_chat]))
async def handler(event):
print("bot 2")
await asyncio.sleep(10)
bot1.start()
bot2.start()
async def main():
return await asyncio.gather(
bot1.run_until_disconnected(),
bot2.run_until_disconnected()
)
asyncio.run(main())
Djoneeee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.