axisrow/tg_messenger/tree/main/claude-plugin
About this mod
Telegram inside Claude Code: /tg opens a pane driven by the tg-messenger CLI.
Installation
Check the author's README for the marketplace and plugin name first. Commands may change as the repository evolves.
claude plugin marketplace add axisrow/tg_messenger claude plugin install tg-messenger
Original text / README
tg-messenger mod for Claude Code
Skeleton of a Claude Code mod (issue #244): a plugin whose behavior lives
entirely in a hooks module — one register(on, options) entry point in
hooks/register.ts, TypeScript loaded straight from source (no build step).
How mods work
- A handler is
($, e, next):$is the engine API ($.command,$.ui,$.process,$.fs,$.store,$.env,$.clock,$.session),ethe event payload,nextthe rest of the pipeline. - This skeleton proves the pieces the Telegram bridge needs:
session.start→$.command.registerputs/tgin the composer;command.run {command: 'tg'}opens a pane ($.ui.open) below the prompt, drawn by aui.render {component: 'Pane'}hook (JSX:Box,Text,Buttonfrom$.ui.resolve(e)) — the messenger UI lands there.
- Reference mods (with docs): anthropics/claude-code
mods/.
Run
Function hooks are early access — the env flag is required until that changes:
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude --plugin-dir claude-plugin -p "/tg"
Or in an interactive session:
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude --plugin-dir claude-plugin
then type /tg — a pane opens below the prompt (ping → toast, close/Esc → dismissed).
Install
This repo is a Claude Code marketplace (.claude-plugin/marketplace.json at the root):
claude plugin marketplace add axisrow/tg_messenger
claude plugin install tg-messenger@tg-messenger
claude plugin configure tg-messenger # profile + dialog
Function hooks are early access — until that changes, the installing user needs
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 in their environment (see above).
Transport
The pane drives the project's own CLI (tg-messenger) — no HTTP, no secrets:
- history —
--profile P read <id> --limit 50on pane open; - live — one long-running
--profile P listen --ids --outchild (incoming DMs + own messages from other devices), reconnected with backoff; - send —
--profile P send <id> <text>, media viasend <id> --file …; - react —
--profile P react <id> <msg-id> <emoji>.
tg-messenger must be installed and logged in for the configured profile
(tg-messenger login --profile P). Without a full config the pane degrades to
a local-only scratchpad with a one-line toast. The transport lives in
hooks/register.tsx (the engine follows $ only within the file that
declares it); every call is one child process over an argv array.
Config (#248)
Two options (claude plugin configure tg-messenger):
- profile (optional) — the saved tg-messenger profile to use. When empty,
the pane resolves it at boot from
tg-messenger profiles: exactly one valid (✓ ok) saved profile is picked and shown in the header; zero valid → a clear "runtg-messenger login" error; several valid → the list plus a hint to configure. The mod never picks an account silently — the single-profile pick is logged and rendered. - dialog — which dialog the pane talks to: a marked numeric dialog id
(negative for groups, as shown by
tg-messenger dialogs) or@username(resolved once per pane open via the cached dialog list — never per message). Group dialogs are history-only: the CLI'slistenstreams DMs only (v1). Anything malformed → clear toast, dead-safe no-send mode.
