add comment describing regex. remove unnecessary length check
This commit is contained in:
parent
6d0d960eef
commit
53cd32b2ab
7
bot.py
7
bot.py
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue