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
- Rust 100%
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> |
||
|---|---|---|
| .github/workflows | ||
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
botrelay
Reusable primitives for Cloudflare Workers that need to:
- Forward content (an email, a notification, anything) to a Telegram chat or Discord channel via a bot.
- 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 typedUpdateparsing for the webhook endpoint.botrelay::discord— a minimal Discord Bot API client (createMessagewith components), Ed25519 interaction-signature verification (WebCrypto), and typedInteractionparsing including modal submissions.botrelay::reply— a smallReplyContexttype (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.