Skip to main content

A Telegram bot that interfaces with a self-hosted Readeck instance to manage bookmarks.

Project description

A Telegram bot that interfaces with a self-hosted Readeck instance to manage bookmarks. It's based on the python-telegram-bot framework.

Features:

  • /register (create a new user) or /token to register the bot with an existent user
  • Save bookmarks by sending a URL (with optional title and tags).
  • Read. Create a simplified version of the article in telegra.ph
  • /md_ return the raw markdown
  • /list . unread articles
  • /epub generate an epub with the unread articles
  • /version show the current bot version
  • /restart restart the bot process (for upgrades, requires systemd or similar process manager)

Setup a development environment

1. Clone the bot repository

git clone https://github.com/mgaitan/readeckbot.git
cd readeckbot

2. Download the Readeck binary

Download the appropriate binary for your system from the official site: https://readeck.org/en/download

Place the readeck binary in the same directory as the bot code.

3. Start the Readeck API server in a console

Open a terminal and run

./readeck serve

or readeck.exe serve on Windows

This will start the Readeck backend on http://127.0.0.1:8000 by default.

4. Set up your environment variables

Create a file named .env in the project root. This file stores config variables used by the bot.

TELEGRAM_BOT_TOKEN=<your_bot_token>
READECK_BASE_URL=http://127.0.0.1:8000
READECK_CONFIG=./config.yaml      # optional, can be left out
READECK_DATA=./data               # optional, use if you want to customize where data is stored

LLM_KEY=<your_llm_key>           # optional, use if you want to enable LLM features
LLM_MODEL=<model_name>           # optional, by default it's gemini-2.0-flash-lite
LLM_SUMMARY_MAX_LENGTH=<int>     # optional , use if you want to customize the max length of LLM summary

📄 What’s a .env file? It's a simple file format for storing key=value pairs, that are loaded as environment variables by apps.

[!IMPORTANT] Keep in mind that, initially, we will be working with two different 'tokens'.

On one hand, there's the one we set in the .env file for the Telegram bot; on the other, there's the authentication token specific to Readeck. If you’re having issues when trying to use /register, it’s likely that you're missing the latter.

An easy way to resolve this is by going to the URL where you're hosting Readeck, then navigating to Settings → API. There you can generate the authentication token and then use it in the Telegram chat with the command /token <your_readeck_token>.

5. Get your own Telegram bot token

To connect your bot to Telegram, you’ll need to create a bot and get its API token.

  • Open Telegram and message @BotFather
  • Run /newbot and follow the prompts.
  • Copy the token it gives you and paste it into your .env file under TELEGRAM_BOT_TOKEN

More info: https://core.telegram.org/bots#creating-a-new-bot

6. Run the bot in development mode

This project uses uv, a fast Python package manager and runner.

Don't have it yet? Install it from here: https://github.com/astral-sh/uv#installation

Then in another terminal run the bot:

uv run --extra llm readeckbot

The first time it will install Python and the depenencies as needed and can take a bit, but that’s it!

You can now start chatting with your bot on Telegram using your own token.

Special commands for bot management

  • /version — Replies with the current version of the bot (from the code).
  • /restart — Restarts the bot process. This is useful for upgrades: if you run the bot under systemd (or similar), it will be relaunched and pick up the latest version (for example, if you use uvx to always run the latest code).
    Note: You may want to restrict this command to admin users in production.

Happy hacking and happy reading! 📚🤖

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readeckbot-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

readeckbot-0.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file readeckbot-0.1.1.tar.gz.

File metadata

  • Download URL: readeckbot-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for readeckbot-0.1.1.tar.gz
Algorithm Hash digest
SHA256 297fd069c2f90ed00631aa5b5f3a4587be22cba539fa2d34f58b10bf4c922f5f
MD5 4678cb75deb9177666f41fda8c268e77
BLAKE2b-256 6eeffee231b93920f446ee7e175841b7e3ed501993f0e18d57f6b479e9baa15e

See more details on using hashes here.

Provenance

The following attestation bundles were made for readeckbot-0.1.1.tar.gz:

Publisher: cd.yml on mgaitan/readeckbot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file readeckbot-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: readeckbot-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for readeckbot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9af10bc7d017ce0c65e2af47595146602c0a396ccc0e5c9d715abe7ff049ce8
MD5 c7288c7626c21e1027f42dcb877ca355
BLAKE2b-256 d1079cf04f7e3529ad59da7fdf6b15ed7b92a66bfee39582453a9ff7109581e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for readeckbot-0.1.1-py3-none-any.whl:

Publisher: cd.yml on mgaitan/readeckbot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page