Go to file
2024-10-16 23:23:02 -07:00
.gitignore Updated gitignore to ignore folders 2024-10-13 23:42:38 -07:00
boorubot_v2.sh Bugfix and remove useless variable 2024-10-16 23:23:02 -07:00
boorubot.sh Updated to make image selections more random 2024-04-16 21:00:13 -07:00
imgbot.sh Updated for new key paths 2024-10-13 23:40:53 -07:00
LICENSE.txt Initial Commit 2024-03-09 18:29:43 -08:00
pick_ordered.sh Fixed regex bug that would prevent more than ten lines from being read 2024-03-10 14:43:10 -07:00
README.md Updated cron instructions to make it more portable for strictly posix compliant systems 2024-03-10 00:37:36 -08:00

ReadMe

FediStatusPosterExtras is a collection of shell scripts to extend the functionality of FediStatusPoster.

The scripts are intended to be used with cron to create long running bots that can post more than just a default/random image or message.

Live examples can be found at GNU/Yandere

Scripts

The following scripts are included:

boorubot.sh This script demonstrates how to download a random image from a booru site (in this case gelbooru.com) and post it to your bot account. It will automatically set the sensative flag for the post based on the result. This script utalizes curl and jq to query and download images.

imgbot.sh This script demonstrates how to set custom text based on the path location of the image passed to it. It will utalize the same method to automatically post to the correct bot account based on the image path.

pick_ordered.sh This script will return a line from a text file, as well as log the location of the last line it read from. This is useful to post a list of images in order, and pass the result to the above two scripts. It will wrap around the text file if it reaches the end.

All of the above scripts expect FediStatusPoster to be in the root directory as this repo (ie. both repos should be in the same root directory). You can ofcourse modify the contents of the shell scripts to suit your preferences.

Installing

You must have git and python3 installed.

To setup the Python3 environment, run the following commands:

git clone 'https://git.yandere.cc/Anon/FediStatusPoster.git'
git clone 'https://git.yandere.cc/Anon/FediStatusPosterExtras.git'
cd FediStatusPoster
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install Mastodon.py
deactivate
./fedistatusposter.sh -h

If everything worked correctly, you should see usage information on FediStatusPoster

Now cd into the Extra's folder:

cd ../FediStatusPosterExtras

Posting Your First Image

The below example will highlight how to query and post a random image from Gelbooru

First, create your credentials using CreatePleromaApp. Edit boorubot.sh and update the DEFUALT_CREDENTIALS and DEFAULT_KEYFILE accordingly.

Second, create a file called blacklist.txt, and add a list of line-seperated tags you don't want to be retured as a result.

Then run the following command (add rating:general if you only want a safe image returned):

./boorubot.sh blacklist.txt 'gasai_yuno yandere' 'Message to post if image is safe' 'Message to post if image is nsfw'

The bot will return a single random result for images tagged with gasai_yuno and yandere, and post the image with the corrisponding safe or nsfw message specified in the arguments above.

Useful Tips

To take full advantage of these scripts, they should be used in conjunction with cron to post at regular intervals.

You should edit imgbot.sh to tailor it to your specific needs.

Here are some example configuraitions I use for my bots:

# Post a random image from a directory:
05,25,45 * * * * find ~/Programs/python3/FediStatusPosterExtras/images -type f -print |\
shuf -n 1 | xargs ~/Programs/python3/FediStatusPosterExtras/imgbot.sh

# With a premade list of images, post each in order, wrapping around to the beginning when the end of the list is reached:
05,25,45 * * * * ~/Programs/python3/FediStatusPosterExtras/pick_ordered.sh \
~/Programs/python3/FediStatusPosterExtras/list_of_images_to_post.txt \
~/Programs/python3/FediStatusPosterExtras/logimgbot.log |\
xargs ~/Programs/python3/FediStatusPosterExtras/imgbot.sh

# With a premade list of booru searches stored in a csv file,
# Where the csv has three values seperated like so: search_tag,safe message,nsfw message
# Post each search in the list, wrapping around to the beginning when the end of the list is reached:
05,25,45 * * * * ~/Programs/python3/FediStatusPosterExtras/pick_ordered.sh \
~/Programs/python3/FediStatusPosterExtras/csv_with_search_tags_safemsg_nsfwmsg.csv \
~/Programs/python3/FediStatusPosterExtras/logboorubot.log |\
tr ',' '\0' | tr '\n' '\0' |\
xargs -0 ~/Programs/python3/FediStatusPosterExtras/boorubot.sh \
~/Programs/python3/FediStatusPosterExtras/blacklist.txt

Donate

BTC: bc1q8w04c6xt0sm2nskkqatp372llyx8ed33at4k4g

ETH & BAT: 0x2B1C49cc1C93e5bba59a5eD4D0E0a4Da8D6Ce482

XMR: 493HynLQA4z71b3j9ZDXRNQudpdFW8GxeBGD8ahRctKn97RRurMVd35DqVqdAdjv68TcXTJWUwm6ee81ujDXGcmtKFixwQk