Browse Source

regex work

master
Hendrik Langer 2 years ago
parent
commit
0d0507d649
  1. 6
      matrix_pygmalion_bot/core.py

6
matrix_pygmalion_bot/core.py

@ -106,8 +106,8 @@ class Callbacks(object):
print(event) print(event)
await self.bot.send_message(self.client, room.room_id, "Hello World!") await self.bot.send_message(self.client, room.room_id, "Hello World!")
return return
elif re.search("(?s)^!image(?P<num>[0-9])?(\s(?P<cmd>.*))?$", event.body): elif re.search("(?s)^!image(?P<num>[0-9])?(\s(?P<cmd>.*))?$", event.body, flags=re.DOTALL):
m = re.search("(?s)^!image(?P<num>[0-9])?(\s(?P<cmd>.*))?$", event.body) m = re.search("(?s)^!image(?P<num>[0-9])?(\s(?P<cmd>.*))?$", event.body, flags=re.DOTALL)
if m['num']: if m['num']:
num = int(m['num']) num = int(m['num'])
else: else:
@ -233,7 +233,7 @@ class Callbacks(object):
return return
# Other commands # Other commands
if re.search("^(?=.*\bsend\b)(?=.*\bpicture\b).*$", event.body): if re.search("^(?=.*\bsend\b)(?=.*\bpicture\b).*$", event.body, flags=re.IGNORECASE):
# send, mail, drop, snap picture, photo, image, portrait # send, mail, drop, snap picture, photo, image, portrait
pass pass

Loading…
Cancel
Save