Skip to content

HCLonely/all-pusher-api

Repository files navigation

all-pusher-api

统一化推送服务Nodejs API. 已支持钉钉, Discord, 邮件, 飞书, PushDeer, PushPlus, QQ, QQ 频道机器人, Server 酱, Showdoc Push, Telegram Bot, 企业微信群机器人, 息知, WxPusher, iGot, Chanify, Bark, Push, Slack, Pushback, Zulip, RocketChat等平台.

!!!!!仅推送!!!!!不交互!!!!!!

已支持平台

安装

npm install all-pusher-api -S

使用

具体参数说明请查看说明文档

Example

多平台推送

点击展开
const { PushApi } = require('all-pusher-api'); // 多平台同时推送

(async () => {
  console.log((await new PushApi([
    {
      name: 'ServerChanTurbo',
      config: {
        key: {
          token: '******'
        }
      }
    },
    {
      name: 'PushDeer',
      config: {
        key: {
          token: '******'
        }
      }
    },
    {
      name: 'WxPusher',
      config: {
        key: {
          token: '******',
          uids: ['******']
        }
      }
    },
    ...,
    {
      name: 'PushMe',
      config: {
        key: {
          token: '******'
        }
      }
    }
  ])
    .send({ message: '测试文本' })).map((e) => (e.result.status >= 200 && e.result.status < 300) ? `${e.name} 测试成功` : e));
})();

单平台推送

(async () => {
  // Example 1
  const { PushApi } = require('all-pusher-api'); // 多平台同时推送

  const result = await new PushApi([
    {
      name: 'ServerChanTurbo',
      config: {
        key: {
          token: '******'
        }
      }
    }
  ])
    .send({ message: '测试文本' });
  console.log(result.map((e) => (e.result.status >= 200 && e.result.status < 300) ? `${e.name} 测试成功` : e));

  // Example 2
  const { WxPusher } = require('all-pusher-api/dist/WxPusher'); // 单平台推送可选

  const wxPusherResult = await new WxPusher({
    token: '******',
    uids: ['******']
  })
    .send({ message: '测试文本' });
  console.log(wxPusherResult);
})();

命令行使用

全局安装

npm install all-pusher-api -g

快速使用

allpush send -m '测试文本' -c '{\"name\":\"ServerChanTurbo\",\"config\":{\"key\":{\"token\":\"******\"}}}'
allpush send -m '测试文本' -f './config.json'

allpush send -h

# Usage: allpush send [options]
#
# 向配置的推送平台发送消息
#
# Options:
#   -c, --config <config>     JSON 配置字符串,需对引号进行转义。在线生成: https://configer.hclonely.com/?fileLink=https://raw.githubusercontent.com/HCLonely/all-pusher-api/main/config/template.yaml.js
#   -f, --config-file <path>  JSON 配置文件路径。在线生成: https://configer.hclonely.com/?fileLink=https://raw.githubusercontent.com/HCLonely/all-pusher-api/main/config/template.yaml.js
#   -m, --message <text>      要发送的消息内容
#   -t, --title <text>        消息标题
#   -h, --help                显示帮助信息

使用-c选项时JSON字符串要压缩为单行,双引号要转义! 使用多个通道同时推送时建议使用-f选项而不是-c选项!

支持的消息类型

所有平台支持均纯文本(text)格式消息, 大部分支持markdown格式消息, 部分支持html格式消息

markdown*为支持html格式不支持markdown格式消息时自动将markdown转换为html格式

other为部分平台支持特殊格式的消息, 可通过customOptions传入参数, 具体参数请查看相应平台的文档

  • Showdoc: 'text'
  • Pushover: 'text'
  • 爱语飞飞: 'text'
  • SimplePush: 'text'
  • QQ(go-cqhttp): 'text', 'other'
  • Qmsg: 'text', 'other'
  • Discord: 'text', 'other'
  • 飞书: 'text', 'other'
  • PushBullet: 'text', 'other'
  • NowPush: 'text', 'other'
  • Chanify: 'text', 'other'
  • Bark: 'text', 'other'
  • Server酱Turbo: 'text', 'markdown'
  • 息知: 'text', 'markdown'
  • WPush: 'text', 'markdown'
  • AnPush: 'text', 'markdown'
  • PushDeer: 'text', 'markdown', 'other'
  • QQ官方机器人: 'text', 'markdown', 'other'
  • 企业微信: 'text', 'markdown', 'other'
  • 企业微信群机器人: 'text', 'markdown', 'other'
  • 钉钉: 'text', 'markdown', 'other'
  • TelegramBot: 'text', 'markdown', 'html'
  • 一封传话: 'text', 'markdown', 'html'
  • PushMe: 'text', 'markdown', 'html'
  • 邮件: 'text', 'markdown*', 'html'
  • PushPlus: 'text', 'markdown*', 'html'
  • WxPusher: 'text', 'markdown*', 'html'

状态码

  • 0-Missing Parameter: ***: 缺少必要参数
  • 10-Missing Options: 缺少发送消息配置
  • 11-Unknown Error: 未知错误
  • 200-Success: 推送成功
  • 201-Waiting: 待审核
  • 100-Error: 请求发送成功, 服务器返回错误信息
  • 101-No Response Data: 请求发送成功, 但没有接收到服务器返回的数据
  • 102-Request Error: 请求发送失败, 一般是网络问题
  • 103-Options Format Error: 参数格式错误
  • 104-Get "***" Failed: 获取参数失败
  • 140-Check Sign Failed: 签名校检失败

About

统一化推送服务API. 已支持钉钉, Discord, 邮件, 飞书, PushDeer, PushPlus, QQ 频道, Server 酱, Showdoc Push, Telegram Bot, 企业微信群机器人, 息知, WxPusher, NowPush, iGot等平台.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages