Skip to content
Snippets Groups Projects
Verified Commit a82bcad8 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Pass group matches for regex matches in react_room_messages

parent 50a8dfa1
No related branches found
No related tags found
No related merge requests found
...@@ -136,7 +136,10 @@ class Matrix: ...@@ -136,7 +136,10 @@ class Matrix:
The cases argument takes a dictionary mapping strings or compiled regexs to callables. The cases argument takes a dictionary mapping strings or compiled regexs to callables.
All received messages are compared to the keys, and on match, the respective callable All received messages are compared to the keys, and on match, the respective callable
is called. The callback is passed the matching message as only argument. is called.
The callback is passed the matching message for string matches, or the list of matched
groups for regex matches.
The get_room_messages method is called with default values, resulting in this method always The get_room_messages method is called with default values, resulting in this method always
reacting to new messages since its last call. reacting to new messages since its last call.
...@@ -155,9 +158,10 @@ class Matrix: ...@@ -155,9 +158,10 @@ class Matrix:
matches.append(message) matches.append(message)
func(message) func(message)
elif isinstance(key_, re.Pattern): elif isinstance(key_, re.Pattern):
if key_.match(message): finds = key_.findall(messaage)
if finds:
matches.append(message) matches.append(message)
func(message) func(finds)
return matches return matches
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment