Skip to content

Instantly share code, notes, and snippets.

@travnewmatic
Last active November 6, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travnewmatic/6818340a5b3aa4566608957e240dc075 to your computer and use it in GitHub Desktop.
Save travnewmatic/6818340a5b3aa4566608957e240dc075 to your computer and use it in GitHub Desktop.
#!/bin/bash
# substitute with your variables
# grabs all arguments and dumps them into the body of the message
MSGTYPE=m.text
BODY=$@
HOMESERVER=<homeserver goes here>
ROOM=<room id goes here>
ACCESSTOKEN=<access token goes here>
JSON=$( jq -n \
--arg msgtype "$MSGTYPE" \
--arg body "$BODY"\
'{msgtype: $msgtype, body: $body}' )
/usr/bin/curl -XPOST -d "$JSON" "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