pyrogram
pyrogram copied to clipboard
get_nearby_chats AttributeError: 'PeerSelfLocated' object has no attribute 'peer'
Checklist
- [X] I am sure the error is coming from Pyrogram's code and not elsewhere.
- [X] I have searched in the issue tracker for similar bug reports, including closed ones.
- [X] I ran
pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zipand reproduced the issue using the latest development version.
Description
ERROR on get_nearby_chats
...
chats = app.get_nearby_chats(51.500729, -0.124583)
...
Traceback
The full traceback (if applicable).
'PeerSelfLocated' object has no attribute 'peer'
Traceback (most recent call last):
File "/home/axfj/just_a_test/lib/python3.7/site-packages/pyrogram/dispatcher.py", line 223, in handler_worker
*args
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "bot.py", line 25, in my_handler
spam()
File "bot.py", line 14, in spam
chats = app.get_nearby_chats(51.500729, -0.124583)
File "/home/axfj/just_a_test/lib/python3.7/site-packages/pyrogram/sync.py", line 50, in async_to_sync_wrap
return asyncio.run_coroutine_threadsafe(coroutine, loop).result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/axfj/just_a_test/lib/python3.7/site-packages/pyrogram/methods/chats/get_nearby_chats.py", line 68, in get_nearby_chats
if isinstance(peer.peer, raw.types.PeerChannel):
AttributeError: 'PeerSelfLocated' object has no attribute 'peer'
FIX:
pyrogram/methods/chats/get_nearby_chats.py line 68
for peer in peers:
if isinstance(peer, raw.types.PeerSelfLocated): continue ### FIX
if isinstance(peer.peer, raw.types.PeerChannel):
chat_id = utils.get_channel_id(peer.peer.channel_id)
for chat in chats:
if chat.id == chat_id:
chat.distance = peer.distance
break
return chats