Skip to content

About

Telegram bot AI based on Argentina internet culture

Resources

Stars

4 stars

Watchers

1 watching

Forks

Repository files navigation

Respondedorbot

An AI Telegram bot with an Argentine personality.

It streams replies, remembers conversations, understands media, tracks markets, manages AI credits, and runs scheduled tasks.

Try it: t.me/respondedorbot

Features

  • Chat. AI chat with memory, web search, page reading (pages built by JavaScript load in headless Chromium), tools, and provider fallback.
  • Media. Transcribes audio or YouTube captions and describes images or GIFs.
  • YouTube summaries. Summarizes YouTube videos from their existing captions.
  • Conversation summaries. Catches you up on what the chat said.
  • Markets and data. Crypto, market, dollar, BCRA, weather, and Polymarket data.
  • Credits. Telegram Stars, AI credits, transfers, and charge history.
  • Scheduled tasks. Recurring or one-time.
  • Polls. Sends Telegram polls when asked, including from scheduled tasks, and reads back the votes and who voted.
  • Links and languages. Repairs supported links, reads what's behind a link in the message or the one it replies to (a tweet's text and photo, a page's title and picture), and handles localized Telegram commands.

🚀 Use

Telegram's / menu shows the same command names in every language, the first name in each row below. Only the descriptions follow the user's language. The other names still work.

Every command and alias also works with ! instead of /, for groups where a moderation bot deletes messages that start with /: !gm works like /gm and !prices BTC like /prices BTC. A message whose ! doesn't start a command stays an ordinary message. In groups with privacy mode on, Telegram only sends the bot ! messages that reply to it, unless the bot is an admin. The Telegram menu still shows /.

AI and media

Command Purpose
/ask, /pregunta, /che, /gordo Chat with AI
/resumen, /summary, /tldr Summarize the conversation
/transcribe, /transcript, /describe Transcribe audio or YouTube captions; describe images or GIFs

Data

Command Purpose
/p, /prices, /precios Crypto and traditional markets
/c, /cripto, /criptos, /crypto, /cryptos Crypto prices and conversions
/weather, /clima Current weather
/dolar, /dollar, /usd Dollar rates
/s, /accion, /acciones, /stock, /stocks Stock prices
/oil, /petroleo Oil prices
/elections, /eleccion Polymarket elections
/bcra, /variables BCRA variables
/devo, /rulo Arbitrage calculations
/powerlaw, /rainbow, /satoshi Bitcoin reference models

Bot tools

Command Purpose
/config, /settings Chat settings
/language, /idioma Language settings
/ignore, /unignore, /ignorar, /designorar, /vetar, /desvetar Group admins: reply to someone, or name them (pick them from the @ list, or type their @username), to make the bot ignore them in that group or stop ignoring them. While ignored, their scheduled tasks in that group don't run. /ban and /unban only count as /ban@bot, since moderation bots like Rose and GroupHelp answer the bare ones
/ignored, /ignorados, /vetados List who the bot ignores in the group
/limit, /limitar Group admins: reply to someone, or name them (pick them from the @ list, or type their @username), with how many AI messages per hour the group pays for them, or off to go back to the group limit. An admin can only be given more than the group limit
/limited, /limitados List who has their own limit in the group
/groupcharges, /gastosgrupo Group admins: who spent the group's own credits on AI, in the last day or up to 30 days (or AI_LEDGER_RETENTION_DAYS, if shorter)
/topup, /balance Add or check AI credits
/charges, /history, /gastos Credit history
/transfer Move credits to a group, or to someone by replying to them
/tarea, /task, /tareas, /tasks Manage scheduled tasks
/random, /convertbase, /command, /comando, /time Utilities
/gm, /gn, /help, /instance Greetings and bot information

Prices and charts

Looking up an asset

  • /p finds anything. It and its aliases resolve cryptocurrencies, stocks, company names, and tokens.
  • /c is crypto only. Lookup stays restricted to crypto.
  • Real assets win. Canonical assets take priority over DEX namesakes: /c bitcoin resolves BTC and /p apple resolves AAPL.
  • Be explicit if needed. Use stock: or crypto: to disambiguate.
  • One asset, one chart. A single asset gets a chart.
  • Lists work too. Comma-separated lists such as /p btc,timba combine market and token quotes.
  • Old behavior kept. Bare /c, /p, top-N lists, stablecoin lists, and conversion options retain their provider list behavior.

Tokens

  • Same resolver everywhere. Full Solana/EVM addresses, $ticker messages, and CoinMarketCap/CoinGecko token URLs share the command resolver.
  • Addresses are exact. They preserve case and pin the token identity.
  • Symbols are exact. Symbol searches require an exact match.
  • Ambiguous tickers. They keep their distinct chain and contract identities so the bot can ask which token you mean.
  • Token cards. DexScreener and pump.fun supply them.
  • Fallbacks. Missing chart history or photo delivery falls back to the available quote/card text, and missing metrics are shown as N/A.
  • Pump.fun. Bonding-curve tokens use pump.fun's candle feed for explicit chart ranges. When only an older trade is available, the chart shows its price across the window and labels it "last available trade price".

Chart ranges

Suffix Means
h Hours
d Days
w Weeks
m or mo 30-day months
y 365-day years

Examples: /c bitcoin 1m, /c bitcoin 7d, /p apple 1y, /s AAPL 5y.

  • Candles. Granularity is selected automatically.
  • Real dates only. Charts label the dates actually returned by the provider. Newly created tokens and unavailable history can't fill an older requested range.
  • Range change. For a single cryptocurrency or stock with an explicit range, a successful chart caption derives its change from that range and labels it with the requested period.
  • No history. If the provider can't supply usable history, delivery falls back to the available quote and says that the chart is unavailable.
  • No range. Without an explicit range, the caption keeps the default daily change.

Dollar change periods

/dolar takes the same suffixes, from 1h to 100y, and shows how much each rate changed in that time. Examples: /dolar 6h, /dolar 1w, /dolar 30d, /dolar 10y.

  • Up to 48 hours. The change uses the bot's own hourly snapshots.
  • Longer periods. The change uses the daily closes from ArgentinaDatos: blue, official and wholesale since 2011, CCL since 2013, MEP since 2018, card since 2019 and USDT since 2023.
  • Wholesale and TCRM 100. Before 2011, the wholesale rate comes from BCRA, which starts in 2002. TCRM 100 uses BCRA's wholesale rate and ITCRM of that day.
  • No history. A rate without a close from that time shows only its price.

⬇️ Run it yourself

You need:

  • Rust 1.98
  • PostgreSQL
  • Redis 8 (includes the Query Engine, formerly RediSearch)
  • FFmpeg

Warning

Never run two pollers with the same Telegram token.

Run it locally

1. Install the requirements

  • Rust 1.98
  • PostgreSQL
  • Redis 8 (includes the Query Engine, formerly RediSearch)
  • FFmpeg

2. Create the configuration

cp .env.example .env

Edit .env and set these values:

Variable What it is for
TELEGRAM_TOKEN Telegram bot token from BotFather
TELEGRAM_USERNAME Bot username, with or without @
DATABASE_URL PostgreSQL database URL
COINMARKETCAP_KEY Crypto market data
OPENROUTER_API_KEY AI chat, vision, summaries, and audio transcription

Create both workspace/SOUL.md and workspace/RULES.md with nonempty text. These files are the only source of the bot's personality and response rules.

Redis uses localhost:6379 by default. See .env.example for optional providers, monitoring, polling, and maintenance settings.

3. Build and check the configuration

cargo build --locked --release -p botd

set -a
. ./.env
set +a

./target/release/botd --check-config

4. Start the bot

./target/release/botd

Stop it with Ctrl+C. The bot waits for background work to finish before it exits.

[!IMPORTANT] For a Supabase database, use the session pooler on port 5432 with sslmode=require. Do not use the transaction pooler on port 6543.

Deploy with Podman
podman build --tag respondedorbot:local .

mkdir -p ~/.config/containers/systemd
mkdir -p ~/.config/systemd/user
mkdir -p ~/secrets ~/workspace

cp quadlets/* ~/.config/containers/systemd/
cp -r systemd/respondedorbot-* systemd/podman-auto-update.timer.d ~/.config/systemd/user/
cp .env.example ~/secrets/app.env
chmod 600 ~/secrets/app.env

password=$(openssl rand -hex 24)
cat > ~/secrets/postgres.env <<EOF
POSTGRES_USER=respondedorbot
POSTGRES_PASSWORD=$password
POSTGRES_DB=respondedorbot
EOF
chmod 600 ~/secrets/postgres.env
echo "DATABASE_URL=postgresql://respondedorbot:$password@respondedorbot-postgres:5432/respondedorbot?sslmode=disable"

podman run --rm --env-file ~/secrets/app.env \
  -v ~/workspace:/app/workspace:ro \
  respondedorbot:local /usr/local/bin/botd --check-config

systemctl --user daemon-reload
systemctl --user enable --now respondedorbot-maintenance.timer
systemctl --user enable --now respondedorbot-podman-prune.timer
systemctl --user enable --now podman-auto-update.timer
systemctl --user start respondedorbot-redis.service
systemctl --user start respondedorbot-postgres.service
systemctl --user start respondedorbot.service

Before starting, edit ~/secrets/app.env, set DATABASE_URL to the line printed above, and add the personality files to ~/workspace/SOUL.md and ~/workspace/RULES.md. Each unit waits until its secrets file exists.

podman-auto-update.timer checks the registry every 5 minutes and restarts the bot on a new latest image.

The runtime image contains botd, FFmpeg, and native shared libraries. CI publishes latest and immutable sha-<full-commit-sha> images.

To roll back, pin the Quadlet Image= setting to a verified SHA tag, reload the user units, and restart the service.

Upgrading from the old Redis Stack image: Redis 8 reads its data as is, but runs as the redis user, so fix the file owner once before starting it:

systemctl --user stop respondedorbot.service respondedorbot-redis.service
podman run --rm -v systemd-respondedorbot-redis:/data docker.io/library/redis:8-trixie chown -R redis:redis /data
systemctl --user daemon-reload
systemctl --user start respondedorbot-redis.service respondedorbot.service

Database backups

respondedorbot-backup.timer dumps the database every hour into an encrypted restic repository, such as a Cloudflare R2 bucket. It keeps 48 hourly and 30 daily snapshots. If a backup fails, the admin gets a Telegram message.

Create ~/secrets/restic.env and keep a copy of RESTIC_PASSWORD somewhere safe. Without it the backups cannot be read. The first backup creates the restic repository.

cat > ~/secrets/restic.env <<EOF
RESTIC_REPOSITORY=s3:https://<account-id>.r2.cloudflarestorage.com/<bucket>
RESTIC_PASSWORD=$(openssl rand -hex 32)
AWS_ACCESS_KEY_ID=<r2-access-key-id>
AWS_SECRET_ACCESS_KEY=<r2-secret-access-key>
EOF
chmod 600 ~/secrets/restic.env
systemctl --user enable --now respondedorbot-backup.timer

restic() {
  podman run --rm -i --env-file ~/secrets/restic.env \
    --volume=restic-cache:/root/.cache/restic \
    docker.io/restic/restic:latest "$@"
}

To restore the latest snapshot into an empty database:

systemctl --user stop respondedorbot.service
restic dump latest /respondedorbot.sql --host=respondedorbot --tag=postgres \
  | podman exec -i respondedorbot-postgres \
    psql --username=respondedorbot --dbname=respondedorbot --set=ON_ERROR_STOP=1
podman exec respondedorbot-postgres \
  psql --username=respondedorbot --dbname=respondedorbot --command=ANALYZE
systemctl --user start respondedorbot.service

ANALYZE matters: without fresh statistics the billing queries plan badly and can hit their timeouts. List snapshots with restic snapshots, and restore an older one by its ID instead of latest.

[!WARNING] Never run two pollers with the same Telegram token.

Inspect AI tool logs

Foreground AI conversations emit single-line AI trace: JSON records to stderr, captured by the container journal.

  • Each record includes the operation ID and provider round.
  • Events show available tools, provider generation IDs, requested tool calls, execution duration, and the final executed-tool count (including zero).
  • Search events include the query, up to ten source URLs/titles/snippets (news results first, with their date), empty results or an error, and the provider request ID when available.
  • Page reads include the URL, render when the model asked for a browser load, and whether the page was rendered or why rendering failed.
podman logs --since 15m --timestamps respondedorbot 2>&1 | grep 'AI trace:'

Match operation_id across records to follow one conversation turn.

  • Search queries and snippets are logged with length limits.
  • URL credentials, query parameters, and fragments are omitted.
  • Other tool outputs, chat history, and assistant response bodies are not logged.
  • These records are not sent to Telegram.
Test it

Run the Rust checks in an isolated Podman container:

scripts/check-container.sh

The script starts PostgreSQL and Redis inside the container. It runs formatting, Clippy, all workspace tests, and the coverage gate. Integration tests use synthetic data. The container has no host credentials or service sockets. It uses at most half the host memory and two CPUs. Set CARGO_BUILD_JOBS to change the CPU limit. The first run downloads the pinned Rust image and builds the test tools. It requires Podman and network access. It does not run the CI image or fuzz jobs.

Coverage requirements:

Crate Coverage
bot-core 100%
bot-adapters 100%
botd 100%

Mutation testing of bot-core (scripts/mutants.sh) runs in its own Mutants workflow and never blocks a merge.

More detail: Testing

How the code is organized
botd          Starts the app and connects all services
  |
  +-- bot-adapters   Telegram, HTTP, Redis, PostgreSQL, AI, and media
        |
        +-- bot-core   Parsing, routing, state machines, and domain rules

Dependencies point toward bot-core. External payloads are decoded in bot-adapters, while deterministic behavior stays in bot-core.

Path Contents
crates/bot-core Domain behavior and state machines
crates/bot-adapters External service implementations
crates/botd Executable and composition root
docs Architecture, persistence, billing, and testing
quadlets, systemd Deployment and maintenance units
Containerfile Rust-only production image

Read more: Architecture, Billing, Persistence

About

Telegram bot AI based on Argentina internet culture

Resources

Stars

4 stars

Watchers

1 watching

Forks

Packages

Used by

Contributors

Languages