Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Μ
µtrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Projekt Hack-n-Fun
Libs
µtrix
Commits
a82bcad8
Verified
Commit
a82bcad8
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Pass group matches for regex matches in react_room_messages
parent
50a8dfa1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mytrix.py
+7
-3
7 additions, 3 deletions
mytrix.py
with
7 additions
and
3 deletions
mytrix.py
+
7
−
3
View file @
a82bcad8
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment