Skip to content

Repository files navigation

ReadeckWiseBot 🤖

ReadeckWiseBot is a lightweight Go binary designed for a simple Readwise-like experience in Telegram. It randomly retrieves a user-defined number highlights (annotations) from a Readeck instance and forwards them to a Telegram channel or chat on a daily schedule.

Features

  • Random Discovery: Pulls a random highlight or highlights from the user’s collection.
  • Beautiful Formatting: Sends the highlights to Telegram in blockquotes, with direct links to Readeck articles.
  • Scheduled: Runs automatically at a predefined time every day.
  • Docker: Hardened, non-root Docker image with small resource footprint.
  • Resource Limits: The bot is restricted to limited resources, and uses paginated API calls to be as efficient and fast as possible, even with thousands of highlights.

Prerequisites

To use this bot, you will need:

  1. A Readeck Instance: Either self-hosted or the hosted version.
  2. Readeck API Token: Go to your Readeck profile -> API Tokens to generate one.
  3. Telegram Bot Token: Created via @BotFather.
  4. Telegram Chat ID: The ID of the channel or group where the bot will post.

Setup Guide

1. Create a Telegram Bot

  1. Message @BotFather on Telegram.
  2. Use the /newbot command and follow the instructions.
  3. Save the API Token provided.
  4. Add your bot as an Administrator to the channel or group you want to post to.

2. Get your Chat ID

The easiest way to get your chat ID is to:

  1. Post a test message in your channel/group.
  2. Forward that message to @userinfobot.
  3. It will reply with the unique ID (e.g., -100123456789 or 12345678).

Configuration

You can configure the bot using a config.yaml file in the project root:

readeck:
  url: "https://readeck.example.com/api"
  token: "your_readeck_token"

telegram:
  token: "your_telegram_bot_token"
  chat_id: -100123456789

bot:
  retrieve_count: 1
  schedule_time: "09:00" # HH:MM format

Environment Variables

Every setting can also be set via env variables making the config file unnecessary:

  • READECK_URL
  • READECK_TOKEN
  • TELEGRAM_TOKEN
  • TELEGRAM_CHAT_ID
  • BOT_SCHEDULE_TIME
  • RUN_ONCE (Set to true to trigger a highlight immediately on startup for testing)

How to Run

Using Docker Compose (Recommended)

  1. Create a docker-compose.yml:
services:
  readeckwisebot:
    image: ghcr.io/alanon202/readeckwisebot:main
    container_name: readeckwise-bot
    restart: always
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL
    read_only: true
    user: "1000:1000"
    environment:
      READECK_URL: ${READECK_URL}
      READECK_TOKEN: ${READECK_TOKEN}
      TELEGRAM_TOKEN: ${TELEGRAM_TOKEN}
      TELEGRAM_CHAT_ID: ${TELEGRAM_CHAT_ID}
      BOT_SCHEDULE_TIME: "09:00"
      BOT_RETRIEVE_COUNT: 1
    tmpfs:
      - /tmp
    volumes:
      - ./config.yaml:/app/config.yaml:ro
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthcheck"]
      interval: 120s
      timeout: 5s
      retries: 3
      start_period: 5s
    deploy:
      resources:
        limits:
          cpus: '0.10'
          memory: 64M
        reservations:
          memory: 16M
  1. Run it:
docker compose up -d

Running Locally

go run .

About

ReadeckWiseBot offers a Readwise-like experience. It randomly retrieves and scheldules a user-defined number of highlights (annotations) from a Readeck instance and forwards them to a Telegram chat.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages