This repository has been archived on 2024-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
YandereLewdBot/README.md

177 lines
7.8 KiB
Markdown
Raw Normal View History

2022-07-14 12:32:18 -07:00
# Readme
Yandere Lewd Bot is a customizable, no frills image-posting bot for Pleroma.
2022-07-14 13:11:32 -07:00
A live example can be viewed at [GNU/Yandere](https://yandere.cc/YandereLewdBot).
2022-07-14 12:32:18 -07:00
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.
## About
Yandere Lewd Bot is designed to be simple to understand (from a technical perspective) and easy to modify/extend. Yandere Lewd Bot relies on GNU formatted hash files to configure and organize posts (from the GNU coreutils package):
(ex. `26d00a6ee5ae8fa3d58ee44b32b8992f *./rsc/nsfw/image.jpg`)
2022-07-14 13:11:32 -07:00
The bot is still in development and can easily be crashed by writing a poorly configured `cfg.py` file, or messing with the hash files it uses to configure posts. The bot may also crash with encoding errors for files with non-unicode filenames.
2022-07-14 12:32:18 -07:00
## Installing
To setup the python3 environment (for Arch Linux) run the following commands:
```
sudo pacman -Syu
sudo pacman -S --needed python git
2022-07-14 13:11:32 -07:00
git clone 'https://git.yandere.cc/Anon/YandereLewdBot.git'
2022-07-14 12:32:18 -07:00
cd yandereLewdBot/
python -m venv venv
source ./venv/bin/activate
pip install --upgrade pip
2022-07-14 13:11:32 -07:00
pip install -r requirements.txt
2022-07-14 12:32:18 -07:00
deactivate
2022-07-14 13:13:44 -07:00
# Generate the default folder structure.
2022-07-14 13:11:32 -07:00
mkdir md5
mkdir -p rsc/{safe,nsfw}
cp -vn ./default/cfg.py ./src/cfg.py
2022-07-14 12:32:18 -07:00
./run.sh -h
```
If everything worked correctly you should see usage information on Yandere Lewd Bot.
The ./run.sh file will automatically activate and deactive the python virtual environment. You may want add a symlink to `/usr/local/bin` for convienence.
```
sudo ln -s "$(pwd)/run.sh" "/usr/local/bin/yandereLewdBot"
yandereLewdBot -h
```
For Debian or Ubuntu based distros I believe you need to change python with python3 for the package and command name `¯\_(ツ)_/¯`
2022-07-14 13:11:32 -07:00
2022-07-14 12:32:18 -07:00
## 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.
```
source ./venv/bin/activate
./bin/create_app.py
# Follow the interactive prompts.
deactivate
```
If you did everything correctly you should see `Success! :)` at the end of the terminal, as well as your credentials in the format below:
```text
settings_server = OrderedDict([
"app_name": "app",
2022-07-14 13:11:32 -07:00
"api_base_url": "https://yandere.cc",
2022-07-14 12:32:18 -07:00
"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": "",
}
```
2022-07-14 13:11:32 -07:00
If you used encryption, everything in the `settings_server` dictionary will be encrypted and you will have to enter your password every time you start the bot. Copy and paste these values from the terminal into your `src/cfg.py` file. **Make sure you paste over or delete the placeholder values with the same names.**
2022-07-14 12:32:18 -07:00
## Posting
To begin posting:
- Put some images in the rsc/ folder (organize by safe and nsfw posts).
- 'safe' posts will be marked with `#yandere`
- 'nsfw' posts will be spoilered and marked as `#yandere #nsfw`
2022-07-14 13:11:32 -07:00
- Make sure you are in the bot's root directory (the directory with `run.sh`)
2022-07-14 13:18:40 -07:00
- Checksum all the files you added with the following command:
- `find "./rsc" -type f -exec md5sum -b '{}' \; > "./md5/master_file.txt"`
2022-07-14 12:32:18 -07:00
- Start the bot with `./run.sh`
- Enter your password if you encrypted your OAuth tokens.
- If you symlinked the file in the [Installing](##installing) section you can simply run `yandereLewdBot` instead of changing directories and starting the bot with `./run.sh`
- If everything worked correctly, you should see your first image posted to your account.
- Hit Ctrl+C to stop the bot.
- When you start the bot again, it will begin posting from where it last left off.
- It accomplishes this by writing to a `md5/blacklist.txt` file. If you see this file, it worked correctly.
- Keep in mind that the bot's default visibility setting is set to unlisted for testing. You may want to update it to public.
2022-07-14 13:35:00 -07:00
- Read [docs/configuration.md](/Anon/YandereLewdBot/src/branch/master/docs/configuration.md) to customize the bot for your purposes.
2022-07-14 12:32:18 -07:00
2022-07-14 13:11:32 -07:00
# Donate
XMR: 493HynLQA4z71b3j9ZDXRNQudpdFW8GxeBGD8ahRctKn97RRurMVd35DqVqdAdjv68TcXTJWUwm6ee81ujDXGcmtKFixwQk
2022-07-14 13:18:40 -07:00
# Useful Tips
2022-07-14 12:32:18 -07:00
## Installing Screen
2022-07-14 13:18:40 -07:00
Most likely, you will want this bot to run over a long period of time. It is probobly best to install the `screen` package for your distro so you don't have to have a terminal window constantly open (especially if you are running it from a remote machine such as a Raspberry Pi or server).
2022-07-14 12:32:18 -07:00
```
sudo pacman -Syu
sudo pacman -S --needed screen
# Screen cheatsheet
# To create a new screen session named 'yandereLewdBot'
screen -S yandereLewdBot
# To detach from the screen session
Ctrl+a d
# To reconnect to the screen session
screen -r yandereLewdBot
# List screen sessions
screen -ls
# Kill the screen session
Ctrl+a k y
# Scroll back
Ctrl+a ESC Page Up
2022-07-14 13:26:25 -07:00
# Cancel scroll back
2022-07-14 12:32:18 -07:00
ESC
```
## A Master Blacklist
2022-07-14 13:11:32 -07:00
The default configuration file has the following settings below (these files will not exist by default. The bot will simply ignore blacklist hash files that it can't open). The `_r` stands for read and the `_w` stands for write. This will ensure that the `master_blacklist.txt` is always read, but is never written to. This is intended for the user to manually add GNU formatted hashes to `master_blacklist.txt` in case they want to make especially sure that hashes and paths that are matched in the list are never uploaded accidentally.
2022-07-14 12:32:18 -07:00
```
"master_blacklist_r": ("./md5/blacklist.txt", "./md5/master_blacklist.txt"),
"master_blacklist_w": ("./md5/blacklist.txt",),
```
## Quickly Create Configuration Files
Configuration files for Yandere Lewd 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: alt.py
# Post to an alt account using the exact same settings as the main configuration file
# Run with the following command: ./run.sh -c alt
2022-07-14 13:26:25 -07:00
# cfg.py is the default configuration.
2022-07-14 12:32:18 -07:00
from cfg import *
settings_server = OrderedDict([
("app_name", "generate from ./bin/create_app.py"),
("api_base_url", "generate from ./bin/create_app.py"),
("client_id", "generate from ./bin/create_app.py"),
("client_secret", "generate from ./bin/create_app.py"),
("access_token", "generate from ./bin/create_app.py")
])
settings_reminder = "generate from ./bin/create_app.py"
settings_encrypt = {
"encrypt": False,
"salt": "generate from ./bin/create_app.py"
}
settings_behavior["master_blacklist_r"] = ("./md5/blacklist_alt.txt", "./md5/master_blacklist.txt")
settings_behavior["master_blacklist_w"] = ("./md5/blacklist_alt.txt",)
# Uncommenting the below might be useful if your alt is used for debugging and testing
# settings_behavior["master_list"] = ("master_file_alt.txt",)
# settings_behavior["visibility"] = "private"
# settings_behavior["debug"] = True
# settings_behavior["master_blacklist_w"] = tuple()
```
```
# Name: xmas.py
# An xmas themed config file!
# Run with the following command: ./run.sh -c xmas
2022-07-14 13:26:25 -07:00
# cfg.py is the default configuration.
2022-07-14 12:32:18 -07:00
from cfg import *
settings_behavior["master_list"] = ("./md5/event_xmas.txt",)
settings_behavior["master_blacklist_r"] = ("./md5/blacklist_xmas.txt", "master_blacklist.txt")
settings_behavior["master_blacklist_w"] = ("./md5/blacklist_xmas.txt",)
# 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:]
```