From f5ec850e7fc97c5809aa8c2d1a4f46ed3d51431a Mon Sep 17 00:00:00 2001 From: krazykirby99999 Date: Wed, 24 Nov 2021 18:45:13 -0600 Subject: [PATCH] Fix messagemath.mention. "body" is now a tuple instead of a list --- simplematrixbotlib/match.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/simplematrixbotlib/match.py b/simplematrixbotlib/match.py index 4807cce..1d709b7 100644 --- a/simplematrixbotlib/match.py +++ b/simplematrixbotlib/match.py @@ -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'' - self._body_without_prefix = None def command(self, command=None): """ @@ -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):