This bot is used for one and only task - post pictures from my personal archive.
Go to file
Renovate c99f22b1b8 Update dependency pillow to ~=10.3.0 (#76)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [pillow](https://github.com/python-pillow/Pillow) ([changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)) | minor | `~=10.2.0` -> `~=10.3.0` |

---

### Release Notes

<details>
<summary>python-pillow/Pillow (pillow)</summary>

### [`v10.3.0`](https://github.com/python-pillow/Pillow/blob/HEAD/CHANGES.rst#1030-2024-04-01)

[Compare Source](https://github.com/python-pillow/Pillow/compare/10.2.0...10.3.0)

-   CVE-2024-28219: Use `strncpy` to avoid buffer overflow [#&#8203;7928](https://github.com/python-pillow/Pillow/issues/7928)
    \[radarhere, hugovk]

-   Deprecate `eval()`, replacing it with `lambda_eval()` and `unsafe_eval()` [#&#8203;7927](https://github.com/python-pillow/Pillow/issues/7927)
    \[radarhere, hugovk]

-   Raise `ValueError` if seeking to greater than offset-sized integer in TIFF [#&#8203;7883](https://github.com/python-pillow/Pillow/issues/7883)
    \[radarhere]

-   Add `--report` argument to `__main__.py` to omit supported formats [#&#8203;7818](https://github.com/python-pillow/Pillow/issues/7818)
    \[nulano, radarhere, hugovk]

-   Added RGB to I;16, I;16L, I;16B and I;16N conversion [#&#8203;7918](https://github.com/python-pillow/Pillow/issues/7918), [#&#8203;7920](https://github.com/python-pillow/Pillow/issues/7920)
    \[radarhere]

-   Fix editable installation with custom build backend and configuration options [#&#8203;7658](https://github.com/python-pillow/Pillow/issues/7658)
    \[nulano, radarhere]

-   Fix putdata() for I;16N on big-endian [#&#8203;7209](https://github.com/python-pillow/Pillow/issues/7209)
    \[Yay295, hugovk, radarhere]

-   Determine MPO size from markers, not EXIF data [#&#8203;7884](https://github.com/python-pillow/Pillow/issues/7884)
    \[radarhere]

-   Improved conversion from RGB to RGBa, LA and La [#&#8203;7888](https://github.com/python-pillow/Pillow/issues/7888)
    \[radarhere]

-   Support FITS images with GZIP\_1 compression [#&#8203;7894](https://github.com/python-pillow/Pillow/issues/7894)
    \[radarhere]

-   Use I;16 mode for 9-bit JPEG 2000 images [#&#8203;7900](https://github.com/python-pillow/Pillow/issues/7900)
    \[scaramallion, radarhere]

-   Raise ValueError if kmeans is negative [#&#8203;7891](https://github.com/python-pillow/Pillow/issues/7891)
    \[radarhere]

-   Remove TIFF tag OSUBFILETYPE when saving using libtiff [#&#8203;7893](https://github.com/python-pillow/Pillow/issues/7893)
    \[radarhere]

-   Raise ValueError for negative values when loading P1-P3 PPM images [#&#8203;7882](https://github.com/python-pillow/Pillow/issues/7882)
    \[radarhere]

-   Added reading of JPEG2000 palettes [#&#8203;7870](https://github.com/python-pillow/Pillow/issues/7870)
    \[radarhere]

-   Added alpha_quality argument when saving WebP images [#&#8203;7872](https://github.com/python-pillow/Pillow/issues/7872)
    \[radarhere]

-   Fixed joined corners for ImageDraw rounded_rectangle() non-integer dimensions [#&#8203;7881](https://github.com/python-pillow/Pillow/issues/7881)
    \[radarhere]

-   Stop reading EPS image at EOF marker [#&#8203;7753](https://github.com/python-pillow/Pillow/issues/7753)
    \[radarhere]

-   PSD layer co-ordinates may be negative [#&#8203;7706](https://github.com/python-pillow/Pillow/issues/7706)
    \[radarhere]

-   Use subprocess with CREATE_NO_WINDOW flag in ImageShow WindowsViewer [#&#8203;7791](https://github.com/python-pillow/Pillow/issues/7791)
    \[radarhere]

-   When saving GIF frame that restores to background color, do not fill identical pixels [#&#8203;7788](https://github.com/python-pillow/Pillow/issues/7788)
    \[radarhere]

-   Fixed reading PNG iCCP compression method [#&#8203;7823](https://github.com/python-pillow/Pillow/issues/7823)
    \[radarhere]

-   Allow writing IFDRational to UNDEFINED tag [#&#8203;7840](https://github.com/python-pillow/Pillow/issues/7840)
    \[radarhere]

-   Fix logged tag name when loading Exif data [#&#8203;7842](https://github.com/python-pillow/Pillow/issues/7842)
    \[radarhere]

-   Use maximum frame size in IHDR chunk when saving APNG images [#&#8203;7821](https://github.com/python-pillow/Pillow/issues/7821)
    \[radarhere]

-   Prevent opening P TGA images without a palette [#&#8203;7797](https://github.com/python-pillow/Pillow/issues/7797)
    \[radarhere]

-   Use palette when loading ICO images [#&#8203;7798](https://github.com/python-pillow/Pillow/issues/7798)
    \[radarhere]

-   Use consistent arguments for load_read and load_seek [#&#8203;7713](https://github.com/python-pillow/Pillow/issues/7713)
    \[radarhere]

-   Turn off nullability warnings for macOS SDK [#&#8203;7827](https://github.com/python-pillow/Pillow/issues/7827)
    \[radarhere]

-   Fix shift-sign issue in Convert.c [#&#8203;7838](https://github.com/python-pillow/Pillow/issues/7838)
    \[r-barnes, radarhere]

-   Open 16-bit grayscale PNGs as I;16 [#&#8203;7849](https://github.com/python-pillow/Pillow/issues/7849)
    \[radarhere]

-   Handle truncated chunks at the end of PNG images [#&#8203;7709](https://github.com/python-pillow/Pillow/issues/7709)
    \[lajiyuan, radarhere]

-   Match mask size to pasted image size in GifImagePlugin [#&#8203;7779](https://github.com/python-pillow/Pillow/issues/7779)
    \[radarhere]

-   Release GIL while calling `WebPAnimDecoderGetNext` [#&#8203;7782](https://github.com/python-pillow/Pillow/issues/7782)
    \[evanmiller, radarhere]

-   Fixed reading FLI/FLC images with a prefix chunk [#&#8203;7804](https://github.com/python-pillow/Pillow/issues/7804)
    \[twolife]

-   Update wl-paste handling and return None for some errors in grabclipboard() on Linux [#&#8203;7745](https://github.com/python-pillow/Pillow/issues/7745)
    \[nik012003, radarhere]

-   Remove execute bit from `setup.py` [#&#8203;7760](https://github.com/python-pillow/Pillow/issues/7760)
    \[hugovk]

-   Do not support using test-image-results to upload images after test failures [#&#8203;7739](https://github.com/python-pillow/Pillow/issues/7739)
    \[radarhere]

-   Changed ImageMath.ops to be static [#&#8203;7721](https://github.com/python-pillow/Pillow/issues/7721)
    \[radarhere]

-   Fix APNG info after seeking backwards more than twice [#&#8203;7701](https://github.com/python-pillow/Pillow/issues/7701)
    \[esoma, radarhere]

-   Deprecate ImageCms constants and versions() function [#&#8203;7702](https://github.com/python-pillow/Pillow/issues/7702)
    \[nulano, radarhere]

-   Added PerspectiveTransform [#&#8203;7699](https://github.com/python-pillow/Pillow/issues/7699)
    \[radarhere]

-   Add support for reading and writing grayscale PFM images [#&#8203;7696](https://github.com/python-pillow/Pillow/issues/7696)
    \[nulano, hugovk]

-   Add LCMS2 flags to ImageCms [#&#8203;7676](https://github.com/python-pillow/Pillow/issues/7676)
    \[nulano, radarhere, hugovk]

-   Rename x64 to AMD64 in winbuild [#&#8203;7693](https://github.com/python-pillow/Pillow/issues/7693)
    \[nulano]

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6ImRldiJ9-->

Reviewed-on: #76
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-04-02 15:09:37 +03:00
classes Update dependency photosapi_client to v0.6.0 (#75) 2024-03-19 23:25:03 +02:00
docs Updates wiki init 2023-03-22 11:02:13 +01:00
locale Locale for console is gone for good 2023-07-03 11:42:28 +02:00
modules Update dependency photosapi_client to v0.6.0 (#75) 2024-03-19 23:25:03 +02:00
plugins Update dependency photosapi_client to v0.6.0 (#75) 2024-03-19 23:25:03 +02:00
.gitignore Update dependency photosapi_client to v0.6.0 (#75) 2024-03-19 23:25:03 +02:00
.renovaterc Fixed branch name in Renovate config 2023-04-20 13:35:52 +02:00
LICENSE Initial commit 2022-08-08 14:53:26 +02:00
README.md Updated README 2023-07-03 12:34:55 +02:00
README_uk.md Updated README 2023-07-03 12:34:55 +02:00
config_example.json Attempt to work around #40 2023-08-16 13:20:25 +02:00
loop.bat Starting scripts and README were updated 2023-06-28 08:22:18 +02:00
loop.sh Starting scripts and README were updated 2023-06-28 08:22:18 +02:00
main.py CLI is back and updated 2023-07-03 11:27:15 +02:00
requirements.txt Update dependency pillow to ~=10.3.0 (#76) 2024-04-02 15:09:37 +03:00
start.bat Starting scripts and README were updated 2023-06-28 08:22:18 +02:00
start.sh Starting scripts and README were updated 2023-06-28 08:22:18 +02:00

README.md

TelegramPoster

License: GPL Code style: black

Шукаєш інструкцію українською? А вона ось тут знаходиться)

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

Use MongoDB's installation manual and Photos API's README.

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, Photos API, MongoDB and optionally git (if you want to update using git pull). 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-standard executable path - you should also change it in scripts you will use (loop.sh, loop.bat, start.sh and start.bat).

  1. Install MongoDB and Photos API:

    1. Install MongoDB by following official installation manual
    2. Install Photos API by following Photos API's README
  2. Download the bot:

    1. git clone -b dev https://git.end-play.xyz/profitroll/TelegramPoster.git (if you're using git)
    2. cd TelegramPoster
  3. Create virtual environment [Optional]:

    1. Install virtualenv module: pip install virtualenv
    2. Create venv: python -m venv .venv
    3. Activate it using source .venv/bin/activate on Linux, .venv\Scripts\activate.bat in CMD or .venv\Scripts\Activate.ps1 in PowerShell.
  4. Install project's dependencies:

    python -m pip install -r requirements.txt
    Without installing those - bot cannot work at all.

  5. Configure required keys with your favorite text editor:

    1. Copy config file: cp config_example.json config.json
    2. Open config.json using your favorite text editor. For example nano config.json, but you can also edit it with vim, mcedit, or Notepad/Notepad++ on Windows
    3. Change "bot.owner", "bot.api_id", "bot.api_hash" and "bot.bot_token" keys' values.

    If you don't know where to find bot_token and your id - here you can find some hints: get bot token, get your id, get api_hash and api_id.

  6. Configure database and API:

    1. Configure database:

      1. Change database host and port in keys "database.host" and "database.port". For default local installation those will be 127.0.0.1 and 27017 respectively
      2. Change database name to the one you like in "database.name". It will be automatically created on start
      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:

      1. Change "posting.api.address" and "posting.api.address_external" to the ones your API server uses
      2. Run your bot using python main.py --create-user --create-album to configure its new user and album. You can also use manual user and album creation described in the wiki. You can also change username, password and album in"posting.api" to the user and album you have if you already have Photos API album and user set up. In that case you don't need to create a new one.
  7. Add bot to the channel:

    To use your bot of course you need to have a channel or group otherwise it makes no sense to have such a bot. Here 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 and "posting.comments" to comments group's ID.

  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 the bot.
    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 /shutdown 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 to get more detailed instructions.

CLI arguments

Of course bot also has them. You can perform some actions with them.

  • --create-user - create new API user. Requires config key "posting.api.address" to be set;
  • --create-album - create new API album. Requires API address and user config ("posting.api") to be complete.

Examples:

  • python main.py --create-user
  • python main.py --create-user --create-album

Tips and improvements

  • You may want to configure your bot to work as a systemd service instead. There's a tutorial for that in the wiki.

Localization

Bot is capable of using custom locales. There are some that are pre-installed (English and Ukrainian), however you can add your own locales too.

All localization files are located in the locale. Just copy locale file of your choice, name it in accordance to IETF language tags (if you want your locale to be compatible with Telegram's locales) or define your own name. Save it as json and you're good to go. If you want to change default locale for messages - edit "locale" parameter in the config.json.

We recommend to only make changes to your custom locale. Or at least always have your backup of for example en.json as your fallback.