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/docs/configuration.md

119 lines
8.0 KiB
Markdown

# Configuration
Yandere Lewd Bot uses regular python files to configure posts. The default configuration is `cfg.py`
Included in the file are three [helper functions](#setting-up-profiles-in-a-single-line) to quickly configure posts. These are located at the top of the configuration file.
Below is a detailed description of each parameter in the configuration file.
## setting_server
Paste the generated credentials from `create_app.py` in the fields below.
**`app_name:`** The name of the application.
**`api_base_url:`** The URL of the instance.
**`client_id:`** The client ID generated by `create_app.py`
**`client_secret:`** The client secret generated by `create_app.py`
**`access_token:`** The client token generated by `create_app.py`
**NOTE:** If you enabled encryption when generating your tokens, the above should be long strings of seemingly incoherent text.
## settings_reminder
A setting to remind the user to regenerate their OAuth tokens
**`settings_reminder:`** A date and time, formatted as `settings_time["long_date_format"]`. Used to remind the user to regenerate their OAuth tokens.
## settings_encrypt
Paste the generated credentials from `create_app.py` in the fields below.
**`encrypt:`** If encryption is enabled this should be set to `True`
**`salt:`** The salt value generated by `create_app.py`
**`keyfile:`** The keyfile used for decryption.
## settings_behavior
This is the main configuration setting for the bot.
**`master_list:`** The master list(s) for the bot to post from. This should be a GNU formatted hash file. If multiple lists are specified they will be concatenated in order.
**`master_blacklist_r:`** The master blacklist(s) to be *read* when the bot starts. This should be a GNU formatted hash file. All hashes and paths specified in this setting will be blacklisted when the bot initializes and will not be posted.
**`master_blacklist_w:`** The master file(s) to *write* to when the bot makes a successful post. This will be a GNU formatted hash file.
**`max_size:`** The max upload size (in bytes). Files that are over will be excluded from posting. Set this to `None` if there is no limit (not recommended). If you find that the bot is continuously attempting to repost a post that is failing, and the connection is timing out, it usually signifies that you are attempting to upload a large file over a slow connection and getting dropped from the server. Reducing this value should fix the issue.
**`visibility:`** The visibility of the post ('public', 'unlisted', 'private', or 'direct').
**`feature_set:`** The feature set of the instance you are connecting to ('mainline', 'fedibird', or 'pleroma'). **This bot has only been tested with 'pleroma'.**
**`sleep_seconds:`** The time between posts (in seconds)
**`uploads_per_post:`** The number of times the bot should post after `sleep_seconds`
**`max_errors:`** The max consecutive posting errors that should occur before the bot gives up and exits. This usually indicates a temporary problem with the remote server, however if the bot repeatedly fails, and the server is up, it probably means the image is too large to upload. Try reducing the `max_size` variable if this happens. Your image may also be in a format that the remote server rejects, in which case the post should be added to the master blacklist.
**`retry_seconds:`** The time to wait between post attempts (in seconds).
**`multi_media_ext:`** Files ending with this extension will be treated as a multi-upload list. All GNU formatted hashes contained within will be uploaded in a single post when picked by the bot. Setting this value to `None` or `False` will disable this behavior.
**`content_type:`** The content type of the post ('text/plain' (default), 'text/markdown', 'text/html', 'text/bbcode'). **This bot has only been tested with `'text/plain'` and `'text/markdown'`**.
**`content_newline:`** The newline character or string. This will be inserted between each line in the message. If `content_type` is `'text/plain'`, this value should be `'\n'`. If `content_type` is `'text/markdown'` you may need to experiment. On some instances the defualt `'\n'` works, on others you may need to change this to `'<br/>'`.
**`post_image_link:`** If set to `True` this will insert a direct media link at the end of the message for each media file uploaded. If `content_type` is `'text\markdown'` it will make the link actionable, otherwise it will simply be a plain text html link. Some instances add this link automatically, in which case this should be set to `False`. See `content_newline` and `content_type` to correctly configure actionable links.
**`tmp_dir:`** The temporary directory to use if `atomic_saving` is set to `True`. The default location is `/var/tmp`.
**`debug:`** Set this to true for testing. This will prevent Yandere Lewd Bot from logging into the mastodon instance and asking for your encryption password (meaning that nothing will actually get posted to your account, but it will still do everything else).
**NOTE:** `master_list`, `master_blacklist_r`, and `master_blacklist_w` all take a tuple() of str(). Please see below for formatting help.
> To specify multiple files: `master_blacklist_r: ("./md5/blacklist.txt", "./md5/master_blacklist.txt"),`
> To specify a single file: `master_blacklist_r: ("./md5/blacklist.txt",),`
> To specify no file: `master_blacklist_r: tuple(),`
## settings_time
Time localization settings. Mostly unimplemented.
**`time_format:`** Time format.
**`time_format_seconds:`** Should be the same as `time_format` but with a resolution in seconds.
**`date_format:`** Date format.
**`long_date_format:`** Time and date format. `settings_encrypt["reminder"]` Should be in this format. CreatePleromaApp will use this value if available.
**`long_date_seconds_format:`** Should be the same as `long_date_format` but with a resolution in seconds.
**`long_date_week:`** The same as `long_date_format` but with the day of the week specified.
## settings_post
Configure Yandere Lewd Bot profiles. In the default configuration, images are sorted by safe and nsfw profiles. This means that all 'safe' images should be located in `./rsc/safe/*` and all 'nsfw' images should be located in `./rsc/nsfw/*`. The bot will apply profiles based on it's file path using [Unix filename pattern matching](https://docs.python.org/3/library/fnmatch.html).
**`settings_post:`** A tuple() containing all of the profile dictionaries that the bot can post. See `setup_profile()`, `setup_nsfw_profile()`, and `setup_safe_profile()` for help configuring custom profiles.
**`settings_post_default:`** The default post profile. If no profile can be matched for an item in the `master_list` it will default to the profile specified by this value. If the value is `None`, the bot will error out and output the offending line(s) from the hash file (recommended). If you want to apply a default post behavior for unmatched profiles, create a default setting with `setup_profile()` helper function. The Unix `path` keyword will be completely ignored.
# Setting Up Profiles
Each profile in `settings_post` contains a dictionary with the following keywords: `name`, `path`, `spoiler`, and `message`
There are three helper functions located at the top of the configuration file with the same parameter names to help you setup posts in a single line:
```
setup_profile(name, path, spoiler, *message)
setup_nsfw_profile(name, path, *message)
setup_safe_propfile(name, path, *message)
```
Below is an explanation of each keyword:
* **`name:`** String value. The name of the profile. This is mainly used to help you identify what profile is being applied to posts. This information is printed by the bot, but is otherwise unused.
* **`path:`** String value. This should be a Unix path with wild cards. The bot will configure posts accordingly by using [Unix filename pattern matching](https://docs.python.org/3/library/fnmatch.html) implemented in the `fnmatch` python library.
* **`spoiler:`** Boolean value. Mark the media as sensitive. Use for nsfw or spoilers.
* **`message:`** A tuple of strings. The message. Each string in the tuple will be placed on a new line.