Matrix Admin Tools

See Matrix on the command line for instructions on how to get your API key.

Removing rooms from room directory

work in progress

#!/bin/bash
# Usage example:
# ./matrix_admin_remove_room.sh !longroomID:glasgow.social
msgtype=m.text
homeserver=glasgow.social
access_token=put_your_user_access_token_here
room_id=$1
 
curl -XPUT -d "$( jq -Rsc --arg msgtype "$msgtype" '{$msgtype, body:.}')" "https://$homeserver/_matrix/client/r0/rooms/$room/send/m.room.message?access_token=$access_token"
 
curl -X PUT "https://$homeserver/_matrix/client/r0/directory/list/room/{roomId}" \
    -H "Authorization: Bearer $access_token" \
    -H "Content-Type: application/json" \
    -d '{
        "visibility": "none"
    }'