.gitignore | ||
cinny_access_token.png | ||
element_access_token.png | ||
element_room_id.jpg | ||
LICENSE | ||
README.md | ||
redact_matrix.py |
Redact Matrix
Small script that redacts (deletes) every message written by the user in specified Matrix room(s).
Usage
Installation
Download the script:
git clone https://git.thisisjoes.site/cynic/redact-matrix.git
cd redact-matrix
chmod +x redact_matrix.py # optional
Getting our access token
On Element it is found at: ⚙️ Quick settings > All Settings > Help & About > Advanced > Access Token
On Cinny, for example, go to Firefox's Inspect tool, then to the Storage tab, and copy your cinny_access_token
.
Other clients may have a similar key with this value.
The token is different for each session and remains valid as long as you don't log out.
Getting room ID's
Room ID's look like this:
!cdPNSVToruMtXqGznY:domain.tld
On Element the room ID of any room can be found at ℹ️ Room info > Settings > Advanced > Internal room ID
On Cinny we can see this value in the source of sent messages.
Running the script
./redact_matrix.py -s matrix.org -t syt_uaY3lMW_nAyiumHhGDhXJBFLKdoY_3RRBuz \!xTDdCBHByVyZtZEmNI:matrix.org '!cdPNSVToruMtXqGznY:domain.tld'
As we can see above, it is possible to apply the command to more than one room.
Additionally, by adding the -n
flag after redact_matrix.py
the Nuke mode is turned on, which means that you will not be deleting only your own messages but also those of other users in the room, as long as you have permissions (e.g. admin). In other words, it attempts to "nuke" the room, so, please, be very careful with this flag.
When in doubt, see the help by passing --help
or -h
:
# python redact_matrix.py --help
usage: redact_matrix.py [-h] [-n] -s HOMESERVER -t ACCESS_TOKEN [room_ids ...]
positional arguments:
room_ids room ID's
options:
-h, --help show this help message and exit
-n, --nuke try and delete all messages in the room, not only mine
required:
-s HOMESERVER, --homeserver HOMESERVER
homeserver's domain name
-t ACCESS_TOKEN, --access-token ACCESS_TOKEN
Matrix access token
Note:
Once it has deleted all of your messages it may remove the room itself, if you had permissions to do so.