Skip to content

[Upstream PR #221] feat: add Telegram bridge for direct message integration #165

@quangdang46

Description

@quangdang46

Mirrored from upstream 1jehuang/jcodePull Request #221 by @LAG-Yadav
Original state: open
Created: 2026-05-16T13:02:35Z · Updated: 2026-05-17T15:54:59Z
Diff: https://github.com/1jehuang/jcode/pull/221.diff
This issue is an auto-mirrored copy. Comments and edits here are local to quangdang46/jcode — do not expect them to propagate upstream.


Summary

Add a zero-dependency Python bridge that connects Telegram messages directly into a running Jcode session via the debug socket. Users can message a Jcode instance via Telegram and receive responses in real-time.

Architecture

Telegram user → Bot API → Bridge polls getUpdates → Injects into Jcode debug socket → Jcode responds → Bridge sends back to Telegram

What's Included

  • scripts/telegram-bridge/bridge.py — Main daemon: polls Telegram, injects into Jcode via debug socket, watches for responses, sends replies
  • scripts/telegram-bridge/.env.example — Configuration template
  • scripts/telegram-bridge/bin/ — Helper scripts: tgstart, tgstatus, tgread, tgsend
  • scripts/telegram-bridge/README.md — Full documentation

Key Design Decisions

  • Pure Python stdlib — zero pip dependencies, works on any system with Python 3
  • Polling over webhooks — works anywhere Jcode runs (laptop, VPS, headless), no HTTPS endpoint needed
  • Debug socket injection — messages appear directly in the running session, preserving context for natural multi-turn conversations
  • Markdown→HTML conversion — Jcode's Markdown responses are converted to Telegram's HTML subset for proper rendering of bold, italic, code blocks, and links
  • Auto .env loading — bridge reads ~/.jcode/telegram/.env on startup, survives restarts

Usage

  1. Create a Telegram bot via @Botfather
  2. Set TELEGRAM_BOT_TOKEN in ~/.jcode/telegram/.env
  3. Enable debug_socket = true in Jcode config
  4. Run tgstart to start the bridge
  5. Message your bot on Telegram — messages appear in Jcode's terminal as 📩 *Telegram from X*: ...

The bridge automatically delivers Jcode's responses back to the Telegram user.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions