diff --git a/.drone.yml b/.drone.yml index 0c6540d..d153a8a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,6 @@ type: docker name: default steps: - - name: lint image: node commands: diff --git a/README.md b/README.md index 7a2a4d2..a2724ce 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Should be compatible with Mastodon, Misskey and Pleroma! - `yarn token` will generate a configuration file located at `config.json` 7. Put images in the `images` folder. -- By default the bot will look for SFW images at `images/sfw` and NSFW images at `images/nsfw`. This can be configured. +- By default the bot will look for SFW images at `images/sfw` and NSFW images at `images/nsfw`. This can be configured with the `-d` flag. 8. Run the bot: \ `yarn local` @@ -42,7 +42,7 @@ Example cron configuration: ``` 0 * * * * cd /path/to/fediverse-imagebot && /usr/local/bin/yarn local -m "Message" ``` -This example will run the bot every hour on the hour with the post message `Message`. +This example will run the bot every hour on the hour with the post message `Message` using images from the default `images` directory. An example of this configuration can be found at https://froth.zone/rinbot. ## Additional information diff --git a/package.json b/package.json index 0da2fb3..bdae837 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "typescript": "^4.5.4" }, "name": "fediverse-imagebot", - "version": "0.1.0", + "version": "2.0.0", "description": "Image bot for the fediverse (Pleroma, Mastodon, Misskey)", "main": "dist/local.js", "scripts": { diff --git a/src/local.ts b/src/local.ts index d26fda8..5b9ecd0 100644 --- a/src/local.ts +++ b/src/local.ts @@ -72,7 +72,7 @@ if (args.verbose) { } // JSON object read from config file -let data: { +let config: { instance: string, type: "misskey" | "mastodon" | "pleroma", accessToken: string, @@ -80,9 +80,9 @@ let data: { }; try { - data = JSON.parse(fs.readFileSync(args.config, "utf8")); + config = JSON.parse(fs.readFileSync(args.config, "utf8")); if (args.verbose) { - console.log(`Config: ${JSON.stringify(data)}`); + console.log(`Config: ${JSON.stringify(config)}`); } } catch (e: unknown) { @@ -139,7 +139,7 @@ else { sensitivity = false; } -const client = generator(data.type, data.instance, data.accessToken); +const client = generator(config.type, config.instance, config.accessToken); client.uploadMedia(image).then((res: Response) => { if (args.verbose) console.log(res.data); @@ -149,22 +149,21 @@ client.uploadMedia(image).then((res: Response) => { sensitive: sensitivity } ).then((res: Response) => { - console.log("Successfully posted to " + data.instance); + console.log("Successfully posted to " + config.instance); if (args.verbose) console.log(res.data); exit(0); } ).catch((err: Error) => { - console.error("Error posting to " + data.instance + ": " + err.message); + console.error("Error posting to " + config.instance + ": " + err.message); if (args.verbose) { console.error("--BEGIN FULL ERROR--"); console.error(err); } else console.error("Run with -v to see the full error."); - } - ); + }); }).catch((err: Error) => { - console.error("Error uploading image to " + data.instance + ": " + err.message); + console.error("Error uploading image to " + config.instance + ": " + err.message); if (args.verbose) { console.error("--BEGIN FULL ERROR--"); console.error(err);