maxwell/custom/packages/maxwell-notify.nix
2020-10-20 01:11:28 +02:00

21 lines
416 B
Nix

{ writeScriptBin, fish, curl
, homeserver
, roomId
, authToken
}:
writeScriptBin "notify" ''
#!${fish}/bin/fish
set token (cat ${authToken})
if test (id -u) != 0
echo 'you must be root to send a notice'
exit 1
end
set url '${homeserver}/rooms/${roomId}/send/m.room.message?access_token='$token
set msg '{"msgtype":"m.text", "body": "'$argv[1]'"}'
${curl}/bin/curl -s -XPOST -d $msg $url
''