mirror of
https://gitlab.com/ceda_ei/the-long-night
synced 2025-11-05 08:50:05 +01:00
Add matrix backend and relevant config generation
This commit is contained in:
12
backends/matrix.py
Normal file
12
backends/matrix.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from matrix_client.client import MatrixClient
|
||||
from matrix_client.api import MatrixHttpApi
|
||||
|
||||
|
||||
def send(config, message):
|
||||
if 'token' in config:
|
||||
token = config["token"]
|
||||
else:
|
||||
token = MatrixClient(config["server"]).login(config["username"],
|
||||
config["password"])
|
||||
bot = MatrixHttpApi(config["server"], token=token)
|
||||
bot.send_message(config["room_id"], message)
|
||||
Reference in New Issue
Block a user