Skip to main content
M

dsh-telegram-publish

maxisoft-git/dsh-telegram-publish

Publishes text, photos and documents into a Telegram group, channel or forum topic through the Bot API, with a settings page for the token and destination. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Install

dsh plugin --profile web add github:maxisoft-git/dsh-telegram-publish

README

Telegram publish

English · Русский · 简体中文

License: MIT DSH >= 0.2.2-rc.1

Publishes one message — text, a photo or a document — into a Telegram group, supergroup or channel through the Bot API. It adds the telegram_publish tool for the agent, the /tg command for a person, and a section of the Settings page labelled Telegram publish (Russian UI: Публикация в Telegram), where the bot token, the destination chat and the delivery switches are set. It only writes: it does not read the group into the session, does not keep a message history and does not run a bot of its own.

What it adds

RowEffect
Tool telegram_publishPublishes text, or one local photo or document with a caption, into the configured chat, an explicit chatId or a named target; optional forum topic, reply target, silent delivery, no-preview and pin. Returns ok, chatId, messageId and a t.me link when the chat id allows one.
Command /tg <text>Publishes the text into the default chat without a model turn. /tg with no argument prints the current setup: whether the token is found, the default chat, the named targets and the markup.
Settings sectionA section on the Settings page (settings.section, id telegram-publish, order 40): token field with Save token / Remove, Find groups, the named-targets textarea, the markup select and the three delivery switches, Save settings, Send a test message.
Host routes /api/telegram-publish/*Six JSON routes the settings page calls: state, config, token, token/remove, test, discover. Loopback socket, loopback Host on the same port and same-origin POST only; /test and /discover accept one call per 2 seconds; the token is never returned.

Install

DSH 0.2.2-rc.1 or newer.

In DSH. Plugins → Add plugin with the installation spec github:maxisoft-git/dsh-telegram-publish. The plugin manager installs it for the whole profile; a new session picks it up.

From a checkout. git clone https://github.com/maxisoft-git/dsh-telegram-publish.git, then install that absolute directory with Plugins → Add plugin.

Use

  1. Create a bot: @BotFather → /newbot → copy the token.
  2. Add the bot to the group or channel. Where the chat restricts posting, make the bot an administrator.
  3. Open Settings → Telegram publish (Russian UI: Настройки → Публикация в Telegram).
  4. Paste the token into Bot token and press Save token. The plugin calls getMe first; a token Telegram rejects is not stored.
  5. Post any message in the group and press Find groups. The list is built from the bot's recent getUpdates; pick the chat, press Use, then Save settings.
  6. Optional: put extra destinations into Named targets, one name = -100… per line. The agent picks one with the target argument.
  7. Press Send a test message to confirm the chat accepts the bot.
  8. Publish. From the agent, one example per shape:
telegram_publish { "text": "Release 1.4 is out", "target": "news" }
telegram_publish { "text": "Screenshot", "photo": "shots/home.png" }
telegram_publish { "text": "Maintenance tonight", "chatId": "-1001234567890", "topicId": 42, "pin": true }

From a session:

/tg Release 1.4 is out
/tg

Limits and behaviour, checked before anything is uploaded: 4096 characters for text, 1024 for a caption, 10 MB for a photo, 50 MB for a document. photo and document are mutually exclusive. replyTo applies to a text message; a media upload drops it. A failed pin does not cancel the published message — the result names the pin failure instead. Markup is Telegram markup (markdown by default); when Telegram cannot parse it, the same text is sent once more as plain text. Errors come back as telegram_publish: <Telegram description>.

An upload path is resolved against the session directory and must stay inside it; a symlink is resolved before that check, and a name that starts with a dot is refused. The row key allowOutsideWorkspace: true lifts the directory rule, and then any readable file can be uploaded.

Configuration

KeyDefaultMeaningWhere it is stored
tokenRefTELEGRAM_BOT_TOKENCredential reference that holds the bot tokenPlugin row telegram-publish; the value itself in the DSH credential store
chatId— (none)Default destination: -100… for a supergroup, @channelname for a public channelPlugin row
targets{}Named destinations for the tool's target argument, e.g. news: '-100…'Plugin row
formatmarkdownDefault markup: plain, markdown or htmlPlugin row
silentfalsePublish without a notification soundPlugin row
noPreviewfalseDisable link previewsPlugin row
pinfalsePin every published messagePlugin row
apiBasehttps://api.telegram.orgBot API root. Must be https — http is accepted only for a loopback host, and the URL may carry no credentials, query or fragmentPlugin row
allowOutsideWorkspacefalseAllow photo and document paths outside the session directoryPlugin row

The token is a credential reference only. The settings page stores it through the DSH credential service under tokenRef; the same service also resolves an environment variable of that name. The page writes the other keys through the config editor, so the profile's cordis.patch.yml stays the source of truth. apiBase is not edited on the page — it is a row key for a self-hosted Bot API.

Data and network

Outbound HTTPS to api.telegram.org, or to the host named by apiBase, and only when the plugin is asked to act:

  • getMe — when a token is saved, and once per 60 seconds while the settings page is open with a token configured.
  • sendMessage, sendPhoto, sendDocument — on telegram_publish, on /tg, or on Send a test message.
  • pinChatMessage — when pinning is on.
  • getUpdates — only when Find groups is pressed, to list the groups, supergroups and channels the bot has recently seen.

Every request URL is <apiBase>/bot<token>/<method>, so the token travels in the path to that host. The message text, the chat id, the topic id and the reply target go to Telegram as part of the request. A photo or document is read from a local path inside the session directory — unless the row sets allowOutsideWorkspace — and posted as multipart/form-data; no other file is read. A redirect from the Bot API is not followed, so a request body and the token in its URL are never replayed at another address, and an answer larger than 1 MiB is refused instead of buffered.

Turning it off: remove the token on the settings page (or unset the credential and TELEGRAM_BOT_TOKEN), or disable the plugin. Nothing is queued or retried — a failed request is reported to the caller.

On disk the plugin writes nothing of its own: the keys above live in the profile's plugin row, the token in the DSH credential store. The bot identity from getMe is cached in memory for 60 seconds and is not written anywhere.

Security

SECURITY.md — how to report a vulnerability and which versions are supported. SECURITY-AUDIT.md — the per-plugin audit: data flow, permissions, findings and their fixes.

The token is never written to the plugin configuration, never logged, and never included in a tool result or a route response; error text is scrubbed of the token and of token-shaped strings before it reaches a surface. The six settings routes require a loopback socket, a loopback Host header on the same port, and a same-origin Origin on POST; /test and /discover answer 429 with a Retry-After header when called more than once per 2 seconds.

Requirements

  • DeepSeek Harness 0.2.2-rc.1 or newer.
  • Node.js 22.19.0 or newer, as declared in engines.
  • A bot token from @BotFather and a chat id (-100… or @channelname).
  • The bot must be a member of the group, and an administrator where the chat restricts posting. Pinning needs administrator rights.

Development

  • npm test runs three offline scripts: scripts/smoke.mjs (tool and /tg against a mock Bot API), scripts/smoke-settings.mjs (the six routes and the config editor) and scripts/smoke-client.mjs (the browser bundle with a React shim).
  • npm run verify checks the manifest, the patch file, the three locale files and the required README, LICENSE, CHANGELOG, SECURITY and SECURITY-AUDIT files.
  • Local link install: Plugins → Add plugin with the absolute path of the checkout. No build step; the code runs from source.
  • Layout: index.js is the Host half (tool, /tg, the six routes, the Bot API client), client.js the Browser half (the settings section), cordis.patch.yml the Loader row, locale/ holds en, ru, zh, docs/ the detail page, scripts/ the tests above.

License

MIT © 2026 maxisoft-git

Related plugins