Closed mdenushev closed 2 years ago
i fixed it by using telethon 1.0.4 and mtprotosender.py
from telethon 1.1.1 (i have to because of RecursionError
)
Doesn't seem to be present in the current sync
branch.
The error seems to return
2022-02-07T22:23:54.591712247Z Traceback (most recent call last):
2022-02-07T22:23:54.591718301Z File "/usr/local/lib/python3.7/site-packages/apscheduler/executors/base.py", line 125, in run_job
2022-02-07T22:23:54.591723837Z retval = job.func(*job.args, **job.kwargs)
2022-02-07T22:23:54.591743370Z File "/app/updater.py", line 36, in run_updater
2022-02-07T22:23:54.591748020Z new_users = get_subscribers(channel_id=channel['channel_id'], client=client, own_prefixes='auto')
2022-02-07T22:23:54.591751919Z File "/app/utils.py", line 107, in get_subscribers
2022-02-07T22:23:54.591756147Z new_users = _get_subscribers(client=client, channel_id=channel_id, own_prefixes=own_prefixes, limit=limit)
2022-02-07T22:23:54.591760543Z File "/app/utils.py", line 135, in _get_subscribers
2022-02-07T22:23:54.591765052Z for u in client.iter_participants(channel_id, limit=limit):
2022-02-07T22:23:54.591769334Z File "/usr/local/lib/python3.7/site-packages/telethon/requestiter.py", line 87, in __next__
2022-02-07T22:23:54.591773368Z return self.client.loop.run_until_complete(self.__anext__())
2022-02-07T22:23:54.591777371Z File "/usr/local/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
2022-02-07T22:23:54.591782075Z return future.result()
2022-02-07T22:23:54.591786151Z File "/usr/local/lib/python3.7/site-packages/telethon/requestiter.py", line 74, in __anext__
2022-02-07T22:23:54.591790234Z if await self._load_next_chunk():
2022-02-07T22:23:54.591793769Z File "/usr/local/lib/python3.7/site-packages/telethon/client/chats.py", line 224, in _load_next_chunk
2022-02-07T22:23:54.591798666Z participants = results[i]
2022-02-07T22:23:54.591802454Z TypeError: 'ChannelParticipants' object is not subscriptable
@Lonami what should I do about it?
I got telethon==1.24.0
currently.
The error seems to return
2022-02-07T22:23:54.591712247Z Traceback (most recent call last): 2022-02-07T22:23:54.591718301Z File "/usr/local/lib/python3.7/site-packages/apscheduler/executors/base.py", line 125, in run_job 2022-02-07T22:23:54.591723837Z retval = job.func(*job.args, **job.kwargs) 2022-02-07T22:23:54.591743370Z File "/app/updater.py", line 36, in run_updater 2022-02-07T22:23:54.591748020Z new_users = get_subscribers(channel_id=channel['channel_id'], client=client, own_prefixes='auto') 2022-02-07T22:23:54.591751919Z File "/app/utils.py", line 107, in get_subscribers 2022-02-07T22:23:54.591756147Z new_users = _get_subscribers(client=client, channel_id=channel_id, own_prefixes=own_prefixes, limit=limit) 2022-02-07T22:23:54.591760543Z File "/app/utils.py", line 135, in _get_subscribers 2022-02-07T22:23:54.591765052Z for u in client.iter_participants(channel_id, limit=limit): 2022-02-07T22:23:54.591769334Z File "/usr/local/lib/python3.7/site-packages/telethon/requestiter.py", line 87, in __next__ 2022-02-07T22:23:54.591773368Z return self.client.loop.run_until_complete(self.__anext__()) 2022-02-07T22:23:54.591777371Z File "/usr/local/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete 2022-02-07T22:23:54.591782075Z return future.result() 2022-02-07T22:23:54.591786151Z File "/usr/local/lib/python3.7/site-packages/telethon/requestiter.py", line 74, in __anext__ 2022-02-07T22:23:54.591790234Z if await self._load_next_chunk(): 2022-02-07T22:23:54.591793769Z File "/usr/local/lib/python3.7/site-packages/telethon/client/chats.py", line 224, in _load_next_chunk 2022-02-07T22:23:54.591798666Z participants = results[i] 2022-02-07T22:23:54.591802454Z TypeError: 'ChannelParticipants' object is not subscriptable
@Lonami what should I do about it? I got
telethon==1.24.0
currently.
same problems.
I have the same issue (ChannelParticipants object does not support indexing
) with:
client.iter_participants(entity, limit=None, filter=None, aggressive=False)
doing
client.iter_participants(entity, limit=None, filter=None, aggressive=True)
raises a FloodWaitError
Exception (used to work fine until today):`
telethon.errors.common.MultiError: ([FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)',), None, None, FloodWaitError('A wait of 30 seconds is required (caused by GetParticipantsRequest)',)
Thanks
Tracebacks, if it helps.
When aggressive=True
,
Traceback (most recent call last):
File "/PATH_TO_FOLDER/user_info_scraper.py", line 108, in <module>
all_participants = client.get_participants(group_entity, aggressive=True)
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/sync.py", line 39, in syncified
return loop.run_until_complete(coro)
File "/usr/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/client/chats.py", line 507, in get_participants
return await self.iter_participants(*args, **kwargs).collect()
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/requestiter.py", line 113, in collect
async for message in self:
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/requestiter.py", line 74, in __anext__
if await self._load_next_chunk():
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/client/chats.py", line 222, in _load_next_chunk
results = await self.client(self.requests)
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/client/users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/client/users.py", line 80, in _call
raise MultiError(exceptions, results, requests)
telethon.errors.common.MultiError: ([None, FloodWaitError('A wait of 31 seconds is required (caused by GetParticipantsRequest)'), FloodWaitError('A wait of 31 seconds is required (caused by GetParticipantsRequest)'), None, None, FloodWaitError('A wait of 31 seconds is required (caused by GetParticipantsRequest)')], [<telethon.tl.types.channels.ChannelParticipants object at 0x7f837d814a90>, None, None, <telethon.tl.types.channels.ChannelParticipants object at 0x7f837d8150f0>, <telethon.tl.types.channels.ChannelParticipants object at 0x7f837d816260>, None], [<telethon.tl.functions.channels.GetParticipantsRequest object at 0x7f837d8150c0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x7f837d8152d0>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x7f837d814f10>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x7f837d814d90>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x7f837d814c10>, <telethon.tl.functions.channels.GetParticipantsRequest object at 0x7f837beaaf80>])
When aggressive=False
,
Traceback (most recent call last):
File "/PATH_TO_FOLDER/user_info_scraper.py", line 110, in <module>
all_participants = client.get_participants(group_entity, aggressive=False)
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/sync.py", line 39, in syncified
return loop.run_until_complete(coro)
File "/usr/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/home/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/client/chats.py", line 507, in get_participants
return await self.iter_participants(*args, **kwargs).collect()
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/requestiter.py", line 113, in collect
async for message in self:
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/requestiter.py", line 74, in __anext__
if await self._load_next_chunk():
File "/PATH_TO_FOLDER/env/lib/python3.10/site-packages/telethon/client/chats.py", line 224, in _load_next_chunk
participants = results[i]
TypeError: 'ChannelParticipants' object is not subscriptable
Have the same issue in a 3.8 venv
Edit: downgrading to (turns out it didn't)telethon==1.22.0
seemed to help
Can someone confirm if the error is present in the development version, not v1.24.0 from PyPi? That is, does this error occur if master is installed?
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
I cannot reproduce the issue.
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
Uninstalled telethon from env, installed using this command. Now this happens:
Traceback (most recent call last):
File "/PROJECT_FOLDER/user_info_scraper.py", line 8, in <module>
from telethon.client import account
File "/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/__init__.py", line 4, in <module>
from ._misc import utils as _ # depends on helpers and _tl
File "/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/_misc/utils.py", line 23, in <module>
from . import markdown, html
File "/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/_misc/markdown.py", line 8, in <module>
import markdown_it
ModuleNotFoundError: No module named 'markdown_it'
Also tried installing the master version, but the API is too different from 1.24.0 to proceed with testing for me at this time
Also 1.22.0 showed the error as well after some time, so need to take back the previous success story.
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
Uninstalled telethon from env, installed using this command. Now this happens:
Traceback (most recent call last): File "/PROJECT_FOLDER/user_info_scraper.py", line 8, in <module> from telethon.client import account File "/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/__init__.py", line 4, in <module> from ._misc import utils as _ # depends on helpers and _tl File "/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/_misc/utils.py", line 23, in <module> from . import markdown, html File "/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/_misc/markdown.py", line 8, in <module> import markdown_it ModuleNotFoundError: No module named 'markdown_it'
Okay, after pip install markdown-it-py
, I'm facing import issues.
For from telethon import functions, types
,
Traceback (most recent call last):
File "/PROJECT_FOLDER/user_info_scraper.py", line 11, in <module>
from telethon import functions, types
ImportError: cannot import name 'functions' from 'telethon' (/PROJECT_FOLDER/env/lib/python3.10/site-packages/telethon/__init__.py)
For from telethon.client import account
,
Traceback (most recent call last):
File "/PROJECT_FOLDER/user_info_scraper.py", line 8, in <module>
from telethon.client import account
ModuleNotFoundError: No module named 'telethon.client'
For from telethon.sync import TelegramClient
,
Traceback (most recent call last):
File "/PROJECT_FOLDER/user_info_scraper.py", line 10, in <module>
from telethon.sync import TelegramClient
ModuleNotFoundError: No module named 'telethon.sync'
For from telethon.tl.functions.messages import GetDialogsRequest
,
Traceback (most recent call last):
File "/PROJECT_FOLDER/user_info_scraper.py", line 12, in <module>
from telethon.tl.functions.messages import GetDialogsRequest
ModuleNotFoundError: No module named 'telethon.tl'
And a few others.
I cannot reproduce the issue.
Can I provide any additional data? If yes, which and how.
I have the same issue. The same code has worked without errors for the past few months, but it can't work since 2 days ago. Is there anyone can fix it? It's confusing
File "\PROJECT_FOLDER\utils.py", line 131, in get_participants
participants = await client.get_participants(entity)
File "\PROJECT_FOLDER\venv\lib\site-packages\telethon\client\chats.py", line 503, in get_participants
return await self.iter_participants(*args, **kwargs).collect()
File "\PROJECT_FOLDER\venv\lib\site-packages\telethon\requestiter.py", line 113, in collect
async for message in self:
File "\PROJECT_FOLDER\venv\lib\site-packages\telethon\requestiter.py", line 74, in __anext__
if await self._load_next_chunk():
File "\PROJECT_FOLDER\venv\lib\site-packages\telethon\client\chats.py", line 223, in _load_next_chunk
participants = results[i]
TypeError: 'ChannelParticipants' object does not support indexing
I have also same issue, before this code run without error, but it shows timeout error.
Traceback (most recent call last):
File "F:\Test\script.py", line 53, in <module>
all_participants = client.get_participants(target_group, aggressive=True)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\sync.py", line 39, in syncified
return loop.run_until_complete(coro)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\client\chats.py", line 507, in get_participants
return await self.iter_participants(*args, **kwargs).collect()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\requestiter.py", line 113, in collect
async for message in self:
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\requestiter.py", line 74, in __anext__
if await self._load_next_chunk():
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\client\chats.py", line 222, in _load_next_chunk
results = await self.client(self.requests)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\client\users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\telethon\client\users.py", line 80, in _call
raise MultiError(exceptions, results, requests)
telethon.errors.common.MultiError: ([None, FloodWaitError('A wait of 28 seconds is required (caused by GetParticipantsRequest)'),
Can someone confirm if the error is present in the development version, not v1.24.0 from PyPi? That is, does this error occur if master is installed?
this error does not occur if using the development version.
but if add argument aggressive=True the following error appears:
TypeError: TelegramClient.get_participants() got an unexpected keyword argument 'aggressive'
I used v1.23, but the error mentioned above still occurred
this error is only occurring , if i try to get contacts from groups than have more than 10000 members(not using the aggressive keyword ,as new version doesn't have the option to use aggressive any more)
the error of ChannelParticipants object does not support indexing is occurring when using below statement for groups having more than 10k members, for groups less than 10k it is not throwing any error.
all_participants = self.client.get_participants(target_Group)
i tried getting contacts from groups which have more than 10k rows using below code and it is successful but it returns only first10k contacts.
all_participants = []
while_condition = True
my_filter = ChannelParticipantsSearch('')
offset = 0
while while_condition:
participants = self.client(GetParticipantsRequest(channel=target_Group, offset= offset, filter = my_filter, limit=200, hash=0))
all_participants.extend(participants.users)
offset += len(participants.users)
print(len(participants.users))
if len(participants.users) < 1 :
while_condition = False
hope this info may help someone to solve the issue and any other update which can help retrieve more than 10k rows from groups
@vine2444 Sir please send me full code because I face problem this code you sent so please send me complete code I humble request you please
this error does not occur if using the development version.
Thank you, then this means this issue has already been solved in the development version and the fix will be available in the next version of the library.
The next version will be v2, which contains many more breaking changes, and there is no planned release date (I do not know how long it will take me to finish it). The aggressive
parameter has also been removed. It was a hack. Because there are many more breaking changes, updating to the development version won't magically fix third-party code. This code needs to be updated to work under v2. However, if you are a developer and want to update, use the following:
python3 -m pip install --upgrade https://github.com/LonamiWebs/Telethon/archive/master.zip
Because the issue is solved in the development version, and the discussion here is not productive, there is no need to track this issue any more, so I am going to close this and lock the issue.
The issue is fixed in the development version. Please stop opening issues about it and re-read my comment to understand what this means.
telethon-sync == 1.1.1