dev #19

Merged
profitroll merged 98 commits from dev into master 2023-04-24 13:48:22 +03:00
Showing only changes of commit 48acab2d5e - Show all commits

View File

@ -11,7 +11,7 @@ This bot is used for one and only task - post pictures from my personal archive.
## Dependencies ## 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. For now bot requires [MongoDB](https://www.mongodb.com) 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. Please note that Photos API also requires MongoDB so it makes sense to install and configure Mongo first.
@ -26,7 +26,7 @@ To make this bot run at first you need to have a Python interpreter, Photos API,
> it in scripts you will use (`loop.sh`, `loop.bat`, `start.sh` and `start.bat`). > it in scripts you will use (`loop.sh`, `loop.bat`, `start.sh` and `start.bat`).
1. Install Mongo and Photos API: 1. Install Mongo and Photos API:
1. Install MongoDB by following [official installation manual](https://www.mongodb.com/docs/manual/installation/) 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. 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: 2. Download the bot:
@ -44,20 +44,22 @@ To make this bot run at first you need to have a Python interpreter, Photos API,
5. Configure your bot with a favorite text editor: 5. Configure your bot with a favorite text editor:
`nano config.json` `nano config.json`
You can edit with vim, nano, on Windows it's Notepad or Notepad++. Whatever. 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). 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).
6. Configure database and API: 6. Configure database and API:
1. Configure database: 1. Configure database:
1. Change database host and port in keys `"database.host"` and `"database.port"`; 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"`; 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`. 3. If you've changed user and password to access the db you should also change `"database.user"` and `"database.password"` keys, otherwise leave them `null` (default).
2. Configure Photos API: 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; 1. Create new user and album
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; 1. Register new user using API's `POST /users` request (`/docs#/default/user_create_users_post`). 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 `PATCH /users/{user}/confirm` (`/docs#/default/user_confirm_users__user__confirm_patch`) 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; 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; 4. Go to `POST /albums` (`docs#/default/album_create_albums_post`) and create a friendly name for your album. No worries, only bot can see it so it doesn't matter what name you use;
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; 2. Configure bot to use that album
6. Configure API user/password and your album name using `"posting.api.username"`, `"posting.api.password"` and `"posting.api.album"` keys. 1. 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;
2. Configure API user/password and your album name using `"posting.api.username"`, `"posting.api.password"` and `"posting.api.album"` keys.
7. Add bot to the channel: 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. 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.
@ -70,6 +72,8 @@ To make this bot run at first you need to have a Python interpreter, Photos API,
Or you can also use `.\start.bat` on Windows and `bash ./start.sh` on Linux. 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. 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.
If you need any further instructions on how to configure your bot or you had any difficulties doing so - please use [wiki in this repository](https://git.end-play.xyz/profitroll/TelegramPoster/wiki) to get more detailed instructions.
## Command line arguments ## Command line arguments
Of course bot also has them. You can perform some actions with them. Of course bot also has them. You can perform some actions with them.