Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when a handler starts processing in pyrogram, It raises the following error. why? #57

Open
Iamirup opened this issue Jun 19, 2024 · 2 comments

Comments

@Iamirup
Copy link

Iamirup commented Jun 19, 2024

'Client' object has no attribute 'listeners'
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pyrogram/dispatcher.py", line 226, in handler_worker
if await handler.check(self.client, parsed_update):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyromod/listen/message_handler.py", line 58, in check
await self.check_if_has_matching_listener(client, message)
File "/usr/local/lib/python3.12/site-packages/pyromod/listen/message_handler.py", line 37, in check_if_has_matching_listener
listener = client.get_listener_matching_with_data(data, ListenerTypes.MESSAGE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
coroutine = function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyromod/listen/client.py", line 123, in get_listener_matching_with_data
for listener in self.listeners[listener_type]:
^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'listeners'. Did you mean: 'listen'?

@Zenova-Prime
Copy link

I am also facing this same error when I ran code locally(it was one file code), it ran perfectly with no error. But when i splitted my file into different files and tried hosting on Koyeb, it threw same error..

AttributeError: 'Client' object has no attribute 'listeners'
[ERROR/2024-08-16 06:13:39,511] pyrogram.dispatcher: 'Client' object has no attribute 'listeners'
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.11/site-packages/pyrogram/dispatcher.py", line 226, in handler_worker
    if await handler.check(self.client, parsed_update):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/pyromod/listen/message_handler.py", line 58, in check
    await self.check_if_has_matching_listener(client, message)
  File "/app/.heroku/python/lib/python3.11/site-packages/pyromod/listen/message_handler.py", line 37, in check_if_has_matching_listener
    listener = client.get_listener_matching_with_data(data, ListenerTypes.MESSAGE)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
    coroutine = function(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/pyromod/listen/client.py", line 123, in get_listener_matching_with_data
    for listener in self.listeners[listener_type]:
                    ^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'listeners'

@Zenova-Prime
Copy link

Zenova-Prime commented Aug 16, 2024

I am also facing this same error when I ran code locally(it was one file code), it ran perfectly with no error. But when i splitted my file into different files and tried hosting on Koyeb, it threw same error..

AttributeError: 'Client' object has no attribute 'listeners'
[ERROR/2024-08-16 06:13:39,511] pyrogram.dispatcher: 'Client' object has no attribute 'listeners'
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.11/site-packages/pyrogram/dispatcher.py", line 226, in handler_worker
    if await handler.check(self.client, parsed_update):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/pyromod/listen/message_handler.py", line 58, in check
    await self.check_if_has_matching_listener(client, message)
  File "/app/.heroku/python/lib/python3.11/site-packages/pyromod/listen/message_handler.py", line 37, in check_if_has_matching_listener
    listener = client.get_listener_matching_with_data(data, ListenerTypes.MESSAGE)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
    coroutine = function(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/pyromod/listen/client.py", line 123, in get_listener_matching_with_data
    for listener in self.listeners[listener_type]:
                    ^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'listeners'

Their was a silly mistake😅 While splitting of code, i used everywhere pyromod but didn't use Client from pyromod and initiated bot with pyrogram.. When i changed the Client import from pyrogram to pyromod just, its working fine now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants