Telegram userbot for scheduling image posts from e926.net.
Other dependencies are handled inside docker image.
Default config 1
class Anything:
def __eq__(self, _):
return True
DEFAULT = {
"peer": "me",
"tags": "order:score meme",
"post": "preview",
"no_sample": "skip",
"use_last_id": False,
"start_id": Anything(),
"end_id": -1,
"start_page": 1,
"end_page": 1,
"schedule_limit": 10,
"blacklist": [
"rating:e",
"rating:q"
],
"schedule": [
"12:00:00"
],
"time_tolerance": 60,
"reversed": False
}
Argument name | Type | Acceptable values | Explanation |
---|---|---|---|
peer |
str |
String without spaces | Username of peer to whom bot will send the posts2 |
tags |
str |
String with valid tags separated by spaces | String that represents a search on e9263. If you want to send favourites in the order they were added, specify fav:!{user_id} as the only tag. |
post |
str |
"sample" , "preview" or "link" |
Specifies format for sending posts. "sample" will send photo with link as caption, "preview" will use internal Telegram preview and "link" will send link without preview |
no_sample |
str |
"skip" , "preview" or "link" |
Specifies fallback option if there is no sample for this post. Same meaning as values in post . Will be ignored if post is not "sample" |
use_last_id |
bool |
true or false |
Starts with the last ID from the previous planning if true |
start_id |
int |
Integer representing post ID | Ignores all posts until this ID is encountered |
end_id |
int |
Integer representing post ID | Schedules all posts until this ID is encountered (-1 means to schedule all posts until end_page is reached) |
end_page |
int |
Integer from 1 to 7504 representing page number | Ignores all posts until this page is reached (not accurate, take a page before the one you want to start with, and fine-tune with start_id ) |
start_page |
int |
Integer from 1 to 7504 representing page number | Schedules all posts until this page is reached (not accurate, take a page after the one you want to end with, and fine-tune with end_id ) |
schedule_limit |
int |
Integer from 1 to 100 5 | Maximum numbers of scheduled messages (includes those already scheduled) |
blacklist |
list[str] |
List of strings with valid tags separated by spaces | Same as blacklist on e926.net with some minor changes |
schedule |
str |
String representing time in format HH:MM:SS | Daily posting schedule |
time_tolerance |
int |
Integer from 0 to 3600*24 6 representing seconds | Tolerance for detecting already scheduled posts (Telegram clients tend to use current seconds by default when scheduling) |
reversed |
bool |
true or false |
Reverses the posts if true . This significantly slow down the scheduling, since all posts must be fetched before reversing |
You can validate config using validator.py.
python3 validator.py [config]
There are two ways to get an image:
- Build from source code
- Load exported image from the releases page
Clone the repository:
git clone https://github.com/G82ft/e926-2-tg.git
After that, configure the bot.
Finally, build the image:
cd e926-2-tg/
docker build . -t e926-2-tg
Download the image from the releases page. To load the image use:
docker load -i e926-2-tg_v1.2.tar
Default config will be provided in this image. The only way to change it is to attach to the container running this image.
docker exec -it <container> ash
When running, you must specify timezone and phone number (without any spaces/symbols) via environment variables.
docker run -e "TZ=Europe/London" -e "PHONE=1234567890" e926-2-tg
Also, you can specify LOG_LEVEL.
Schedule is represented by a list of strings in format HH:MM:SS. After the list is exhausted, the bot switches to the next day and starts over.
The bot checks daily if the schedule limit is reached. If not, it will add posts after the last scheduled one.
Blacklist is made by hand to support multiple entries. It works as one on e926.net, but tag syntax differs a bit.
It supports -
(not) operator, but does not support the ~
(or), *
(wildcard) and ...
(range) operators. 3
All tags in "tags"
can be written without any prefixes.
{
"id": 123456,
"created_at": "...",
"updated_at": "...",
"tags": {
"general": ["..."],
"artist": ["..."],
"copyright": ["..."],
"character": ["..."],
"species": ["..."],
"invalid": ["..."],
"meta": ["..."],
"lore": ["..."]
},
"change_seq": 123456,
"rating": "s",
"fav_count": 123456,
"approver_id": 123456,
"uploader_id": 123456,
"description": "...",
"comment_count": 123456,
"has_notes": false
}
Post-related tags like rating
must be written like this:
{
"blacklist": [
"key:value"
]
}
For example:
{
"blacklist": [
"-id:123456 fav_count:123456",
"approver_id:123456"
]
}
Logs are stored in app/logs/
. There are two files:
logs.csv
- contains all logs.no_sample.log
- contains posts without sample. It will log all posts without sample no matter what you specify inno_sample
config field (if you have specified to send posts with samples).
Footnotes
-
The configuration presented is written in Python, but the configuration file config.json is in JSON format.
Differences between Python code and JSON format:
- You can't use Anything() in JSON
- Bool literals (True, False) are written in lowercase (true, false) in JSON