Я пишу бота для Telegram, которому нужно отправлять некоторые сообщения с помощью клиента Telethon, а некоторые — с помощью aiogram. Он делает ошибку, которую я не понимаю.
Я пробовал этот код:
Cause exception while process update id=xxx by bot id=xxx
RuntimeError: The asyncio event loop must not change after connection (see the FAQ for details)
Traceback (most recent call last):
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 309, in _process_update
response = await self.feed_update(bot, update, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 158, in feed_update
response = await self.update.wrap_outer_middleware(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\event\handler.py", line 43, in call
return await wrapped()
^^^^^^^^^^^^^^^
File "C:\Users\Artyxx\Documents\Python\bot\bot-check-in\testcode.py", line 19, in start
await client_send(message)
File "C:\Users\Artyxx\Documents\Python\bot\bot-check-in\testcode.py", line 23, in client_send
async with client:
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\auth.py", line 657, in __aenter__
return await self.start()
^^^^^^^^^^^^^^^^^^
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\auth.py", line 141, in _start
me = await self.get_me()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\users.py", line 165, in get_me
me = (await self(
^^^^^^^^^^^
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\users.py", line 34, in _call
raise RuntimeError('The asyncio event loop must not change after connection (see the FAQ for details)')
RuntimeError: The asyncio event loop must not change after connection (see the FAQ for details)
Как мне подключить и использовать эти две библиотеки
Я пишу бота для Telegram, которому нужно отправлять некоторые сообщения с помощью клиента Telethon, а некоторые — с помощью aiogram. Он делает ошибку, которую я не понимаю. Я пробовал этот код: [code]bot = Bot(token=bot_token) dp = Dispatcher() client = TelegramClient("session", api_id, api_hash).start(bot_token=bot_token)
if __name__ == '__main__': asyncio.run(main()) [/code] когда бот получает сообщение, я получаю такую длинную обратную связь: [code]Cause exception while process update id=xxx by bot id=xxx RuntimeError: The asyncio event loop must not change after connection (see the FAQ for details) Traceback (most recent call last): File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 309, in _process_update response = await self.feed_update(bot, update, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 158, in feed_update response = await self.update.wrap_outer_middleware( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...
File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\event\handler.py", line 43, in call return await wrapped() ^^^^^^^^^^^^^^^ File "C:\Users\Artyxx\Documents\Python\bot\bot-check-in\testcode.py", line 19, in start await client_send(message) File "C:\Users\Artyxx\Documents\Python\bot\bot-check-in\testcode.py", line 23, in client_send async with client: File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\auth.py", line 657, in __aenter__ return await self.start() ^^^^^^^^^^^^^^^^^^ File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\auth.py", line 141, in _start me = await self.get_me() ^^^^^^^^^^^^^^^^^^^ File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\users.py", line 165, in get_me me = (await self( ^^^^^^^^^^^ File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\users.py", line 30, in __call__ return await self._call(self._sender, request, ordered=ordered) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Artyxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\telethon\client\users.py", line 34, in _call raise RuntimeError('The asyncio event loop must not change after connection (see the FAQ for details)') RuntimeError: The asyncio event loop must not change after connection (see the FAQ for details) [/code] Как мне подключить и использовать эти две библиотеки