#!/usr/bin/zsh # access token of @abuse:… AT='MDMA...' # admin room to send notifications to ROOM='!x1y2z3:example.com' # ip of the new user, with gdpr redaction to /24 IP=`echo $1|cut -d. -f1-3`.0 #read stdin SI=`/bin/cat` #try to retrieve new user id U=`echo $SI|jq -r .user_id` [ -z "$U" ] && exit 0 [ "null" = "$U" ] && exit 0 # send notification curl -X PUT "https://asra.gr/_matrix/client/r0/rooms/${ROOM}/send/m.room.message/"`uuid -m -F SIV`"?access_token=${AT}" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"body\": \"@room New user registered: ${U} from ${IP}\", \"msgtype\": \"m.text\"}" >> /tmp/reguser.txt 2>> /tmp/reguser.txt