Skip to content

Commit

Permalink
Merge pull request #30 from WhaleFell/master
Browse files Browse the repository at this point in the history
fix listen does not check if message.from_user.id exists or not. Caus…
  • Loading branch information
usernein authored Aug 28, 2023
2 parents a7baef0 + 9994ea8 commit f0474b0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pyromod/listen/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,16 @@ def __init__(self, callback: Callable, filters=None):

@patchable
async def check(self, client, message):
# patch
if not message.from_user:
message_from_user_id = None
else:
message_from_user_id = message.from_user.id
listener = client.match_listener(
(message.chat.id, message.from_user.id, message.id),
(message.chat.id, message_from_user_id, message.id),
ListenerTypes.MESSAGE,
)[0]
#################################

listener_does_match = handler_does_match = False

Expand All @@ -217,8 +223,12 @@ async def check(self, client, message):
@patchable
async def resolve_future(self, client, message, *args):
listener_type = ListenerTypes.MESSAGE
if not message.from_user:
message_from_user_id = None
else:
message_from_user_id = message.from_user.id
listener, identifier = client.match_listener(
(message.chat.id, message.from_user.id, message.id),
(message.chat.id, message_from_user_id, message.id),
listener_type,
)
listener_does_match = False
Expand Down

0 comments on commit f0474b0

Please sign in to comment.