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.
DanbooruBot/docs/configuration.md
2022-10-11 23:30:16 -07:00

105 lines
6.5 KiB
Markdown

# Configuration
Danbooru Bot uses regular python files to configure posts. The default configuration is `cfg.py`
Included in the file is a [helper function](#settings_post) to quickly configure posts. These are located at the top of the configuration file.
Posts are configured in a 2d matrix with both the x and y offset incremented after each successful post (or failed fetch, indicating a configuration error)
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_credentials
If a back end supports or requires an account to use their api, the credentials for your account input here, and used by the back end. This is not required unless you have a premium account from Danbooru.
## settings_behavior
This is the main configuration setting for the bot.
**`max_size:`** (Not implemented yet) 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'.**
**`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.
**`tag_select:`** If set to `random`, the bot will randomly post from `settings_post`. If set to `sequential` it will sequentially post from `settings_post` starting at 0 (or whatever the user specifies with the `-i` switch).
**`retry_seconds:`** The time to wait between post attempts (in seconds).\
**`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 default `'\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 `/tmp`.
**`debug:`** Set this to true for testing. This will prevent Danbooru 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).
## 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 Danbooru Bot profiles. Use the `setup_profile()` function to set profiles up in a single line.
# Setting Up Profiles
Each profile in `settings_post` contains a dictionary with the below keywords. Use the `setup_profile()` function with the same parameter names to setup posts in a single line.
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.
* **`backend`** String value. The backend to use to download images. See danbooru_backend.py for an example.
* **`banned_tags:`** Tuple of strings. Posts that contain these tags will not be uploaded.
* **`tags:`** String value. Tags for the bot to search for. **NOTE:** Danbooru will only search for a single tag at a time. Adding more will cause the post to fail, and the bot to skip over it.
* **`message:`** String value. The body of the post when a *safe* image is selected.
* **`message_nsfw:`** String value. The body of the post when a *nsfw* image is selected.
* **`force_nsfw:`**: If set to `True`, the profile will only post nsfw images. If set to `False` only safe images will be selected. If set to `None` the bot could post either safe or nsfw images.