1
0
Fork 0
mirror of https://github.com/ananthb/botrelay-rs.git synced 2026-09-20 16:27:00 +00:00
Forward content to Telegram and Discord bots and route replies back. Reusable Rust primitives for Cloudflare Workers
Find a file
Ananth Bhaskararaman c62aff4735 ci: bump checkout to v6 and gh-release to v3 for Node 24
Both actions were flagged as Node-20-deprecated. v6.0.2 of
actions/checkout and v3.0.0 of softprops/action-gh-release run on
Node 24, so the deprecation warning goes away.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 20:08:52 +05:30
.github/workflows ci: bump checkout to v6 and gh-release to v3 for Node 24 2026-05-02 20:08:52 +05:30
src add multipart, send_photo, attachment uploads 2026-04-26 23:28:02 +05:30
.gitignore Stop tracking target/ and Cargo.lock 2026-04-24 18:33:25 +05:30
Cargo.toml metadata: keywords + categories + readme + crates.io install snippet 2026-05-02 19:56:54 +05:30
LICENSE Initial commit 2026-04-24 18:26:02 +05:30
README.md metadata: keywords + categories + readme + crates.io install snippet 2026-05-02 19:56:54 +05:30

botrelay

Reusable primitives for Cloudflare Workers that need to:

  1. Forward content (an email, a notification, anything) to a Telegram chat or Discord channel via a bot.
  2. Route replies from those channels back to the original source (typically an email address).

The crate provides:

  • botrelay::telegram — a minimal Telegram Bot API client (sendMessage, setWebhook) and typed Update parsing for the webhook endpoint.
  • botrelay::discord — a minimal Discord Bot API client (createMessage with components), Ed25519 interaction-signature verification (WebCrypto), and typed Interaction parsing including modal submissions.
  • botrelay::reply — a small ReplyContext type (alias, original sender, subject) you store per forwarded message so the webhook handler can look it up and send a reply back through whatever channel the original content came from.

It doesn't own storage or the send-reply side — each consumer plugs in its own KV and outbound mechanism. That's the whole point: both cutout (email proxy) and concierge-worker (business messaging) embed the same primitives with different backends.

Usage

[dependencies]
botrelay = "0.1"
use botrelay::telegram::{TelegramBot, SendMessage};

let bot = TelegramBot::new(std::env::var("TELEGRAM_BOT_TOKEN").unwrap());
let msg = bot.send_message(SendMessage {
    chat_id: "123456".into(),
    text: "Hello!".into(),
    ..Default::default()
}).await?;

See the crate docs for Discord and reply-routing.

License

AGPL-3.0