-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotify-matrix
32 lines (24 loc) · 996 Bytes
/
notify-matrix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
# Send messages to a matrix room with this python matrix client
# For example to be used in combination with rsync backup
# Author: Zjemm
# Email: mail [at] sjemm {dot} net
# Please use/share/comment/reference
# Date: 23-08-2017
# Version 0.4
# Usage: run this script with arguments
# Example: ./notify-matrix "This is my message for you"
# Requirements: python3 matrix module needed
# Example: pip3 install matrix_client
import sys
from matrix_client.client import MatrixClient
# Fill in your own matrix server url here
client = MatrixClient("https://yourserver.domain")
# Use an Existing user
# Fill in your own matrix username and password here
token = client.login_with_password(username="youruser", password="yourpassword")
# Join an existing matrix room (fill in yours here)
room = client.join_room("#yourroom:yourserver.domain")
# Send the argument given in bash to the room
# Example ./notify-matrix "This is my message for you"
room.send_text(sys.argv[1])