Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Fix messagemath.mention.
Browse files Browse the repository at this point in the history
"body" is now a tuple instead of a list
  • Loading branch information
krazykirby99999 committed Nov 25, 2021
1 parent d6a3a34 commit f5ec850
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions simplematrixbotlib/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ def __init__(self, room, event, bot, prefix="") -> None:
"""
super().__init__(room, event, bot)
self._prefix = prefix
bot_user = self.room.users[self.room.own_user_id]
self._display_name = bot_user.display_name
self._disambiguated_name = bot_user.disambiguated_name
self._pill = f'<a href="https://matrix.to/#/{self.room.own_user_id}">'
self._body_without_prefix = None

def command(self, command=None):
"""
Expand Down Expand Up @@ -156,11 +151,11 @@ def mention(self):
Returns True if the message begins with the bot's username, MXID, or pill targeting the MXID, and False otherwise.
"""

for i in [self._display_name, self._disambiguated_name, self.room.own_user_id, self._pill]:
body = self.event.formatted_body or self.event.body
if body.startswith(i):
return True

for body in (self.event.formatted_body, self.event.body):
for id in [self._display_name, self._disambiguated_name, self.room.own_user_id, self._pill]:
if body.startswith(id):
return True
return False

def args(self):
Expand Down

0 comments on commit f5ec850

Please sign in to comment.