RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Помогите исправить ошибку, чет вообще не могу понять в чем проблема.
Task exception was never retrieved
future: <Task finished name='Task-7' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\User\Desktop\allBot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=AttributeError('__enter__')>
Traceback (most recent call last):
File "C:\Users\User\Desktop\allBot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "C:\Users\User\Desktop\allBot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "C:\Users\User\Desktop\allBot\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\User\Desktop\allBot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "C:\Users\User\Desktop\allBot\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\User\Desktop\allBot\main.py", line 23, in main
with bot:
AttributeError: __enter__
C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py:1897: RuntimeWarning: coroutine 'AuthMethods._start' was never awaited
handle = None # Needed to break cycles when an exception occurs.
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
from aiogram import Bot, Dispatcher,executor, types
from aiogram.types import ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton
from telethon import TelegramClient
import asyncio
api_id = # Your API_ID
api_hash = "" # Your APP_ID
bot_token = "" # (via botfather, you can alternatively sign in as a user)
goupid = -4075187420
bot = Bot(token=bot_token)
dp = Dispatcher(bot)
#users = []
@dp.message_handler(commands=['all'])
async def main(message: types.Message):
async def get_users(client, group_id):
async for user in client.iter_participants(group_id):
if not user.deleted:
print(user.username)
# users.append(user.username)
bot = TelegramClient('bot', api_id, api_hash).start(bot_token=bot_token)
with bot:
asyncio.get_event_loop().run_until_complete(get_users(bot, goupid))
#for i in users:
#if i == None:
# continue
#else:
# await message.answer("@"+i)
executor.start_polling(dp)