117 lines
4.7 KiB
Python
117 lines
4.7 KiB
Python
#! /usr/bin/env python
|
|
|
|
# Yandere Lewd Bot, an image posting bot for Pleroma
|
|
# Copyright (C) 2022 Anon
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
from collections import OrderedDict
|
|
|
|
# YandereBot is a customizable, no frills image-posting bot. The bot was designed to be simple to understand
|
|
# (from a technical perspective) and easy to modify/extend. YandereBot relies on GNU formatted hash files to configure
|
|
# and organize posts: (ex. 'd13f8ac27db94291dd5a348ed70c69bb *./rsc/2019.11.27/DDLC/nsfw/Ga4C1qE.jpg')
|
|
|
|
# setup_profile() -> Basic function to configure one line posts
|
|
# @param name The name of the profile. This is only used to inform you if your profiles are setup correctly.
|
|
# @param path The path of the hash file (if using YanBotV2) or a string with fnmatch wildcards (for YanBotV3)
|
|
# @param spoiler Boolean value. Will mark the media as sensitive. Use for nsfw or spoilers.
|
|
# @param *message The message. A variable length argument that will treat each parameter passed to it as a
|
|
# separate line. Do not use the linebreak character '\n' to configure multiline posts. Instead,
|
|
# each line should be passed as a separate string to the *message parameter.
|
|
|
|
def setup_profile(name, path, spoiler, *message):
|
|
post_setting = {
|
|
"name": name,
|
|
"path": path,
|
|
"spoiler": spoiler,
|
|
"message": message
|
|
}
|
|
return post_setting
|
|
|
|
|
|
def setup_nsfw_profile(name, path, *message):
|
|
return setup_profile(name, path, True, *message)
|
|
|
|
|
|
def setup_safe_profile(name, path, *message):
|
|
return setup_profile(name, path, False, *message)
|
|
|
|
|
|
# Client credentials: >>>NEVER GIVE THESE OUT TO ANYONE<<<
|
|
# Use the create_app.py script and follow the prompts to generate your tokens. Once generated, copy & paste them below.
|
|
settings_server = OrderedDict([
|
|
("app_name", "Generated from create_app.py"),
|
|
("api_base_url", "Generated from create_app.py"),
|
|
("client_id", "Generated from create_app.py"),
|
|
("client_secret", "Generated from create_app.py"),
|
|
("access_token", "Generated from create_app.py")
|
|
])
|
|
|
|
settings_reminder = "Generated from create_app.py"
|
|
|
|
# Encryption settings: When using encryption the bot will ask you for your password before logging into your instance.
|
|
# Use create_app.py and follow the instructions. Select yes when it asks you if you want to encrypt your credentials.
|
|
# Paste the output below and never change the values.
|
|
# If you want to encrypt or re-encrypt settings_server you can use encryption.py (or just regenerate your tokens)
|
|
settings_encrypt = {
|
|
"encrypt": False,
|
|
"salt": "Generated from create_app.py"
|
|
}
|
|
|
|
# Basic settings to configure Yandere Bot's behavior
|
|
settings_behavior = {
|
|
"master_list": ("./md5/master_file.txt",),
|
|
"master_blacklist_r": ("./md5/blacklist.txt", "./md5/master_blacklist.txt"),
|
|
"master_blacklist_w": ("./md5/blacklist.txt",),
|
|
"max_size": 15*1024*1024,
|
|
"visibility": "private",
|
|
"feature_set": "pleroma",
|
|
"sleep_seconds": 1*60*60,
|
|
"uploads_per_post": 1,
|
|
"retry_seconds": 15,
|
|
"multi_media_ext": ".txt",
|
|
"content_type": "text/plain",
|
|
"content_newline": "\n",
|
|
"post_image_link": False,
|
|
"post_random": False,
|
|
"atomic_saving": False,
|
|
"sync_save": True,
|
|
"tmp_dir": "/var/tmp",
|
|
"debug": False
|
|
}
|
|
|
|
# Time string formats
|
|
settings_time = {
|
|
"time_format": "%I:%M%p",
|
|
"time_format_seconds": "%I:%M:%S%p",
|
|
"date_format": "%m/%d/%Y",
|
|
"long_date_format": "%m/%d/%Y %I:%M%p",
|
|
"long_date_seconds_format": "%m/%d/%Y %I:%M:%S%p",
|
|
"long_date_week": "%m/%d/%Y %I:%M%p, %A"
|
|
}
|
|
|
|
# Apply post settings
|
|
settings_post = (
|
|
# safe
|
|
setup_safe_profile("profile.safe", "./rsc/safe/*", "#yandere"),
|
|
|
|
# nsfw
|
|
setup_nsfw_profile("profile.nsfw", "./rsc/nsfw/*", "#nsfw #lewd #yandere"),
|
|
)
|
|
# Default post behavior:
|
|
# If no profile can be matched in a master_list, it will default to settings_post_default
|
|
# If settings_post_default is None, the bot will error out and output the offending line(s)
|
|
# If you want the bot to start, set this to a valid settings_post, or create a default setting with setup_profile()
|
|
settings_post_default = None
|