add comment describing regex. remove unnecessary length check

This commit is contained in:
Frank Becker 2020-02-15 11:26:19 +01:00
parent 6d0d960eef
commit 53cd32b2ab
1 changed files with 3 additions and 4 deletions

7
bot.py
View File

@ -111,9 +111,7 @@ class Bot:
async def message_cb(self, room, event): async def message_cb(self, room, event):
# Figure out the command # Figure out the command
body = event.body body = event.body
if len(body) == 0: if not self.starts_with_command(body):
return
if self.starts_with_command(body) is None:
return return
command = body.split().pop(0) command = body.split().pop(0)
@ -142,7 +140,8 @@ class Bot:
@staticmethod @staticmethod
def starts_with_command(body): def starts_with_command(body):
return re.match(r"^!\w.*", body) """Checks if body starts with ! and has one or more letters after it"""
return re.match(r"^!\w.*", body) is not None
async def invite_cb(self, room, event): async def invite_cb(self, room, event):
room: MatrixRoom room: MatrixRoom