document argument parsing

This commit is contained in:
cynic 2024-07-12 03:16:47 -05:00
parent 6df721951f
commit 85cfd21d01

View File

@ -1,21 +1,22 @@
# Redact Matrix
Small script that redacts (deletes) every message you wrote in a given room.
Small script that redacts (deletes) every message written by the user in specified room(s).
---
### Usage
#### Download
#### Installation
Download the script to your computer.
Download the script:
```
git clone https://git.thisisjoes.site/cynic/redact-matrix.git
cd redact-matrix
chmod +x redact_matrix.py # optional
```
#### Get your access token
#### Getting your access token
On [Cinny](https://app.cinny.in), for example, go to Firefox's Inspect tool, to the Storage tab, and copy your `cinny_access_token`.
@ -23,20 +24,18 @@ On [Cinny](https://app.cinny.in), for example, go to Firefox's Inspect tool, to
Other clients may have a similar key with this value.
For example on Element it is found at: ⚙️ *Quick settings > All Settings > Help & About > Advanced > Access Token*
On Element it is found at: ⚙️ *Quick settings > All Settings > Help & About > Advanced > Access Token*
![image](./element.png)
The token is different for each session and remains valid as long as you don't log out.
Open the `redact_all_messages.py` script with your favorite text editor and set the value for `homeserver` with the domain of the matrix instance you're logged in, and the `access_token` with the value you just extracted from the browser. Save the file.
#### Get the Matrix room id
On Cinny you can do this simply by clicking on the room's name.
On Cinny you can see this value in the source of sent messages.
The id will be right below the title of the room, and it looks like this:
The room id looks like this:
`!cdPNSVToruMtXqGznY:domain.tld`
On Element it can be found at *Room info > Settings > Advanced > Internal room ID*
@ -44,14 +43,36 @@ On Element it can be found at *Room info > Settings > Advanced > Internal
![image](./element_room_id.png)
#### Run the script
#### Running the script
```
python redact_all_messages.py '!cdPNSVToruMtXqGznY:domain.tld'
python redact_matrix.py -s matrix.thisisjoes.site -t syt_uaY3lMW_nAyiumHhGDhXJBFLKdoY_3RRBuz \!xTDdCBHByVyZtZEmNI:hackliberty.org '!cdPNSVToruMtXqGznY:domain.tld'
```
As we can see here, 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's deleted all of your messages it may remove the room itself, if you created it.
Once it has deleted all of your messages it may remove the room itself, if you had permissions to do so.