Updated to reflect scheduling posts with cron
This commit is contained in:
parent
b463b159dc
commit
01287fc0dd
44
README.md
44
README.md
@ -53,7 +53,6 @@ cd CreatePleromaApp
|
|||||||
# Follow the interactive prompts.
|
# 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:
|
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
|
```text
|
||||||
settings_server = OrderedDict([
|
settings_server = OrderedDict([
|
||||||
@ -69,9 +68,10 @@ settings_reminder = "09/20/2020 02:58PM"
|
|||||||
settings_encrypt = {
|
settings_encrypt = {
|
||||||
"encrypt": False,
|
"encrypt": False,
|
||||||
"salt": "",
|
"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.**
|
If you used encryption, everything in the `settings_server` dictionary will be encrypted. If you used encryption and did not specify a keyfile, 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.**
|
||||||
|
|
||||||
## Posting
|
## Posting
|
||||||
To begin posting:
|
To begin posting:
|
||||||
@ -86,7 +86,6 @@ To begin posting:
|
|||||||
- Enter your password if you encrypted your OAuth tokens.
|
- 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 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.
|
- 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.
|
- 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.
|
- 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.
|
- Keep in mind that the bot's default visibility setting is set to unlisted for testing. You may want to update it to public.
|
||||||
@ -98,34 +97,32 @@ XMR: 493HynLQA4z71b3j9ZDXRNQudpdFW8GxeBGD8ahRctKn97RRurMVd35DqVqdAdjv68TcXTJWUwm
|
|||||||
BAT: [Basic Attention Token](https://basicattentiontoken.org/)
|
BAT: [Basic Attention Token](https://basicattentiontoken.org/)
|
||||||
|
|
||||||
# Useful Tips
|
# Useful Tips
|
||||||
## Installing Screen
|
## Scheduling posts with cron
|
||||||
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).
|
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 -Syu
|
||||||
sudo pacman -S --needed screen
|
sudo pacman -S --needed cronie
|
||||||
|
sudo systemctl enable cronie
|
||||||
# Screen cheatsheet
|
sudo systemctl start cronie
|
||||||
# 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
|
|
||||||
# Cancel scroll back
|
|
||||||
ESC
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Next, run the following commands:
|
||||||
|
- `crontab -e`
|
||||||
|
- `25,55 * * * * /absolute/path/to/run.sh >> "/absolue/path/to/log.txt" 2>&1`
|
||||||
|
- Modify the paths above to suit your preferances
|
||||||
|
- 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.
|
||||||
|
|
||||||
## A Master Blacklist
|
## A Master Blacklist
|
||||||
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.
|
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.
|
||||||
```
|
```
|
||||||
"master_blacklist_r": ("./md5/blacklist.txt", "./md5/master_blacklist.txt"),
|
"master_blacklist_r": ("./md5/blacklist.txt", "./md5/master_blacklist.txt"),
|
||||||
"master_blacklist_w": ("./md5/blacklist.txt",),
|
"master_blacklist_w": ("./md5/blacklist.txt",),
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quickly Create Configuration Files
|
## 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.
|
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.
|
||||||
```
|
```
|
||||||
@ -148,7 +145,8 @@ settings_reminder = "generate from ./bin/create_app.py"
|
|||||||
|
|
||||||
settings_encrypt = {
|
settings_encrypt = {
|
||||||
"encrypt": False,
|
"encrypt": False,
|
||||||
"salt": "generate from ./bin/create_app.py"
|
"salt": "generate from ./bin/create_app.py",
|
||||||
|
"keyfile": None
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_behavior["master_blacklist_r"] = ("./md5/blacklist_alt.txt", "./md5/master_blacklist.txt")
|
settings_behavior["master_blacklist_r"] = ("./md5/blacklist_alt.txt", "./md5/master_blacklist.txt")
|
||||||
|
@ -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`
|
**`salt:`** The salt value generated by `create_app.py`
|
||||||
|
|
||||||
|
**`keyfile:`** The keyfile used for decryption.
|
||||||
|
|
||||||
## settings_behavior
|
## settings_behavior
|
||||||
This is the main configuration setting for the bot.
|
This is the main configuration setting for the bot.
|
||||||
|
|
||||||
@ -51,6 +53,8 @@ This is the main configuration setting for the bot.
|
|||||||
|
|
||||||
**`uploads_per_post:`** The number of times the bot should post after `sleep_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 repetedly fails, and the server is up, it probobly 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 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.
|
**`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.
|
||||||
|
|
||||||
**`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.
|
**`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.
|
||||||
@ -99,7 +103,15 @@ Configure Yandere Lewd Bot profiles. In the default configuration, images are so
|
|||||||
**`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.
|
**`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
|
# Setting Up Profiles
|
||||||
Each profile in `settings_post` contains a dictionary with the following keywords: `name`, `path`, `message`, and `spoiler`
|
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:
|
Below is an explanation of each keyword:
|
||||||
|
|
||||||
@ -107,33 +119,6 @@ Below is an explanation of each keyword:
|
|||||||
|
|
||||||
* **`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.
|
* **`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.
|
||||||
|
|
||||||
* **`message:`** A tuple of strings. The message. Each string in the tuple will be placed on a new line.
|
|
||||||
|
|
||||||
* **`spoiler:`** Boolean value. Mark the media as sensitive. Use for nsfw or spoilers.
|
* **`spoiler:`** Boolean value. Mark the media as sensitive. Use for nsfw or spoilers.
|
||||||
|
|
||||||
## Setting Up Profiles in a Single Line
|
* **`message:`** A tuple of strings. The message. Each string in the tuple will be placed on a new line.
|
||||||
At the top of the default configuration file are the following three helper functions to make setting up posts more intuitive.
|
|
||||||
>**`setup_profile(name, path, spoiler, *message)`**
|
|
||||||
**`setup_nsfw_profiles(name, path, *message)`**
|
|
||||||
**`setup_safe_profiles(name, path, *message)`**
|
|
||||||
|
|
||||||
---
|
|
||||||
**`setup_profile(name, path, spoiler, *message)`**
|
|
||||||
Returns a post setting dictionary that contains all of the information about a single profile. Each parameter corresponds to the keywords listed above.
|
|
||||||
|
|
||||||
* **`name:`** The name of the profile.
|
|
||||||
|
|
||||||
* **`path:`** A Unix path with wild cards.
|
|
||||||
|
|
||||||
* **`spoiler:`** Mark the media as sensitive. Use for nsfw or spoilers.
|
|
||||||
|
|
||||||
* **`*message:`** The message. This is a variable length parameter (meaning that multiple parameters may be passed to it). Each line in your message should be passed as a separate string to the `*message` variable.
|
|
||||||
>**DO NOT** use the newline character `\n` to configure multiline messages. Instead pass each line as a separate string parameter: ex. `setup_profile("profile.safe", "./rsc/safe/*", False, "First line in my message", "Second line in my message")`
|
|
||||||
|
|
||||||
> Each line in the example above will be placed on a new line.
|
|
||||||
|
|
||||||
**`setup_nsfw_profiles(name, path, *message)`**
|
|
||||||
Returns a post_setting dictionary that contains all of the information about a single **nsfw** profile.
|
|
||||||
|
|
||||||
**`setup_safe_profiles(name, path, *message)`**
|
|
||||||
Returns a post_setting dictionary that contains all of the information about a single **safe** profile.
|
|
||||||
|
Reference in New Issue
Block a user