Code Monkey home page Code Monkey logo

pushoo's Introduction

pushoo.js

背景

消息推送平台多用于在特定的场合提醒使用者,例如:博客收到评论、服务器告警、油价上涨、每日签到结果推送、家中饲养的鸽子外出、飞回,等等……自从方糖气球推出 Server 酱以来,消息推送平台逐渐多样化,他们遵循的 API 格式却很混乱。

  • 有的是 URL 地址传参,有的是 form 表单传参,有的是 JSON 传参,暂时还没看到 XML 传参的;
  • 有的正文支持 Markdown,有的正文支持 HTML,有的正文支持纯文本;
  • 有的支持标题,有的不支持标题。

Twikoo 评论系统对不同的消息推送平台做了大量的适配工作,云函数越来越大。

为了降低云函数复杂度,遂诞生了本项目,本项目旨在整合各大消息推送平台服务,获得统一的调用体验。

同时本项目由Tianli0提供公益QQ机器人推送服务,请勿用于非法用途!(机器人QQ将不定期更换,请关注文档)

支持的消息推送平台

计划支持的推送平台

  • 阿里云短信
  • 腾讯云短信
  • 自定义 Webhook

使用方法

注:如果您是在 Twikoo 评论系统中使用,则无需搭建,直接在 Twikoo 管理面板中配置平台名称和 token 即可。

如果您是在 GitHub Actions 中使用,可以使用 funnyzak/pushoo-action,该作者还提供了基于 pushoo 的命令行工具:funnyzak/pushoo-cli

安装

npm install pushoo

现在,不论您使用什么推送平台,都无需关心他们的调用方式,只需要学习 pushoo 的调用方式即可开始发送您的第一条推送!

const pushoo = require('pushoo').default;

const result = await pushoo('平台名称', {
  token: '平台用户身份标识',
  title: '消息标题',
  content: 'Markdown 格式的推送内容'
});

console.log(result);

是的,调用 pushoo 最简单只需要传递 4 个参数!

参数 必填 默认 说明
平台名称 字符串,平台名称的缩写,支持:qmsgserverchanpushpluspushplushxtripdingtalkwecombarkgocqhttpatripushdeerigottelegramfeishuiftttwecombotdiscord, wxpusher
token 平台用户身份标识,通常情况下是一串数字和字母组合,详情和示例见下方详细说明
title 内容第一行 可选,消息标题,如果推送平台不支持消息标题,则会拼接在正文首行
content Markdown 格式的推送内容,如果推送平台不支持 Markdown,pushoo 会自动转换成支持的格式
options 用于推送时的一些额外配置。类型NoticeOptions
interface NoticeOptions {
  /**
   * bark通知方式的参数配置
   */
  bark?: {
    /**
     * url 用于点击通知后跳转的地址
     */
    url?: string;
  };
  /**
   * IFTTT通知方式的参数配置
   */
  ifttt?: {
    value1?: string;
    value2?: string;
    value3?: string;
  };
  /**
   * Discord通知方式的参数配置
   */
  discord?: {
    userName?: string;
    avatarUrl?: string;
  };
  /**
   * WxPusher通知方式的参数配置
   */
  wxpusher?: {
    uids?: string[];
    url?: string;
    verifyPay?: boolean;
  };
  dingtalk?: {
    /**
     * 消息类型,目前支持 text、markdown。不设置,默认为 text。
     */
    msgtype?: string;
  };
}

详细说明

💬 Qmsg 缩写: qmsg

Qmsg 酱是 Zendee 提供的第三方 QQ 消息推送服务,免费,消息以 QQ 消息的形式推送,支持私聊推送和群推送。请注意,为避免 Qmsg 酱被 Tencent 冻结,pushoo 会自动删除消息中的网址和 IP 地址。

  1. 前往 https://qmsg.zendee.cn/ 并使用 QQ 登录
  2. 点击 “管理台”,选择一个 Qmsg 酱,并添加 TA 为好友
  3. 在 “我的QQ列表” 中添加自己的 QQ 号
  4. 复制 “我的KEY” 下方的 key,填入 pushoo 的 token 中

示例 token:d3e96b6c50adf28cc6d1bb*****a4613

💬 Server 酱 缩写: serverchan

Server 酱是方糖提供的第三方多渠道推送服务,以服务号推送起家,稳定运行多年,免费收费并存,特色功能较多。

  1. 前往 https://sct.ftqq.com/r/13235 并使用微信登录
  2. 点击 “消息通道”,设置合适的消息通道并保存
  3. 点击 “SendKey”,复制 “SendKey” 下方的 key,填入 pushoo 的 token 中

示例 token:SCT1364TKdsiGjGvyAZNYD*****VAK0k

💬 Push Plus 缩写: pushplus

Push Plus 是苏州破壳网络科技有限公司提供的第三方微信服务号推送服务,免费版存在不影响使用的广告,会员版特权如下:https://www.pushplus.plus/vip.html

  1. 前往 https://www.pushplus.plus/ 并使用微信登录
  2. 点击 “一对一推送”,复制 “你的token” 下方的 token,填入 pushoo 的 token 中

示例 token:2832134a66df4da69ef941*****72317

💬 Push Plus Hxtrip 缩写: pushplushxtrip

Push Plus Hxtrip 是中道(苏州)旅游网络科技有限公司提供的第三方微信服务号推送服务,免费无广告

  1. 前往 https://pushplus.hxtrip.com/message 并使用微信登录
  2. 复制 “您的Token” 下方的 Token,填入 pushoo 的 token 中

示例 token:2a00acb27e414ea4bf9d19*****08986

💬 钉钉 缩写: dingtalk

钉钉是阿里推出的办公即时消息软件,官方提供了机器人 API,可实现消息推送,免费。推送的消息必须包含配置的关键字,否则推送不成功。只能在群聊中创建机器人,可选择 2 名好友组建群聊,然后移除 2 名好友(好友会收到提醒,请谨慎操作),再添加机器人。

  1. 根据 https://open.dingtalk.com/document/group/custom-robot-access 的说明,创建一个机器人。如果是在 Twikoo 评论系统中使用,请配置关键字为 “评论”
  2. 复制机器人的 Webhook,填入 pushoo 的 token 中

示例 token:https://oapi.dingtalk.com/robot/send?access_token=06ff1823a060af772677680d9522b547bc2685251d47bed17ddada*****41d97(完整的 Webhook)或者 06ff1823a060af772677680d9522b547bc2685251d47bed17ddada*****41d97(只保留 access token)

💬 企业微信 缩写: wecom

企业微信应用消息推送,免费,限制较少。

  1. 用电脑打开 https://work.weixin.qq.com/,注册一个企业
  2. 注册成功后,点「管理企业」进入管理界面,选择「应用管理」 → 「自建」 → 「创建应用」
  3. 应用名称填入机器人的名称,应用 logo 选择机器人的头像,可见范围选择公司名
  4. 创建完成后进入应用详情页,可以得到应用ID( agentid ),应用Secret( secret ),复制
    PS:获取应用Secret时,可能会将其推送到企业微信客户端,这时候微信里边是看不到的,需要在企业微信客户端里边才能看到
  5. 进入「我的企业」页面,拉到最下边,可以看到企业ID,复制
  6. 进入「我的企业」 → 「微信插件」,拉到下边扫描二维码,关注以后即可收到推送的消息
  7. 将第 4 步和第 5 步取得的 企业ID#应用Secret#应用ID 拼到一起,中间用 “#” 号分隔,填入 pushoo 的 token 中

示例 token:ww97a01a*****1e5f1#xHapDXmgZtlBgRQQXMb4kfh3y75Ynoubl*****l9ytE#1000005

PS:如果出现接口请求正常,企业微信接受消息正常,个人微信无法收到消息的情况,请确认如下配置:

  • 进入「我的企业」 → 「微信插件」,拉到最下方,勾选「允许成员在微信插件中接收和回复聊天消息 」
  • 在企业微信客户端 「我」 → 「设置」 → 「新消息通知」中关闭「仅在企业微信中接受消息」限制条件

💬 Bark 缩写: bark

Bark 是 iOS 通知中心推送工具,可以推送消息到苹果手机上,免费。

  1. 下载 Bark APP
  2. 轻触下方 “服务器”,复制第一个服务器地址,删除 “这里改成你自己的推送内容” 字样,填入 pushoo 的 token 中

示例 token:https://api.day.app/q2S4vQqpNyaS*****9neeJ/(完整的 URL)或者 q2S4vQqpNyaS*****9neeJ(只保留 token)

💬 go-cqhttp 缩写: gocqhttp

go-cqhttp 是开源 QQ 机器人程序,免费,需自行搭建,插件十分丰富,但 “野生” 机器人并没有得到 Tencent 官方的支持,有账号被冻结的风险。

  1. 前往 go-cqhttp release 下载对应系统版本
  2. 此处省略安装过程,可参考 https://docs.go-cqhttp.org/guide/quick_start.html
  3. 修改配置文件,配置 default-middlewares 下面的 access-token,启动 go-cqhttp
  4. 按照示例所示的 API 调用地址,填入 pushoo 的 token 中

示例 token:http://你的IP或域名:端口号/send_private_msg?user_id=QQ号&token=你配置的token(QQ号)或 http://你的IP或域名:端口号/send_group_msg?group_id=群号&token=你配置的token(QQ群)

💬 atri 缩写: atri

go-cqhttp 是开源 QQ 机器人程序,由Tianli提供的pushoo推送服务。

使用前请加机器人好友(QQ:2102916311)

示例 token:1627236613(QQ号)

💬 PushDeer 缩写: pushdeer

PushDeer 是方糖一个开源的无 APP 推送解决方案,支持 iOS 14+ 轻应用、MacOS 11+ 客户端、Android 快应用,免费。

  1. 前往 https://www.pushdeer.com/product.html 扫码打开轻应用并登录
  2. 轻触下方 “Key”,轻触右上角 “+” 号创建第一个 Key,复制,填入 pushoo 的 token 中

示例 token:PDU431TfFHZICvR6lJrFBswSRN1cJ*****zzFvR

💬 iGot 缩写: igot

iGot 是一款聚合 APP、邮箱、微信等多种推送方式的第三方推送平台,免费,存在影响体验的广告。

  1. 根据 https://push.hellyw.com/doc/ 的说明,获取推送 key,填入 pushoo 的 token 中

示例 token:621f3b1dd2eba1*****101d9

💬 Telegram 缩写: telegram

Telegram 是自由的聊天工具,支持机器人 API,免费,**大陆服务器无法使用这种推送方式。

  1. 通过 @BotFather 创建机器人,并获取 api_token
  2. 通过 @userinfobot 获取接受消息对象的 chat_id。接受消息的对象可以是用户,频道,或群组
  3. 将第 1 步和第 2 步取得的 api_token#chat_id 拼到一起,中间用 “#” 号分隔,填入 pushoo 的 token 中

示例 token:5262***170:AAEzkaMjOayU13fFzcg9PI7_7*****p1iAs#958***732

💬 飞书 缩写: feishu

飞书是字节跳动旗下的办公即时消息软件,官方提供了机器人 API,可实现消息推送,免费。推送的消息必须包含配置的关键字,否则推送不成功。只能在群聊中创建机器人。

  1. 进入群组,打开会话设置,找到群机器人,并点击添加机器人,选择自定义机器人并添加。如果是在 Twikoo 评论系统中使用,请配置关键字为 “评论”
  2. 复制机器人的 Webhook,填入 pushoo 的 token 中

示例 token:https://open.feishu.cn/open-apis/bot/v2/hook/393df85f-7b2c-4ff6-bd4f-*******3ed54(完整的 Webhook)或者 393df85f-7b2c-4ff6-bd4f-*******3ed54(只保留 access token)

💬 IFTTT 缩写: ifttt

IFTTT Webhooks推送,免费。

  1. 首先打开 http://ifttt.com/maker,确保你的WebHooks服务是可以用;
  2. 点击 Document 获取你的 Key, 点击 Create 开始创建一个Applet;
  3. If this Then that, this选择WebHooks,Trigger选择Receive a web request,Event Name填一个有意义的,如 push
  4. if this then that, that选择Notification,参数填Value1 、Value2、Value3;
  5. 将 2 步获取的 key 和 第 3 步设置的 Event Name 拼接到一起,中间用 “#” 号分隔,填入 pushoo 的 token 中。

示例 token:d-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#push

PS: title 和 content 会分别对应 Value1 和 Value2,如果要设置 Value3 请在 options 设置

💬 WECOMBOT 缩写: wecombot

企业微信群机器人推送,免费。

  1. 使用企业微信,作为群管理员,创建一个群机器人,复制出机器人的 Webhook;
  2. 然后在 Webhook 中提取出 key 值,填入 pushoo 的 token 中.

示例 token: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx-xxxx-xx Webhook中提取Token为 xxxxxxxx-xxxx-xx;

💬 Discord 缩写: discord

Discord Webhooks推送,免费。

  1. 打开Discord,进入频道设置,找到webhook,点击创建webhook
  2. 复制webhook的url,将整个URL填入pushoo的token中。
  3. 如果需要设置用户名和头像,可以在options中设置。
  4. token 设置也可以通过提取 webhook url 中的 idtoken 来设置,格式为 id#token。 如:https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyz,则 token 设置为 123456789012345678#abcdefghijklmnopqrstuvwxyz

示例 token:

  • https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyz
  • 123456789012345678#abcdefghijklmnopqrstuvwxyz

💬 WxPusher 缩写: wxpusher

WxPusher 是一款微信推送平台,免费。

  1. 打开 https://wxpusher.zjiecode.com/docs/,注册账号,创建应用,获取 appToken;
  2. 创建主题,获取主题ID。如:1234
  3. 使用微信关注创建的主题,完成主题订阅;
  4. 如果需要设置特定推送用户,可以在 options 中设置 uids; 如果要设置消息跳转链接,可以在 options 中设置 url;如果需要设置验证支付,可以在 options 中设置 verifyPay
  5. 最后获取的 appTokentopicId 拼接到一起,中间用 “#” 号分隔,填入 pushoo 的 token 中(如果有多个主题ID,可用半角逗号分隔)。

示例 token:

  • 单个主题ID:AT_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX#1234
  • 多个主题ID:AT_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX#1234,5678

pushoo's People

Contributors

funnyzak avatar gahotx avatar imaegoo avatar kkfive avatar thatcoders avatar tianli0 avatar w4j1e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pushoo's Issues

建议将项目中的 Server酱 链接换成推荐链接

您好,我是 Server酱的作者 Easy 。注意到您的项目中对接或提及了 Server酱,非常感谢对我们的支持。

这里有一个小建议。Server酱最近推出了「推荐返现计划」,您可以在项目中Server酱的官网链接后边加上推荐参数,这样在用户从这里进入Server酱并订阅会员后,您的项目将获得2元/单的佣金。

只需要用微信登录fx.ftqq.com ,然后开通计划就可以获得您的推荐链接,佣金会实时地转入开通账号的微信零钱中。

希望这个计划能让您的开源项目更好。


Hello, I am Easy, the author of ServerChan. I noticed that your project has integrated or mentioned ServerChan, and I am very grateful for that.

I have a small suggestion. ServerChan has recently launched a "Referral Cashback Program". You can add a referral parameter to the link to ServerChan's official website in your project. This way, when users enter ServerChan through your link and subscribe to a membership, your project will earn a commission of 2 RMB per subscription.

You just need to log in to fx.ftqq.com with WeChat, activate the program, and you will get your referral link. The commission will be instantly transferred to the WeChat Wallet of the account that activated the program.

Even though the earnings might not be substantial, I hope this program can provide some additional support for your open-source project.

gocqhttp明明按照格式填了还是报错

即时消息通知结果: {
status: 'failed',
retcode: 10003,

{
url: '/send_private_msg?user_id=542149277',
error: 'Lack of param user_id'
}
}
但是我按格式发到浏览器 是能发送到我的QQ的

Qmsg消息违规被屏蔽

请注意,为避免 Qmsg 酱被 Tencent 冻结,pushoo 会自动删除消息中的网址和 IP 地址。

按照 pushoo 文档,向 Qmsg 推送的消息会删除网址,但邮箱字段含有网址并未被删除,导致消息被 Qmsg 屏蔽,无法收到通知。

消息记录(近30条)
私聊消息 2024-07-17 20:10:34 消息违规
Qmsg酱 blue
纸鹿摸鱼处有新评论了 评论人:gongfuture ([email protected]) 评论人IP: 评论内容:原来还有其他版本的客户端嘛,我还捯饬了挺久的hhh,我去搜搜看 原文链接:(outlook.com违规)

私聊消息 2024-07-14 16:21:35 消息违规
Qmsg酱 blue
纸鹿摸鱼处有新评论了 评论人:gongfuture ([email protected]) 评论人IP: 评论内容:好像displayswitch /internal也要改成displayswitch /extend 原文链接:(outlook.com违规)

希望在向 Qmsg 推送时删除邮箱字段,以免被屏蔽消息。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.