Skip to content

推送服务

本页按服务分别说明配置。所有服务都可以通过 PushApiname + config 使用,也可以直接从 all-pusher-api/dist/<ClassName> 引入对应类。

除特殊说明外:

  • 认证信息推荐放入 config.key
  • messagecustomOptions 至少提供一个。
  • extraOptions 会合并进默认请求体。
  • customOptions 会直接作为该平台请求体。
  • 支持 proxy 的服务都使用 统一代理配置

Bark

类名:Bark

官方 API 文档:Bark

配置项必填说明
key.tokenBark device key。
key.baseURL自建服务端地址,默认为 https://api.day.app/push
js
const { Bark } = require('all-pusher-api/dist/Bark');

await new Bark({
  key: {
    token: '******',
    baseURL: 'https://api.day.app/push'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text,也可通过 customOptions 发送 Bark 支持的完整请求体。

默认请求体会生成 { title, body, device_key }title 未提供时取正文首行前 10 个字符。

Chanify

类名:Chanify

官方 API 文档:Chanify

配置项必填说明
key.tokenChanify token。
key.baseURL自建服务端地址,默认为 https://api.chanify.net/v1/sender/
js
const { Chanify } = require('all-pusher-api/dist/Chanify');

await new Chanify({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text,也可通过 customOptions 发送平台自定义字段。

默认请求体会生成 { title, text },并以表单格式发送到 baseURL + token

DingTalk

类名:DingTalk

官方 API 文档:钉钉群机器人

配置项必填说明
key.token钉钉群机器人 access_token
key.secret开启加签时填写加签密钥。
js
const { DingTalk } = require('all-pusher-api/dist/DingTalk');

await new DingTalk({
  key: {
    token: '******',
    secret: '******'
  }
}).send({
  message: '### 发布完成',
  type: 'markdown',
  extraOptions: {
    at: {
      isAtAll: true
    }
  }
});

支持类型:textmarkdownotherother 通过 customOptions 发送。

Discord

类名:Discord

官方 API 文档:Discord Webhook

配置项必填说明
key.webhookDiscord Webhook URL。
js
const { Discord } = require('all-pusher-api/dist/Discord');

await new Discord({
  key: {
    webhook: 'https://discord.com/api/webhooks/******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textother。默认请求体为 { content },如果传入 title 会拼接到正文前。

FeiShu

类名:FeiShu

官方 API 文档:飞书群机器人

配置项必填说明
key.token飞书群机器人 hook token。
key.secret开启签名校验时填写密钥。
js
const { FeiShu } = require('all-pusher-api/dist/FeiShu');

await new FeiShu({
  key: {
    token: '******',
    secret: '******'
  }
}).send({
  message: '测试文本'
});

支持类型:textother。默认请求体为飞书文本消息:{ msg_type: 'text', content: { text } }

GoCqhttp

类名:GoCqhttp

官方 API 文档:QQ go-cqhttp

配置项必填说明
key.baseUrlgo-cqhttp HTTP API 地址,需包含 http://https://
key.tokengo-cqhttp access token。
key.user_id目标 QQ 号,与 group_idchannel_id 三选一。
key.group_id目标群号,与 user_idchannel_id 三选一。
key.channel_id目标频道 ID,需与 guild_id 同时存在。
key.guild_id目标子频道 ID,需与 channel_id 同时存在。
js
const { GoCqhttp } = require('all-pusher-api/dist/GoCqhttp');

await new GoCqhttp({
  key: {
    baseUrl: 'http://127.0.0.1:5700',
    token: '******',
    user_id: 10000
  }
}).send({
  message: '测试文本'
});

支持类型:textother。频道消息会发送到 /send_guild_channel_msg,其他消息发送到 /send_msg

GoogleChat

类名:GoogleChat

官方 API 文档:Google Chat Webhook

配置项必填说明
key.webhookGoogle Chat Webhook URL。
js
const { GoogleChat } = require('all-pusher-api/dist/GoogleChat');

await new GoogleChat({
  key: {
    webhook: 'https://chat.googleapis.com/v1/spaces/******'
  }
}).send({
  message: '测试文本'
});

支持类型:textother。默认请求体为 { text: message }

IGot

类名:IGot

官方 API 文档:iGot

配置项必填说明
key.tokeniGot 推送 key。
js
const { IGot } = require('all-pusher-api/dist/IGot');

await new IGot({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textother。默认请求体包含标题和内容。

Iyuu

类名:Iyuu

官方 API 文档:爱语飞飞

配置项必填说明
key.tokenIYUU 令牌。
js
const { Iyuu } = require('all-pusher-api/dist/Iyuu');

await new Iyuu({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text。默认使用标题和正文发送。

Mail

类名:Mail

官方 API 文档:Nodemailer

配置项必填说明
key.hostSMTP 服务器地址。
key.portSMTP 服务器端口。
key.secure是否启用 TLS/SSL。
key.auth.userSMTP 用户名。
key.auth.passSMTP 密码。
options.from发件人邮箱。
options.to收件人邮箱,也可通过 extraOptions.to 覆盖。
js
const { Mail } = require('all-pusher-api/dist/Mail');

await new Mail({
  key: {
    host: 'smtp.example.com',
    port: 465,
    secure: true,
    auth: {
      user: 'sender@example.com',
      pass: 'password'
    }
  },
  options: {
    from: 'sender@example.com',
    to: 'receiver@example.com'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textmarkdownhtmlmarkdown 会转换为 HTML 发送。

Ntfy

类名:Ntfy

官方 API 文档:Ntfy Publish

配置项必填说明
key.tokenntfy topic。
key.baseURL自建服务端地址,默认使用 ntfy 官方服务。
js
const { Ntfy } = require('all-pusher-api/dist/Ntfy');

await new Ntfy({
  key: {
    token: 'mytopic',
    baseURL: 'https://ntfy.sh/'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textother。默认以正文作为消息内容,标题可通过 title 传入。

Push

类名:Push

官方 API 文档:Push

配置项必填说明
key.tokenPush API key。
key.baseURL自定义接口地址。
js
const { Push } = require('all-pusher-api/dist/Push');

await new Push({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textother

Pushback

类名:Pushback

官方 API 文档:Pushback

配置项必填说明
key.tokenat_token
key.userIdPushback User_id
js
const { Pushback } = require('all-pusher-api/dist/Pushback');

await new Pushback({
  key: {
    token: 'at_******',
    userId: 'User_******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text。默认把 titlemessage 组合为 Pushback 请求。

PushBullet

类名:PushBullet

官方 API 文档:PushBullet

配置项必填说明
key.tokenPushBullet access token。
js
const { PushBullet } = require('all-pusher-api/dist/PushBullet');

await new PushBullet({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textother。默认发送 note 类型消息。

PushDeer

类名:PushDeer

官方 API 文档:PushDeer

配置项必填说明
key.tokenPushDeer pushkey。
key.baseURL自建服务端地址。
js
const { PushDeer } = require('all-pusher-api/dist/PushDeer');

await new PushDeer({
  key: {
    token: '******'
  }
}).send({
  message: '### 测试文本',
  type: 'markdown'
});

支持类型:textmarkdownother。默认请求体包含 pushkeytextdesptype

PushMe

类名:PushMe

官方 API 文档:PushMe

配置项必填说明
key.tokenPushMe push_key。
key.baseURL自建服务端地址。
js
const { PushMe } = require('all-pusher-api/dist/PushMe');

await new PushMe({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textmarkdownhtml

Pushover

类名:Pushover

官方 API 文档:Pushover

配置项必填说明
key.tokenPushover API token。
key.userPushover user key。
js
const { Pushover } = require('all-pusher-api/dist/Pushover');

await new Pushover({
  key: {
    token: '******',
    user: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text。传入 markdown 时会启用 Pushover 的 monospace/HTML 相关字段,复杂内容建议使用 customOptions

PushPlus

类名:PushPlus

官方 API 文档:PushPlus

配置项必填说明
key.tokenPushPlus token。
js
const { PushPlus } = require('all-pusher-api/dist/PushPlus');

await new PushPlus({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '<h1>测试文本</h1>',
  type: 'html'
});

支持类型:textmarkdownhtml。默认请求体包含 tokentitlecontenttemplate

QQBot

类名:QQBot

官方 API 文档:QQ 官方机器人

配置项必填说明
key.appIdQQ 官方机器人 AppID。
key.appSecretQQ 官方机器人 AppSecret。
key.userId单聊目标用户 openid。
key.groupId群聊目标群 openid。
key.channelId频道子频道 ID。
key.baseUrlQQ Bot API 地址,通常无需修改。
js
const { QQBot } = require('all-pusher-api/dist/QQBot');

await new QQBot({
  key: {
    appId: '******',
    appSecret: '******',
    userId: '******'
  }
}).send({
  message: '测试文本'
});

userIdgroupIdchannelId 至少提供一个,也可以在发送时通过 extraOptionscustomOptions 指定。

支持类型:textmarkdownother。QQ 官方机器人主动推送能力受平台权限限制。

RocketChat

类名:RocketChat

官方 API 文档:RocketChat Incoming Webhook

配置项必填说明
key.webhookRocketChat Incoming Webhook URL。
js
const { RocketChat } = require('all-pusher-api/dist/RocketChat');

await new RocketChat({
  key: {
    webhook: 'https://chat.example.com/hooks/******'
  }
}).send({
  message: '测试文本'
});

支持类型:textother。默认请求体为 { text: message }

ServerChanTurbo

类名:ServerChanTurbo

别名:ServerChan

官方 API 文档:Server 酱

配置项必填说明
key.tokenServer 酱 SendKey。
js
const { ServerChanTurbo } = require('all-pusher-api/dist/ServerChanTurbo');

await new ServerChanTurbo({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textmarkdown。默认请求体包含 titledesp

Showdoc

类名:Showdoc

官方 API 文档:Showdoc Push

配置项必填说明
key.tokenShowdoc Push URL 中 /server/api/push/ 后面的 token。
js
const { Showdoc } = require('all-pusher-api/dist/Showdoc');

await new Showdoc({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text。默认请求体包含标题和内容。

SimplePush

类名:SimplePush

官方 API 文档:SimplePush

配置项必填说明
key.tokenSimplePush key。
js
const { SimplePush } = require('all-pusher-api/dist/SimplePush');

await new SimplePush({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:text。默认发送标题和正文。

Slack

类名:Slack

官方 API 文档:Slack Incoming Webhook

配置项必填说明
key.webhookSlack Incoming Webhook URL。
js
const { Slack } = require('all-pusher-api/dist/Slack');

await new Slack({
  key: {
    webhook: 'https://hooks.slack.com/services/******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textother。默认请求体为 { text },标题会拼接到正文前。

TelegramBot

类名:TelegramBot

官方 API 文档:Telegram Bot sendMessage

配置项必填说明
key.tokenTelegram Bot token。
key.chat_id目标 chat id。
js
const { TelegramBot } = require('all-pusher-api/dist/TelegramBot');

await new TelegramBot({
  key: {
    token: '******',
    chat_id: '******'
  }
}).send({
  message: '<b>测试文本</b>',
  type: 'html'
});

支持类型:textmarkdownhtmlmarkdownhtml 会映射为 Telegram parse_mode

WorkWeixin

类名:WorkWeixin

官方 API 文档:企业微信

配置项必填说明
key.corpid企业 ID。
key.secret企业应用 secret。
key.agentid企业应用 agentid。
key.touser接收成员,多个用 `
js
const { WorkWeixin } = require('all-pusher-api/dist/WorkWeixin');

await new WorkWeixin({
  key: {
    corpid: '******',
    secret: '******',
    agentid: 1000002,
    touser: '@all'
  }
}).send({
  message: '测试文本'
});

支持类型:textmarkdownothertouser 也可在发送时通过 extraOptions 覆盖。

WorkWeixinBot

类名:WorkWeixinBot

官方 API 文档:企业微信群机器人

配置项必填说明
key.webhook企业微信群机器人 Webhook URL。
js
const { WorkWeixinBot } = require('all-pusher-api/dist/WorkWeixinBot');

await new WorkWeixinBot({
  key: {
    webhook: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=******'
  }
}).send({
  message: '### 测试文本',
  type: 'markdown'
});

支持类型:textmarkdownother

WPush

类名:WPush

官方 API 文档:WPush

配置项必填说明
key.tokenWPush API token。
js
const { WPush } = require('all-pusher-api/dist/WPush');

await new WPush({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textmarkdown。默认请求体包含 apikeytitlecontent

WxPusher

类名:WxPusher

官方 API 文档:WxPusher

配置项必填说明
key.tokenWxPusher appToken。
key.uids发送目标 UID 列表,也可发送时指定。
key.topicIds发送目标 topicId 列表,也可发送时指定。
js
const { WxPusher } = require('all-pusher-api/dist/WxPusher');

await new WxPusher({
  key: {
    token: '******',
    uids: ['UID_xxx']
  }
}).send({
  title: '标题',
  message: '# Markdown 内容',
  type: 'markdown'
});

支持类型:textmarkdownhtmlmarkdown 会转换为 HTML 后以 contentType: 2 发送。

Xizhi

类名:Xizhi

官方 API 文档:息知

配置项必填说明
key.token息知 key。
js
const { Xizhi } = require('all-pusher-api/dist/Xizhi');

await new Xizhi({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textmarkdown。默认请求体包含 titlecontent

YiFengChuanHua

类名:YiFengChuanHua

官方 API 文档:一封传话

配置项必填说明
key.token一封传话通道 code。
js
const { YiFengChuanHua } = require('all-pusher-api/dist/YiFengChuanHua');

await new YiFengChuanHua({
  key: {
    token: '******'
  }
}).send({
  title: '测试标题',
  message: '测试文本'
});

支持类型:textmarkdownhtml。默认请求体包含 headbody

Zulip

类名:Zulip

官方 API 文档:Zulip send-message

配置项必填说明
key.tokenZulip bot API key。
key.emailZulip bot email。
key.siteZulip 站点地址,默认 https://chat.zulip.org
key.to发送对象。未配置时发送时必须提供。
js
const { Zulip } = require('all-pusher-api/dist/Zulip');

await new Zulip({
  key: {
    site: 'https://your-zulip.example.com',
    token: '******',
    email: 'bot@example.com',
    to: ['user@example.com']
  }
}).send({
  message: '测试文本'
});

支持类型:text。默认 typedirect,可通过 extraOptions.type 改为 stream 等 Zulip 支持的类型。

Custom

类名:Custom

Custom 不对应固定推送平台,用于把任意 HTTP 接口包装成推送服务。

官方 API 文档:自定义 HTTP 接口,无固定平台文档。

配置项必填说明
url请求地址。
method请求方法,默认 POST
contentType请求内容类型,默认 application/json
headers自定义请求头。
success.key判断成功的响应字段路径,例如 responseData.errcode
success.value判断成功的字段值。
js
const { Custom } = require('all-pusher-api/dist/Custom');

await new Custom({
  url: 'https://example.com/push',
  success: {
    key: 'responseData.code',
    value: 0
  }
}).send({
  text: '测试文本'
});

Custom.send() 不使用统一 sendOptions,入参会直接作为请求体或查询参数发送。