redact-matrix/README.md
2024-07-12 03:42:04 -05:00

79 lines
2.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Redact Matrix
Small script that redacts (deletes) every message written by the user in specified 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*
![access token](./element_access_token.png)
On [Cinny](https://app.cinny.in), for example, go to Firefox's Inspect tool, then to the Storage tab, and copy your `cinny_access_token`.
![access token](./cinny_access_token.png)
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*
![room id](./element_room_id.png)
On Cinny we can see this value in the source of sent messages.
#### Running the script
```
python redact_matrix.py -s matrix.thisisjoes.site -t syt_uaY3lMW_nAyiumHhGDhXJBFLKdoY_3RRBuz \!xTDdCBHByVyZtZEmNI:hackliberty.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.