Skip to content
Snippets Groups Projects
Commit 6361cda4 authored by overflow's avatar overflow
Browse files

script now uses feature handler. added examples as placeholders

parent 2aefb2f9
No related branches found
No related tags found
1 merge request!3Project structure
#!/usr/bin/env python3
from FeatureExamples import FeatureExamples
from FeatureHandler import FeatureHandler
from matrix_client.client import MatrixClient
import os
# Called when a message is recieved.
def on_message(room, event):
if event['type'] == "m.room.message":
if event['content']['msgtype'] == "m.text":
print("{0}: {1}".format(event['sender'], event['content']['body']))
def main():
# connect to server and join room
client = MatrixClient("https://matrix.org")
token = client.login(username="foss-ag_klo", password=os.environ['KLO_PW'])
room = client.join_room("#klotest:matrix.org")
room.add_listener(on_message)
client.start_listener_thread()
# create FeatureHandler
fh = FeatureHandler(room, client)
# add features to FeatureHandler that are called when the specified command is posted in the Matrix room
fh.add_feature("!echo", FeatureExamples.echo)
fh.add_feature("!CUPS", FeatureExamples.caps)
# run script until it's stopped manually
while True:
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment