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
3a73c2a0
Verified
Commit
3a73c2a0
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
[LED cheese] Join room; align cases with new regex API
parent
53849764
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
examples/led_cheese.py
+5
-4
5 additions, 4 deletions
examples/led_cheese.py
with
5 additions
and
4 deletions
examples/led_cheese.py
+
5
−
4
View file @
3a73c2a0
...
@@ -65,16 +65,17 @@ network.connect()
...
@@ -65,16 +65,17 @@ network.connect()
matrix
=
Matrix
(
HOMESERVER
,
MATRIX_ID
,
ACCESS_TOKEN
)
matrix
=
Matrix
(
HOMESERVER
,
MATRIX_ID
,
ACCESS_TOKEN
)
# On which texts to react and which LEDs to turn on
# On which texts to react and which LEDs to turn on
colour_re
=
re
.
compile
(
"
leuchte (.*)
"
,
re
.
I
)
cases
=
{
"
Kalle, leuchte (.*)
"
:
set_colour
,
"
Kalle, hoer auf (.*)
"
:
allow_user
}
permission_re
=
re
.
compile
(
"
hoer auf (.*)
"
,
re
.
I
)
cases
=
{
colour_re
:
set_colour
,
permission_re
:
allow_user
)
if
network
.
is_connected
():
if
network
.
is_connected
():
# Join the room
matrix
.
join_room
(
ROOM_ID
)
# Send message that I am there
# Send message that I am there
matrix
.
send_room_message
(
ROOM_ID
,
"
Hey! Alles cheesy, ich bin bereit zum Leuchten!
"
)
matrix
.
send_room_message
(
ROOM_ID
,
"
Hey! Alles cheesy, ich bin bereit zum Leuchten!
"
)
matrix
.
send_room_message
(
ROOM_ID
,
"
Lass mir etwas Zeit, auf deine Nachrichten zu reagieren!
"
)
matrix
.
send_room_message
(
ROOM_ID
,
"
Lass mir etwas Zeit, auf deine Nachrichten zu reagieren!
"
)
# Wait for a message
# Wait for a message
while
True
:
while
True
:
matrix
.
react_room_messages
(
ROOM_ID
,
cases
)
matrix
.
react_room_messages
(
ROOM_ID
,
cases
,
regex
=
True
)
time
.
sleep
(
10
)
time
.
sleep
(
10
)
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