WIP: New readme

This commit is contained in:
Profitroll 2023-03-12 19:25:35 +01:00
parent 0073120bf2
commit ad281ba981
1 changed files with 38 additions and 16 deletions

View File

@ -1,50 +1,72 @@
<h1 align="center">TelegramPoster</h1>
<p align="center">
<a href="https://git.end-play.xyz/profitroll/TelegramPoster/src/branch/master/LICENSE"><img alt="License: GPL" src="https://img.shields.io/badge/License-GPL-blue"></a>
<a href="https://git.end-play.xyz/profitroll/TelegramPoster/src/branch/dev/LICENSE"><img alt="License: GPL" src="https://img.shields.io/badge/License-GPL-blue"></a>
<a href="https://git.end-play.xyz/profitroll/TelegramPoster"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>
> Шукаєш інструкцію українською? А вона [ось тут](https://git.end-play.xyz/profitroll/TelegramPoster/src/branch/master/README_uk.md) знаходиться)
> Шукаєш інструкцію українською? А вона [ось тут](https://git.end-play.xyz/profitroll/TelegramPoster/src/branch/dev/README_uk.md) знаходиться)
This bot is used for one and only task - post pictures from my personal archive. Here's its source code so you can also host a bot and have fun with it. Just don't exepect it to be brilliant. It is not. But hey, you can always fork it ;)
## Dependencies
For now bot requires MongoDB and [PhotosAPI](https://git.end-play.xyz/profitroll/PhotosAPI) in order to function properly. Use [MongoDB's installation manual](https://www.mongodb.com/docs/manual/installation/) and [Photos API's README](https://git.end-play.xyz/profitroll/PhotosAPI/src/branch/master/README.md) to install install them.
Please note that Photos API also requires MongoDB so it makes sense to install and configure Mongo first.
## Installation
To make this bot run at first you need to have a Python interpreter and git. Google is your friend finding it. You can also ignore git and simply download source code, should also work fine. After that you're ready to go.
To make this bot run at first you need to have a Python interpreter, Photos API, MongoDB and optionally git. You can also ignore git and simply download source code, should also work fine. After that you're ready to go.
> In this README I assume that you're using default python in your
> system and your system's PATH contains it. If your default python
> is `python3` or for example `/home/user/.local/bin/python3.9` - use it instead.
> If it's non-standart executable path - you should also change
> If it's non-standard executable path - you should also change
> it in scripts you will use (`loop.sh`, `loop.bat`, `start.sh` and `start.bat`).
1. Download the bot:
1. `git clone https://git.end-play.xyz/profitroll/TelegramSender.git` (if you want to use git)
1. Install Mongo and Photos API:
1. Install MongoDB by following [official installation manual](https://www.mongodb.com/docs/manual/installation/)
2. Install Photos API by following [Photos API's README](https://git.end-play.xyz/profitroll/PhotosAPI/src/branch/master/README.md)
2. Download the bot:
1. `git clone -b dev https://git.end-play.xyz/profitroll/TelegramSender.git` (if you want to use git)
2. `cd ./TelegramSender`
2. Install dependencies:
3. Install project's dependencies:
`python -m pip install -r requirements.txt`
Without installing those - bot cannot work at all
3. Install optional dependencies [Not required]:
4. Install optional dependencies [Not required]:
`python -m pip install -r requirements-optional.txt`
These are not required but can make the bot run a bit faster
4. Configure your bot with a favorite text editor:
5. Configure your bot with a favorite text editor:
`nano config.json`
You can edit with vim, nano, on Windows it's Notepad or Notepad++. Whatever.
If you don't know where to find bot_token and your id - here you can find some hints: [get bot token](https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token), [get your id](https://www.alphr.com/telegram-find-user-id/), [get api_hash and api_id](https://core.telegram.org/api/obtaining_api_id).
Also don't forget to change bot's working mode. Dict key `"mode"` contains keys `"post"` and `"submit"`, each of those can be either `true` or `false`.
5. Add bot to the channel:
To use your bot of course you need to have a channel or group otherwise makes no sense to have such a bot. [Here](https://stackoverflow.com/a/33497769) you can find a quick guide how to add your bot to a channel.
6. Configure database and API:
1. Configure database:
1. Change database host and port in keys `"database.host"` and `"database.port"`;
2. Change database name to the one you like in `"database.name"`;
3. If you've changed user and password to access the db you should also change `"database.user"` and `"database.password"` keys, otherwise leave it `null`.
2. Configure Photos API:
1. Register new user using POST /users request on the page "docs#/default/user_create_users_post" of the API. Please make sure you're using a valid email address if you've configured you API to use email confirmation;
2. If you have email confirmation - activate your new user by using "docs#/default/user_confirm_users__user__confirm_patch" page of the docs or by using the link from the email;
3. Now create a new album for your bot using your user. Click "Authorize" on the docs page of your API, enter your login and password, select "select all" in scopes section and click "Authorize". Now you can execute requests as your user;
4. Go to POST /albums (/docs#/default/album_create_albums_post) and create a friendly name for your album. No worries, it will be only used internally by the bot;
5. Now you can configure your bot to use all of that. Change key `"posting.api.address"` to the http/https address accessible by the bot. Avoid using external address without a reason if API and the bot are on the same machine. If you want to see duplicates from the outside you can also change `"posting.api.address_external"` to the one accessible from the internet;
6. Configure API user/password and your album name using `"posting.api.username"`, `"posting.api.password"` and `"posting.api.album"` keys.
6. Fill your contents folder:
Of course bot cannot post something from nothing. Configure your `config.json` what media types bot should post (`"posting", "extensions"`), when to post them (`"posting", "time"`) and also where to find them (`"locations"`). You can also move them when sent by setting `"posting", "move_sent"` to `true`.
7. Add bot to the channel:
To use your bot of course you need to have a channel or group otherwise makes no sense to have such a bot. [Here](https://stackoverflow.com/a/33497769) you can find a quick guide how to add your bot to a channel. After that simply set `"posting.channel"` to your channel's ID.
6. Good to go, run it!
`python ./main.py`
8. Configure posting time:
To make your bot post random content you need to configure `"posting.time"` with a list of "DD:MM" formatted strings or use `"posting.interval"` formatted as "XdXhXmXs". To use interval instead of selected time set `"posting.use_interval"` to `true`.
9. Good to go, run it!
Make sure MongoDB and Photos API are running and use `python ./main.py` to start it.
Or you can also use `.\start.bat` on Windows and `bash ./start.sh` on Linux.
Additionally there are `loop.sh` and `loop.bat` available if you want your bot to start again after being stopped or after using `/reboot` command.