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

Commit f5ec850

Browse files
author
krazykirby99999
committed
Fix messagemath.mention.
"body" is now a tuple instead of a list
1 parent d6a3a34 commit f5ec850

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

simplematrixbotlib/match.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ def __init__(self, room, event, bot, prefix="") -> None:
8282
"""
8383
super().__init__(room, event, bot)
8484
self._prefix = prefix
85-
bot_user = self.room.users[self.room.own_user_id]
86-
self._display_name = bot_user.display_name
87-
self._disambiguated_name = bot_user.disambiguated_name
88-
self._pill = f'<a href="https://matrix.to/#/{self.room.own_user_id}">'
89-
self._body_without_prefix = None
9085

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

159-
for i in [self._display_name, self._disambiguated_name, self.room.own_user_id, self._pill]:
160-
body = self.event.formatted_body or self.event.body
161-
if body.startswith(i):
162-
return True
163-
154+
for body in (self.event.formatted_body, self.event.body):
155+
for id in [self._display_name, self._disambiguated_name, self.room.own_user_id, self._pill]:
156+
if body.startswith(id):
157+
return True
158+
164159
return False
165160

166161
def args(self):

0 commit comments

Comments
 (0)