Skip to content

Commit

Permalink
updated README and the mk-cleaner program
Browse files Browse the repository at this point in the history
  • Loading branch information
spirillen committed Oct 22, 2024
1 parent fcdb160 commit 5ad924f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Mk Cleaner local files
mk-cleaner.sh

# Generated by Cargo
# will have compiled files and executables
debug/
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ edition = "2021"
[dependencies]
futures = "0.3.31"
tokio = { version = "1.40.0", features = ["full"] }
misskey = { version = "0.2.0", features = ["http-client", "inspect-contents"] }
misskey = { version = "0.2.0", features = ["http-client", "inspect-contents"] }
env_logger = "0.11.5"
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<!-- TOC -->
* [MK Cleaner](#mk-cleaner)
* [Running MK Cleaner](#running-mk-cleaner)
* [The error](#the-error)
* [Other docs](#other-docs)
* [History](#history)
Expand All @@ -34,6 +35,31 @@ This may be the reason to the error I receive when running the code against the
server version `2024.10.0` while the last mention version on the project is
`v12.63.0`

## Running MK Cleaner
First, you should clone this repository to make it easy to update.

```shell
https://github.com/mypdns/MK-Cleaner.git mk-ckleaner
```

> [!NOTE]
> This is subject to being altered once the program is fully
> functional, and released as stable.
> We, should change the way we read in the environment variables from a config
> file, and the rust program itself asks for the userID.
Next you need to configure the `mk-cleaner.sh` by copying the
`mk-cleaner.sh.example` to `mk-cleaner.sh` and set the values of

1. MISSKEY_API_URL, This is the full url to your API path, such as `https://example.org/api/`
2. MISSKEY_TOKEN, This is your private API_key from your installation URI, such as `https://example.org/settings/api`

Now you should be able to run `mk-cleaner.sh` like

```shell
mk-cleaner.sh userID
```

## The error
The error seems to be related to how the json response is handled, and I don't
know if there is a workaround for this.
Expand Down
12 changes: 12 additions & 0 deletions mk-cleaner.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

read -erp "UserID to suspend: " userID

export MISSKEY_API_URL=""
export MISSKEY_TOKEN=""

# In case the program do not work for your, please do uncomment the next
# two lines and add the output to a new issue
# export RUST_LOG=debug
# export RUST_BACKTRACE=1
./target/debug/mk-cleaner "$userID"
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ use misskey::ClientExt;

#[tokio::main(flavor = "current_thread")]
async fn main() {
// env_logger::init();

let endpoint = std::env::var("MISSKEY_API_URL").expect("environment variable MISSKEY_API_URL");
let token = std::env::var("MISSKEY_TOKEN").expect("environment variable MISSKEY_TOKEN");
let client = misskey::HttpClient::builder(endpoint.as_str())
.token(token)
.build()
.expect("Building misskey::HttpClient should succeed");


let mut suspend_count_success = 0;
let mut suspend_count_failures = 0;
let mut delete_note_success = 0;
let mut delete_note_failures = 0;

for user_id in std::env::args().skip(1) {
eprintln!("Doing {user_id}");

let user: misskey::model::id::Id<_> = user_id.parse().expect("valid user_id");
match client.suspend(user).await {
Ok(()) => suspend_count_success += 1,
Expand Down

0 comments on commit 5ad924f

Please sign in to comment.