amiryousefi / telegram-analysis

Telegram Analysis Tools
330 stars 192 forks source link

AttributeError: 'coroutine' object has no attribute 'messages' #3

Closed Erni76 closed 4 years ago

Erni76 commented 4 years ago

Hello, I had tried your code ChannelMessages.py to retrieve messages from a group I'm a member of. Unfortunately, no matter how I set the offset-id I keep getting this error:

Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1664, in main() File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1658, in main globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1068, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Users/Arnold/Programming/Python/Telegram/ChannelMessages.py", line 79, in if not history.messages: AttributeError: 'coroutine' object has no attribute 'messages'

Could you please help me to resolve this issue?

Erni76 commented 4 years ago

Apparently I was imputing the wrong id ... with -100 on the front. All works as expected.

Keramatfar commented 4 years ago

Apparently I was imputing the wrong id ... with -100 on the front. All works as expected.

I have the same problem. Removing 100 from the start of the ID does not help.

jerik commented 4 years ago

Apparently I was imputing the wrong id ... with -100 on the front. All works as expected.

I have the same problem. Removing 100 from the start of the ID does not help.

For me it was not the offset_id instead await was missing in two lines. Below the correct lines where I added await:

my_channel = await client.get_entity(entity)
...
history = await client(GetHistoryRequest(
ditirodt commented 2 years ago

Apparently I was imputing the wrong id ... with -100 on the front. All works as expected.

I have the same problem. Removing 100 from the start of the ID does not help.

For me it was not the offset_id instead await was missing in two lines. Below the correct lines where I added await:

my_channel = await client.get_entity(entity)
...
history = await client(GetHistoryRequest(

I get

Cannot cast coroutine to any kind of Peer. after adding await, what could be the prob?