Telethon throws an error when I try to change the value of variable "taken", declared outside of the event handler.
from telethon import TelegramClient, events
import asyncio
async def main():
main_bot = await TelegramClient('main_bot', API_ID, API_HASH).start()
taken: bool = False
@main_bot.on(events.NewMessage)
async def event_handler(event):
print(taken)
taken = not taken
await main_bot.run_until_disconnected()
if __name__ == '__main__':
asyncio.run(main())
Only printing it doesn't show problems, if I comment out the line taker = not taker the error doesn't occur, if it's present even the line before fails