Skip to content

Instantly share code, notes, and snippets.

@jasalt
Forked from travnewmatic/sendmatrix
Created July 16, 2020 13:10
Show Gist options
  • Save jasalt/9562b4b6ff4d3092fe37839591f3ea11 to your computer and use it in GitHub Desktop.
Save jasalt/9562b4b6ff4d3092fe37839591f3ea11 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Adjust homserver, room, and accesstoken to your particular setup
# Script is expecting data to be piped in on STDIN
# Example:
# echo "some text" | sendmatrix
msgtype=m.text
homeserver=<homeserver>
room=<room id>
accesstoken=<access token>
curl -XPOST -d "$( jq -Rsc --arg msgtype "$msgtype" '{$msgtype, body:.}')" "https://$homeserver/_matrix/client/r0/rooms/$room/send/m.room.message?access_token=$accesstoken"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment