examples: add channel-bridge — bidirectional cross-channel message forwarding#15
Conversation
…rwarding Adds a standalone Bun script that bridges messages between any two Hub channels using the WebSocket API: - Channel A contact → forwarded to Channel B with configurable prefix - Channel B reply with trigger prefix (@name) → forwarded back to Channel A Typical use case: Telegram contact's messages appear in WeChat in real time; WeChat user replies with @name to send back. Includes a launchd plist template for persistent background operation on macOS. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hey @jamiekya — thanks for this contribution! Really cool idea. Cross-channel bridging wasn't something we had on our radar at all, so it's great to see the community pushing the boundaries of what Hub can do. 🎉 The code is clean and well-documented — nice work. A few things we'd like addressed before merging: 1. Auth supportThe script doesn't include
2. Proxy bypassWe recently fixed an issue (#13) where system HTTP proxies ( if (!process.env.NO_PROXY) process.env.NO_PROXY = "127.0.0.1,localhost";3. Reconnect backoffThe current fixed 5s reconnect delay works, but exponential backoff would be more robust for longer outages (e.g. Hub restart taking a while): // Something like: 5s → 10s → 20s → cap at 60s, reset on successful connectNothing fancy needed — a simple multiply-and-cap in the Happy to help if you have any questions on these. Looking forward to merging this! — Forge (maintainer) |
- Auth: read HUB_API_TOKEN from env or ~/.forge-hub/api-token file, pass as Bearer header on /send and ?token= on WebSocket connect - Proxy: set NO_PROXY=127.0.0.1,localhost to bypass system HTTP proxy - Reconnect: replace fixed 5s delay with exponential backoff (5s → 10s → 20s → cap 60s, resets to 5s on successful connect) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
LinekForge
left a comment
There was a problem hiding this comment.
All three points addressed cleanly. LGTM — merging.
Thanks for the quick turnaround @jamiekya!
关联 Issue
closes #14
做了什么
新增
examples/channel-bridge.ts:一个基于 Hub WebSocket API 的独立跨通道消息桥脚本。功能:
@Alice)开头 → 去掉触发词后转发回通道 A适用场景示例:
@Alice开头回复 → 对方在 Telegram 收到文件说明
examples/channel-bridge.tsbun runexamples/channel-bridge.plist使用方式
测试
在 macOS 本地测试了 Telegram ↔ WeChat 双向转发,链路正常。
🤖 Generated with Claude Code