You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Anon c3fb59a3e7
Removed unused modules
2 years ago
default Added banned tags 2 years ago
docs Updated documentation 2 years ago
src Removed unused modules 2 years ago
.gitignore Added cron script 2 years ago
LICENSE.txt Initial Commit 2 years ago Updated donate section 2 years ago Cleaned up comments 2 years ago
requirements.txt Added dependency for python-magic 2 years ago Cleaned up comments 2 years ago


Danbooru Bot is a customizable, no frills image-posting bot for Pleroma.

A live example can be viewed at GNU/Yandere.

Currently the bot will only run on Linux. I believe it should run on most distros but I have only tested it on Arch and Raspbian.


The main purpose of this bot is to download a random image from a list of pre-configured profiles (using tags) and upload it to Pleroma. Danbooru Bot is designed to be simple to understand (from a technical perspective) and easy to modify/extend. Despite the name, several different booru sites can be supported since modules are dynamically loaded at runtime.

This project is licensed under GPLv3. See LICENSE.txt.

The bot is still in development and can easily be crashed by writing a poorly configured file. It may also crash with encoding errors for files with non-unicode filenames.

Booru Sites Supported

  1. Danbooru
  2. Gelbooru (Testing)
  3. Konachan (Testing)


To setup the python3 environment (for Arch Linux) run the following commands:

sudo pacman -Syu
sudo pacman -S --needed python git
git clone ''
cd DanbooruBot/
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
cp -vn default/ src/
./ -h

If everything worked correctly you should see usage information on Danbooru Bot.

The ./ file will automatically activate and deactivate the python virtual environment. You may want add a symlink to /usr/local/bin for convenience.

sudo ln -s "$(pwd)/" "/usr/local/bin/danbooruBot"
danbooruBot -h

For Debian or Ubuntu based distros I believe you need to change python with python3 for the package and command name ¯\_(ツ)_/¯

Generating your OAuth Tokens

Before you can begin posting from the bot, you must first create an account on the instance of your choice, and then generate your OAuth tokens.

To generate your tokens, run the following commands and follow the interactive prompts.

cd ..
git clone ''
ln -s "$(pwd)"/DanbooruBot/venv CreatePleromaApp/venv
ln -s "$(pwd)"/DanbooruBot/src/ CreatePleromaApp/src/
cd CreatePleromaApp/
./ -c cfg
# Follow the interactive prompts.

If you did everything correctly you should see Success! :) at the end of the terminal, as well as your credentials in the format below:

settings_server = OrderedDict([
        "app_name":       "app",
        "api_base_url":   "",
        "client_id":      "Long String of Text",
        "client_secret":  "Long String of Text",
        "access_token":   "Long String of Text"

settings_reminder = "09/20/2020 02:58PM"

settings_encrypt = {
        "encrypt":		False,
        "salt":			"",
		"keyfile":		None

If you used encryption, everything in the settings_server dictionary will be encrypted. If you used encryption and did not specify a keyfile, you will have to enter your password every time you start the bot. Copy and paste these values from the terminal into your src/ file. Make sure you paste over or delete the placeholder values with the same names.

Danbooru credentials

If you have an account with Danbooru, you can enter it below the danbooru_backend dictionary. It is not necessary to have an account unless you want to post images that are censored by default.


To begin posting:

  • Start the bot with ./
    • Enter your password if you encrypted your OAuth tokens.
    • If you symlinked the file in the Installing section you can simply run danbooruBot instead of changing directories and starting the bot with ./
  • If everything worked correctly, you should see your first image posted to your account.
  • Keep in mind that the bot's default visibility setting is set to unlisted for testing. You may want to update it to public.
  • Read docs/ to customize the bot for your purposes.


BTC: bc1q8w04c6xt0sm2nskkqatp372llyx8ed33at4k4g

ETH & BAT: 0x2B1C49cc1C93e5bba59a5eD4D0E0a4Da8D6Ce482

XMR: 493HynLQA4z71b3j9ZDXRNQudpdFW8GxeBGD8ahRctKn97RRurMVd35DqVqdAdjv68TcXTJWUwm6ee81ujDXGcmtKFixwQk

Useful Tips

Scheduling posts with cron

Most likely you will want this bot to run over a long period of time. There are a several ways to automate calling a script at regular intervals on Linux. For brevity I will be covering the cron way.

First off, install cron if it's not already installed:

sudo pacman -Syu
sudo pacman -S --needed cronie
sudo systemctl enable cronie
sudo systemctl start cronie

Next, run the following commands:

  • crontab -e
  • 25,55 * * * * /absolute/path/to/ >> "/absolute/path/to/log.txt" 2>&1
    • Modify the paths above to suit your preferences
  • Save and exit

If you followed the steps above the cron job should run every 30 minutes at 25 and 55 minutes past the hour. Tail the log file to ensure it's working correctly.

Advanced cron

Included with the bot is a script. The script will automatically pass the -i and -s (index and state switches respectively) to the bot by grepping from the log file. This script has not been tested thoroughly so use with caution

Below is an example on how to use this script:

  • Open and make any necessary changes to the default log path.
  • crontab -e
  • 25,55 * * * * /absolute/path/to/ >> "/absolute/path/to/log.txt" 2>&1
    • Modify the paths above to suit your preferences
    • Make sure the absolute log path in the crontab file is the same as the log path in
  • Save and exit

Quickly Create Configuration Files

Configuration files for Danbooru Bot are just python files. Because of this we can easily create multiple configurations by importing the main configuration file, and overriding the values we need. This is useful for creating holiday and debug configurations without needing to create a new configuration file from scratch.

# Name:
# Post to an alt account using the exact same settings as the main configuration file
# Run with the following command: ./ -c alt

# is the default configuration.
from cfg import *

settings_server = OrderedDict([
	("app_name",		"generate from ./bin/"),
	("api_base_url",	"generate from ./bin/"),
	("client_id",		"generate from ./bin/"),
	("client_secret",	"generate from ./bin/"),
	("access_token",	"generate from ./bin/")

settings_reminder = "generate from ./bin/"

settings_encrypt = {
	"encrypt":	False,
	"salt":	"generate from ./bin/"

# Uncommenting the below might be useful if your alt is used for debugging and testing
# settings_behavior["visibility"] = "private"
# settings_behavior["debug"] = True
# Name:
# An xmas themed config file!
# Run with the following command: ./ -c xmas

# is the default configuration.
from cfg import *

# Prepend '#Merry #Christmas' to the beginning of the first line in each post
for setting in settings_post:
	if len(setting["message"]) and issubclass(type(setting["message"][0]), str):
		new_msg = "#Merry #Christmas {}".format(setting["message"][0])
		setting["message"] = (new_msg,) + setting["message"][1:]