This bot is used for one and only task - post pictures from my personal archive.
Go to file
Renovate 1c53476e37 Update dependency pillow to ~=10.2.0 (#73)
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.1.0` -> `~=10.2.0` |

---

### Release Notes

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

### [`v10.2.0`](https://github.com/python-pillow/Pillow/blob/HEAD/CHANGES.rst#1020-2024-01-02)

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

-   Add `keep_rgb` option when saving JPEG to prevent conversion of RGB colorspace [#&#8203;7553](https://github.com/python-pillow/Pillow/issues/7553)
    \[bgilbert, radarhere]

-   Trim glyph size in ImageFont.getmask() [#&#8203;7669](https://github.com/python-pillow/Pillow/issues/7669), [#&#8203;7672](https://github.com/python-pillow/Pillow/issues/7672)
    \[radarhere, nulano]

-   Deprecate IptcImagePlugin helpers [#&#8203;7664](https://github.com/python-pillow/Pillow/issues/7664)
    \[nulano, hugovk, radarhere]

-   Allow uncompressed TIFF images to be saved in chunks [#&#8203;7650](https://github.com/python-pillow/Pillow/issues/7650)
    \[radarhere]

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

-   Changed IPTC tile tuple to match other plugins [#&#8203;7661](https://github.com/python-pillow/Pillow/issues/7661)
    \[radarhere]

-   Do not assign new fp attribute when exiting context manager [#&#8203;7566](https://github.com/python-pillow/Pillow/issues/7566)
    \[radarhere]

-   Support arbitrary masks for uncompressed RGB DDS images [#&#8203;7589](https://github.com/python-pillow/Pillow/issues/7589)
    \[radarhere, akx]

-   Support setting ROWSPERSTRIP tag [#&#8203;7654](https://github.com/python-pillow/Pillow/issues/7654)
    \[radarhere]

-   Apply ImageFont.MAX_STRING_LENGTH to ImageFont.getmask() [#&#8203;7662](https://github.com/python-pillow/Pillow/issues/7662)
    \[radarhere]

-   Optimise `ImageColor` using `functools.lru_cache` [#&#8203;7657](https://github.com/python-pillow/Pillow/issues/7657)
    \[hugovk]

-   Restricted environment keys for ImageMath.eval() [#&#8203;7655](https://github.com/python-pillow/Pillow/issues/7655)
    \[wiredfool, radarhere]

-   Optimise `ImageMode.getmode` using `functools.lru_cache` [#&#8203;7641](https://github.com/python-pillow/Pillow/issues/7641)
    \[hugovk, radarhere]

-   Fix incorrect color blending for overlapping glyphs [#&#8203;7497](https://github.com/python-pillow/Pillow/issues/7497)
    \[ZachNagengast, nulano, radarhere]

-   Attempt memory mapping when tile args is a string [#&#8203;7565](https://github.com/python-pillow/Pillow/issues/7565)
    \[radarhere]

-   Fill identical pixels with transparency in subsequent frames when saving GIF [#&#8203;7568](https://github.com/python-pillow/Pillow/issues/7568)
    \[radarhere]

-   Corrected duration when combining multiple GIF frames into single frame [#&#8203;7521](https://github.com/python-pillow/Pillow/issues/7521)
    \[radarhere]

-   Handle disposing GIF background from outside palette [#&#8203;7515](https://github.com/python-pillow/Pillow/issues/7515)
    \[radarhere]

-   Seek past the data when skipping a PSD layer [#&#8203;7483](https://github.com/python-pillow/Pillow/issues/7483)
    \[radarhere]

-   Import plugins relative to the module [#&#8203;7576](https://github.com/python-pillow/Pillow/issues/7576)
    \[deliangyang, jaxx0n]

-   Translate encoder error codes to strings; deprecate `ImageFile.raise_oserror()` [#&#8203;7609](https://github.com/python-pillow/Pillow/issues/7609)
    \[bgilbert, radarhere]

-   Support reading BC4U and DX10 BC1 images [#&#8203;6486](https://github.com/python-pillow/Pillow/issues/6486)
    \[REDxEYE, radarhere, hugovk]

-   Optimize ImageStat.Stat.extrema [#&#8203;7593](https://github.com/python-pillow/Pillow/issues/7593)
    \[florath, radarhere]

-   Handle pathlib.Path in FreeTypeFont [#&#8203;7578](https://github.com/python-pillow/Pillow/issues/7578)
    \[radarhere, hugovk, nulano]

-   Added support for reading DX10 BC4 DDS images [#&#8203;7603](https://github.com/python-pillow/Pillow/issues/7603)
    \[sambvfx, radarhere]

-   Optimized ImageStat.Stat.count [#&#8203;7599](https://github.com/python-pillow/Pillow/issues/7599)
    \[florath]

-   Correct PDF palette size when saving [#&#8203;7555](https://github.com/python-pillow/Pillow/issues/7555)
    \[radarhere]

-   Fixed closing file pointer with olefile 0.47 [#&#8203;7594](https://github.com/python-pillow/Pillow/issues/7594)
    \[radarhere]

-   Raise ValueError when TrueType font size is not greater than zero [#&#8203;7584](https://github.com/python-pillow/Pillow/issues/7584), [#&#8203;7587](https://github.com/python-pillow/Pillow/issues/7587)
    \[akx, radarhere]

-   If absent, do not try to close fp when closing image [#&#8203;7557](https://github.com/python-pillow/Pillow/issues/7557)
    \[RaphaelVRossi, radarhere]

-   Allow configuring JPEG restart marker interval on save [#&#8203;7488](https://github.com/python-pillow/Pillow/issues/7488)
    \[bgilbert, radarhere]

-   Decrement reference count for PyObject [#&#8203;7549](https://github.com/python-pillow/Pillow/issues/7549)
    \[radarhere]

-   Implement `streamtype=1` option for tables-only JPEG encoding [#&#8203;7491](https://github.com/python-pillow/Pillow/issues/7491)
    \[bgilbert, radarhere]

-   If save_all PNG only has one frame, do not create animated image [#&#8203;7522](https://github.com/python-pillow/Pillow/issues/7522)
    \[radarhere]

-   Fixed frombytes() for images with a zero dimension [#&#8203;7493](https://github.com/python-pillow/Pillow/issues/7493)
    \[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: #73
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-01-02 13:12:31 +02:00
classes exp is now exc 2023-08-16 13:27:23 +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 Constant change due to #29 2023-10-16 05:50:32 +00:00
plugins Improved naming 2023-10-15 18:14:22 +02:00
.gitignore API usage overhaul (#27) 2023-06-28 00:57:30 +03: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.2.0 (#73) 2024-01-02 13:12:31 +02: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.