From 53cd32b2ab200d3832aae0eb34b2d3cd8de68ded Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Sat, 15 Feb 2020 11:26:19 +0100 Subject: [PATCH] add comment describing regex. remove unnecessary length check --- bot.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 6ffdaa9..8a240f6 100755 --- a/bot.py +++ b/bot.py @@ -111,9 +111,7 @@ class Bot: async def message_cb(self, room, event): # Figure out the command body = event.body - if len(body) == 0: - return - if self.starts_with_command(body) is None: + if not self.starts_with_command(body): return command = body.split().pop(0) @@ -142,7 +140,8 @@ class Bot: @staticmethod 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): room: MatrixRoom