This bot is used for one and only task - post pictures from my personal archive.
This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Renovate c38d79afe1 Update dependency pillow to ~=10.4.0 (#82)
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.3.0` -> `~=10.4.0` |

---

### Release Notes

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

### [`v10.4.0`](https://github.com/python-pillow/Pillow/blob/HEAD/CHANGES.rst#1040-2024-07-01)

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

-   Raise FileNotFoundError if show_file() path does not exist [#&#8203;8178](https://github.com/python-pillow/Pillow/issues/8178)
    \[radarhere]

-   Improved reading 16-bit TGA images with colour [#&#8203;7965](https://github.com/python-pillow/Pillow/issues/7965)
    \[Yay295, radarhere]

-   Deprecate non-image ImageCms modes [#&#8203;8031](https://github.com/python-pillow/Pillow/issues/8031)
    \[radarhere]

-   Fixed processing multiple JPEG EXIF markers [#&#8203;8127](https://github.com/python-pillow/Pillow/issues/8127)
    \[radarhere]

-   Do not preserve EXIFIFD tag by default when saving TIFF images [#&#8203;8110](https://github.com/python-pillow/Pillow/issues/8110)
    \[radarhere]

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

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

-   Remove zero-byte end padding when parsing any XMP data [#&#8203;8171](https://github.com/python-pillow/Pillow/issues/8171)
    \[radarhere]

-   Do not detect Ultra HDR images as MPO [#&#8203;8056](https://github.com/python-pillow/Pillow/issues/8056)
    \[radarhere]

-   Raise SyntaxError specific to JP2 [#&#8203;8146](https://github.com/python-pillow/Pillow/issues/8146)
    \[Yay295, radarhere]

-   Do not use first frame duration for other frames when saving APNG images [#&#8203;8104](https://github.com/python-pillow/Pillow/issues/8104)
    \[radarhere]

-   Consider I;16 pixel size when using a 1 mode mask [#&#8203;8112](https://github.com/python-pillow/Pillow/issues/8112)
    \[radarhere]

-   When saving multiple PNG frames, convert to mode rather than raw mode [#&#8203;8087](https://github.com/python-pillow/Pillow/issues/8087)
    \[radarhere]

-   Added byte support to FreeTypeFont [#&#8203;8141](https://github.com/python-pillow/Pillow/issues/8141)
    \[radarhere]

-   Allow float center for rotate operations [#&#8203;8114](https://github.com/python-pillow/Pillow/issues/8114)
    \[radarhere]

-   Do not read layers immediately when opening PSD images [#&#8203;8039](https://github.com/python-pillow/Pillow/issues/8039)
    \[radarhere]

-   Restore original thread state [#&#8203;8065](https://github.com/python-pillow/Pillow/issues/8065)
    \[radarhere]

-   Read IM and TIFF images as RGB, rather than RGBX [#&#8203;7997](https://github.com/python-pillow/Pillow/issues/7997)
    \[radarhere]

-   Only preserve TIFF IPTC_NAA_CHUNK tag if type is BYTE or UNDEFINED [#&#8203;7948](https://github.com/python-pillow/Pillow/issues/7948)
    \[radarhere]

-   Clarify ImageDraw2 error message when size is missing [#&#8203;8165](https://github.com/python-pillow/Pillow/issues/8165)
    \[radarhere]

-   Support unpacking more rawmodes to RGBA palettes [#&#8203;7966](https://github.com/python-pillow/Pillow/issues/7966)
    \[radarhere]

-   Removed support for Qt 5 [#&#8203;8159](https://github.com/python-pillow/Pillow/issues/8159)
    \[radarhere]

-   Improve `ImageFont.freetype` support for XDG directories on Linux [#&#8203;8135](https://github.com/python-pillow/Pillow/issues/8135)
    \[mamg22, radarhere]

-   Improved consistency of XMP handling [#&#8203;8069](https://github.com/python-pillow/Pillow/issues/8069)
    \[radarhere]

-   Use pkg-config to help find libwebp and raqm [#&#8203;8142](https://github.com/python-pillow/Pillow/issues/8142)
    \[radarhere]

-   Accept 't' suffix for libtiff version [#&#8203;8126](https://github.com/python-pillow/Pillow/issues/8126), [#&#8203;8129](https://github.com/python-pillow/Pillow/issues/8129)
    \[radarhere]

-   Deprecate ImageDraw.getdraw hints parameter [#&#8203;8124](https://github.com/python-pillow/Pillow/issues/8124)
    \[radarhere, hugovk]

-   Added ImageDraw circle() [#&#8203;8085](https://github.com/python-pillow/Pillow/issues/8085)
    \[void4, hugovk, radarhere]

-   Add mypy target to Makefile [#&#8203;8077](https://github.com/python-pillow/Pillow/issues/8077)
    \[Yay295]

-   Added more modes to Image.MODES [#&#8203;7984](https://github.com/python-pillow/Pillow/issues/7984)
    \[radarhere]

-   Deprecate BGR;15, BGR;16 and BGR;24 modes [#&#8203;7978](https://github.com/python-pillow/Pillow/issues/7978)
    \[radarhere, hugovk]

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

-   Support reading P mode TIFF images with padding [#&#8203;7996](https://github.com/python-pillow/Pillow/issues/7996)
    \[radarhere]

-   Deprecate support for libtiff < 4 [#&#8203;7998](https://github.com/python-pillow/Pillow/issues/7998)
    \[radarhere, hugovk]

-   Corrected ImageShow UnixViewer command [#&#8203;7987](https://github.com/python-pillow/Pillow/issues/7987)
    \[radarhere]

-   Use functools.cached_property in ImageStat [#&#8203;7952](https://github.com/python-pillow/Pillow/issues/7952)
    \[nulano, hugovk, radarhere]

-   Add support for reading BITMAPV2INFOHEADER and BITMAPV3INFOHEADER [#&#8203;7956](https://github.com/python-pillow/Pillow/issues/7956)
    \[Cirras, radarhere]

-   Support reading CMYK JPEG2000 images [#&#8203;7947](https://github.com/python-pillow/Pillow/issues/7947)
    \[radarhere]

</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: #82
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-07-02 00:55:50 +03:00
classes Fixed caption being added explicitly 2024-04-30 20:57:51 +02:00
docs Updates wiki init 2023-03-22 11:02:13 +01:00
locale Fixed deletion not working properly 2024-05-06 12:47:09 +02:00
modules Update dependency photosapi_client to v0.6.0 (#75) 2024-03-19 23:25:03 +02:00
plugins Fixed deletion not working properly 2024-05-06 12:47:09 +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
config_example.json Attempt to work around #40 2023-08-16 13:20:25 +02:00
LICENSE Initial commit 2022-08-08 14:53:26 +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
README_uk.md Updated README 2023-07-03 12:34:55 +02:00
README.md Updated README 2023-07-03 12:34:55 +02:00
requirements.txt Update dependency pillow to ~=10.4.0 (#82) 2024-07-02 00:55:50 +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

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.