Make README show newer image folder option
continuous-integration/drone Build is passing Details

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2022-01-09 12:05:55 -06:00
parent 874ecb7729
commit d9e4f2dc6f
Signed by: sam
GPG Key ID: 4D8B07C18F31ACBD
4 changed files with 11 additions and 13 deletions

View File

@ -3,7 +3,6 @@ type: docker
name: default
steps:
- name: lint
image: node
commands:

View File

@ -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

View File

@ -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": {

View File

@ -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<Entity.Attachment>) => {
if (args.verbose)
console.log(res.data);
@ -149,22 +149,21 @@ client.uploadMedia(image).then((res: Response<Entity.Attachment>) => {
sensitive: sensitivity
}
).then((res: Response<Entity.Status>) => {
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);