chicheng-push: Adding Multi-Channel Message Push to DSH

Introduction

Much of DSH’s capability comes from plugins: after scheduled tasks, external tools, or custom scripts finish running, the results often need to be sent to Server酱, PushPlus, Telegram Bot, Feishu/Lark Bot, or custom Webhooks. If each plugin maintains its own channel configuration, fields, tests, and toggles, subsequent maintenance can become fragmented.

chicheng-push centralizes this capability into the DSH Web settings interface: a new “Push Plugin” entry is added to the sidebar, allowing configuration and management of multiple push channels, and exposing them to other plugins via the pushNotifier service and the /push/api/send HTTP endpoint.

What Is This

chicheng-push is a DSH message push plugin, maintained by 534119219, License: MIT.

It solves the problem of “how to uniformly notify after plugins complete tasks” in DSH scenarios: maintaining multiple push channels in the Web settings interface and providing host-side services and HTTP endpoints for convenient invocation by other plugins or scripts.

Core Features

Settings Interface

  • A new “Push Plugin” entry is added to the sidebar of the Web settings interface.
  • Multiple push channels can be configured and managed.
  • Supports enabling/disabling, editing, and deleting channels.
  • Supports sending test messages to individual channels.
  • Supports Chinese / English UI that switches with the browser language.

Supported Channels

  • Server酱
  • PushPlus
  • Bark
  • DingTalk Bot
  • WeCom Group Bot
  • WeCom App Messages
  • Telegram Bot
  • Feishu/Lark Bot
  • ntfy
  • iGot
  • PushDeer
  • Gotify
  • Custom Webhook
  • Email (SMTP)

Invocation by Other Plugins

The plugin provides two types of invocation methods:

  • The host-side pushNotifier service.
  • The /push/api/* HTTP endpoints.

The pushNotifier service provides:

push.list()
push.types()
push.send()
push.sendText()
push.test()

The HTTP endpoints include:

/push/api/list
/push/api/types
/push/api/save
/push/api/remove
/push/api/toggle
/push/api/test
/push/api/send

Channel data is persisted at:

$DSH_HOME/push/channels.json

Installation and Activation

  1. Install the plugin:
dsh plugin --profile web add chicheng-push
  1. Verify that the dsh.profile.bundles array in the profile manifest already includes chicheng-push. If it was not automatically added, manually add a line.

  2. Manually restart the dsh web service.

After restarting, navigate to:

Settings → Push Plugin

Typical Usage

Configuring Channels

  1. Select the channel type.

  2. Fill in the form fields. Required fields are marked with *.

  3. Save.

After saving, you can send a test message to an individual channel. This is a real push and is used to verify whether the current channel configuration is usable.

Invocation by Other Host Plugins

Other host plugins can read the service via ctx.get('pushNotifier') and then call push.send:

const push = ctx.get("pushNotifier");

if (push) {
  await push.send({
    title: "Task Completed",
    content: "exit 0",
    channels: "all",
  });
}

You can also call push.test(id) to send a test message for a specific channel, or call push.sendText(title, content, channels) to send a text message.

HTTP Endpoint Invocation

Any allowed location can send a POST JSON request to /push/api/send, for example:

curl -X POST http://127.0.0.1:3080/push/api/send \
  -H "content-type: application/json" \
  -d '{"title":"Scheduled Task Completed","content":"exit 0","channels":"all"}'

The /push/api/* endpoints are protected by a fence, allowing access only from same-origin, loopback, or trusted hosts.

Development and Testing

The plugin’s host half has zero third-party runtime dependencies; HTTP channels use Node’s built-in fetch. The email channel is only used when configured and when nodemailer can be dynamically loaded.

Notes for development:

  • Changes to lib/index.js require a restart to take effect.
  • Changes to lib/client.js only require a page refresh.

Run the integration tests:

node smoke.mjs

The tests include 19 assertions covering the real HTTP sending pipeline.

Applicable Scenarios and Notes

Suitable for the following situations:

  • Need to centrally manage multiple push channels within the DSH Web settings interface.
  • Other host plugins need to invoke pushes after task completion.
  • Scripts or external tools need to trigger pushes via HTTP endpoints.
  • Need Chinese / English UI that switches with the browser language.

Things to note before use:

  • The plugin runs with the current dsh process permissions. It is recommended to review the source code and license before installation.
  • Channel configurations (including SendKey / Token / Authorization codes) are stored in plaintext at $DSH_HOME/push/channels.json; please ensure that directory is only readable and writable by the current user.
  • The /push/api/* endpoints are protected by a fence (same-origin / loopback / trusted hosts only).
  • Test messages sent to channels are real pushes; confirm the configuration is correct before sending.

Links

  • Directory page: https://www.skillhub.cn/plugins/534119219/chicheng-push
  • GitHub: https://github.com/534119219/chicheng-push
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye