Go to file
dotnet c05aff718e Make message formatting more flexible. 2023-10-13 19:23:06 -04:00
.gitignore Add log.txt to gitignore. 2023-10-13 18:24:03 -04:00
LICENSE Add MIT license 2023-10-10 18:52:34 -04:00
README.md Allow specification of several messages to choose from 2023-10-13 14:36:59 -04:00
gelbooru_poster.py Make message formatting more flexible. 2023-10-13 19:23:06 -04:00
misskeybot.service Initial Commit 2023-10-10 14:30:37 -04:00
misskeybot.timer Initial Commit 2023-10-10 14:30:37 -04:00

README.md

Gelbooru Image Bot for Misskey

Simple python bot which scrapes images from gelbooru based on specified tags every hour and posts to a misskey instance. The script can handle multiple bots simulatenously.

  • Uses a systemd timer.
  • Posts original source when available.
  • Attempts to optimize downloaded images for size with PIL.
  • Attempts to renote the original source if possible.
  • Option for posting to hashtags (limits to once per day to avoid drowning out other content).

Installation

Requires the pillow library: pip install pillow

Edit the misskeybot.service file with your install path, copy misskeybot.service and misskeybot.timer to /etc/systemd/system/ then run as root:

systemctl daemon-reload                 #Reload unit files
systemctl enable misskeybot.timer       #Enable the periodic execution of the script
systemctl start misskeybot.timer        #Start the periodic execution of the script

Usage

python .\gelbooru_poster.py --help
Usage: python3 gelbooru-bot.py [--gen-config] [--help]
  --gen-config: Add a new bot to the config.json file
  --help: Show this help message
  No arguments: Run the bot
  Note: The values in defaults.json will be used if the values are not set in config.json

Files

config.json

{
    "hololive_images": {
        "gelbooru_tags": "hololive",
        "gelbooru_tags_exclude": "-sky",
        "bot_message": ["Hololive Image", "Uooooh"],
        "bot_hashtags": "#hololive",
        "misskey_token": "uuuu0hOhrrrlrlrP8888uquqaaaaAUAU",
        "max_page_number": 200,
        "last_run_time": -1
    },
    "kancolle": {
        "gelbooru_tags": "{kantai_collection ~ boat_girl}",
        "gelbooru_tags_exclude": "",
        "bot_message": ".",
        "bot_hashtags": "#kancolle",
        "misskey_token": "HHkkuuuutdtdrrrrvWvW8888yayaaaaa",
        "max_page_number": 200,
        "misskey_url": "https://misskey.io/api/",
        "last_run_time": 1696896202.1551812
    }
}
  • max_page_number: Automatically determined by the script.

  • last_run_time: Used to allow the different bots to post at different times by tracking the last time that specific bot posted.

defaults.json

{
    "gelbooru_tags": "rating:safe",
    "gelbooru_tags_exclude": "",
    "bot_message": "Random image from Gelbooru",
    "misskey_url": "https://misskey.io/api/",
    "misskey_token": "",
    "max_page_number": 1000
}
  • These values are used if not defined in the config.json, useful if all bots are on the same url.