Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
Played with log
  • Loading branch information
spirillen committed Oct 23, 2024
1 parent ec13368 commit 61cb86e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ edition = "2021"
futures = "0.3.31"
tokio = { version = "1.40.0", features = ["full"] }
misskey = { version = "0.2.0", features = ["http-client", "inspect-contents"] }
env_logger = "0.11.5"
env_logger = "0.11.5"
log = "0.4.22"
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,27 @@ git clone https://github.com/mypdns/MK-Cleaner.git mk-ckleaner && \
```

```shell
# Open config file in default editor, else set default editor (*nix ONLY)
if [ -n "$(which xdg-open)" ]; then
# This script will open your config file with your default editor, else help
# you set default editor (*nix ONLY)

if [ -n "$(which xdg-open)" ]; then
xdg-open "mk-cleaner.sh"
elif [ -n "${VISUAL-${EDITOR-nano}}" ]; then
elif [ -n "${VISUAL-${EDITOR-nano}}" ]; then
${VISUAL-${EDITOR-nano}} "mk-cleaner.sh"
elif [ -n "$(which editor)" ]; then
editor "mk-cleaner.sh"
else
echo "Your System suck!!!"
echo "You should set a default editor for your system"
echo "I'll help you this time!!!"
select-editor || exit 1

if [ -n "${VISUAL-${EDITOR-nano}}" ]; then
${VISUAL-${EDITOR-nano}} "mk-cleaner.sh"

elif [ -n "$(which editor)" ]; then
editor "mk-cleaner.sh"
else
echo "Your System suck!!!"
echo "You should set a default editor for your system"
echo "I'll help you this time!!!"
select-editor || exit 1
editor "mk-cleaner.sh"
fi
fi
```

Expand All @@ -66,12 +74,12 @@ fi
> We, should change the way we read in the environment variables from a config
> file, and the rust program itself asks for the userID.
> [!IMPORTANT]
> [!IMPORTANT]
> 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`
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

Expand Down
7 changes: 7 additions & 0 deletions mk-cleaner.sh.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ export MISSKEY_TOKEN=""
# export RUST_LOG=debug
# export RUST_BACKTRACE=1
./target/debug/mk-cleaner "$userID"

# Clean out Secret API token from the bash_history as it can be leaked
# and compromise the security of your server.
echo "Delete misskey token from bash_history"
sed -i "/${MISSKEY_TOKEN}/d" "$HOME/.bash_history"
echo "Delete userID from bash_history"
sed -i "/$userID/d" "$HOME/.bash_history"
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
use futures::stream::TryStreamExt;
use log::{error, info};
use misskey::ClientExt;

#[tokio::main(flavor = "current_thread")]
async fn main() {
env_logger::init();
env_logger::init();
info!("Application started");

let endpoint = std::env::var("MISSKEY_API_URL").expect("environment variable MISSKEY_API_URL");
if endpoint.is_empty() {
error!("MISSKEY_API_URL is not set")
}
let token = std::env::var("MISSKEY_TOKEN").expect("environment variable MISSKEY_TOKEN");
if token.is_empty() {
error!("MISSKEY_TOKEN is not set")
}

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;
Expand Down

0 comments on commit 61cb86e

Please sign in to comment.