Updated to reflect scheduling posts with cron
This commit is contained in:
parent
8ebca294b0
commit
adb52b817c
47
README.md
47
README.md
@ -52,7 +52,6 @@ cd CreatePleromaApp/
|
||||
# Follow the interactive prompts.
|
||||
```
|
||||
|
||||
|
||||
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([
|
||||
@ -68,11 +67,11 @@ settings_reminder = "09/20/2020 02:58PM"
|
||||
settings_encrypt = {
|
||||
"encrypt": False,
|
||||
"salt": "",
|
||||
"keyfile": None
|
||||
}
|
||||
```
|
||||
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.**
|
||||
|
||||
|
||||
## Danbooru credentials
|
||||
If you have an account with Danbooru, you can enter it below the `danbooru_backend` dictionary. It is not necessary to have an account unless you want to post images that are censored by default.
|
||||
|
||||
@ -84,7 +83,6 @@ To begin posting:
|
||||
- Enter your password if you encrypted your OAuth tokens.
|
||||
- If you symlinked the file in the [Installing](#installing) section you can simply run `danbooruBot` 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.
|
||||
- Keep in mind that the bot's default visibility setting is set to unlisted for testing. You may want to update it to public.
|
||||
- Read [docs/configuration.md](./docs/configuration.md) to customize the bot for your purposes.
|
||||
|
||||
@ -94,29 +92,34 @@ XMR: 493HynLQA4z71b3j9ZDXRNQudpdFW8GxeBGD8ahRctKn97RRurMVd35DqVqdAdjv68TcXTJWUwm
|
||||
BAT: [Basic Attention Token](https://basicattentiontoken.org/)
|
||||
|
||||
# Useful Tips
|
||||
## Installing Screen
|
||||
Most likely, you will want this bot to run over a long period of time. It is probably 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).
|
||||
## Scheduling posts with cron
|
||||
Most likely you will want this bot to run over a long period of time. There are a several ways to automate calling a script at regular intervals on Linux. For brevity I will be covering the cron way.
|
||||
|
||||
First off, install cron if it's not already installed:
|
||||
```
|
||||
sudo pacman -Syu
|
||||
sudo pacman -S --needed screen
|
||||
|
||||
# Screen cheatsheet
|
||||
# To create a new screen session named 'danbooruBot'
|
||||
screen -S danbooruBot
|
||||
# To detach from the screen session
|
||||
Ctrl+a d
|
||||
# To reconnect to the screen session
|
||||
screen -r danbooruBot
|
||||
# List screen sessions
|
||||
screen -ls
|
||||
# Kill the screen session
|
||||
Ctrl+a k y
|
||||
# Scroll back
|
||||
Ctrl+a ESC Page Up
|
||||
# Cancel scroll back
|
||||
ESC
|
||||
sudo pacman -S --needed cronie
|
||||
sudo systemctl enable cronie
|
||||
sudo systemctl start cronie
|
||||
```
|
||||
|
||||
Next, run the following commands:
|
||||
- `crontab -e`
|
||||
- `25,55 * * * * /absolute/path/to/run.sh >> "/absolute/path/to/log.txt" 2>&1`
|
||||
- Modify the paths above to suit your preferences
|
||||
- Save and exit
|
||||
|
||||
If you followed the steps above the cron job should run every 30 minutes at 25 and 55 minutes past the hour. Tail the log file to ensure it's working correctly.
|
||||
|
||||
## Advanced cron
|
||||
If you want to post in sequential order from your profiles (assuming you have multiple), you can use the `-i` flag and grep from the log file to start the bot at the last index it posted from.
|
||||
|
||||
Below is an example on how to do this with cron:
|
||||
- `crontab -e`
|
||||
- ``25,55 * * * * [ ! -f /absolute/path/to/log.txt ] && /absolute/path/to/run.sh >> /absolute/path/to/log.txt 2>&1 || /absolute/path/to/run.sh -i "$(expr `grep "^Profile" /absolute/path/to/log.txt | cut -d ' ' -f5 | tail -n 1` + 1)" >> /absolute/path/to/log.txt 2>&1``
|
||||
- Modify the paths above to suit your preferences
|
||||
- Save and exit
|
||||
|
||||
## Quickly Create Configuration Files
|
||||
Configuration files for Danbooru 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.
|
||||
```
|
||||
|
@ -32,6 +32,8 @@ Paste the generated credentials from `create_app.py` in the fields below.
|
||||
|
||||
**`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.
|
||||
|
||||
@ -44,11 +46,11 @@ This is the main configuration setting for the bot.
|
||||
|
||||
**`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`
|
||||
|
||||
**`retry_seconds:`** The time the bot should wait before attempting to re-upload a post that failed (in seconds). This value is ignored if the bot experiences a FileNotFoundError (the file was deleted after the bot was started) or encounters a 413 error (file upload size is too large). In either of the two cases the bot will continue posting the next image in the list.
|
||||
**`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).\
|
||||
|
||||
**`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'`**.
|
||||
|
||||
|
Reference in New Issue
Block a user