diff --git a/README.md b/README.md index 2645b6cd65..9915ca48c7 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,21 @@ wechat-public-account-push 实现自消息推送的原理,是通过调用一 **其他通道** +> 免费版每个接收用户每天允许推送200条消息,付费版每个接收用户每天1000条 +> +> 1分钟内接收5次请求,超出的请求将不再推送。另外对于相同的内容,1小时内限制发送3条。 +> +> 消息推送时显示的是 **设备通知**,标题需要**进入公众号查看** +> +> 消息放置在消息列表,方便随时查看 +> +> 不再是xxxx测试号,而是推送加服务号,更美观 +> +> 此通道[可能会被腾讯弃用](https://developers.weixin.qq.com/community/minihome/doc/000a46c7eb8468ba1a1cc863e51401),请评估风险后再选择 +> + +[⭐pushplus推送加服务号 >>> 点击使用](./docs/message-channel/push-plus.md) + > 免费版每个接收用户每天允许推送5条消息,付费版每个接收用户每天1000条 > > 消息推送时显示的是 **设备通知**,标题需要**进入公众号查看** @@ -172,6 +187,8 @@ wechat-public-account-push 实现自消息推送的原理,是通过调用一 [❓配置自动生成 教程 >>>](https://github.com/shuangxunian/wechat-form) +[❓配置完成后如何手动运行或者更改自动运行时间? 点开链接查看4. 5. >>>](./docs/how-to-use/github-actions.md) + #### 1.2.2 方式二:使用Github-Action(不准时,排队执行,胜在免费) > 世界上最大的同性交友平台(不是),需要一定的英语基础,**编辑的时候请不要使用网页的自动翻译** diff --git a/docs/how-to-use/config-demo.md b/docs/how-to-use/config-demo.md index 0a8925409c..dcab6c451f 100644 --- a/docs/how-to-use/config-demo.md +++ b/docs/how-to-use/config-demo.md @@ -9,11 +9,12 @@ const USER_CONFIG = { * 基本配置 */ - // 使用的推送通道:['push-deer', 'wechat-test', 'server-chan'] + // 使用的推送通道:['push-deer', 'wechat-test', 'server-chan', 'push-plus'] // 默认使用 【微信测试号】 // 使用【pushDeer】请填写 push-deer // 使用【微信测试号】请填写 wechat-test // 使用【方糖服务号】请填写 server-chan + // 使用【pushplus推送加服务号】请填写 push-plus USE_PASSAGE: 'wechat-test', // 使用微信测试号时才需要填写:公众号APP_ID diff --git a/docs/message-channel/push-plus.md b/docs/message-channel/push-plus.md new file mode 100644 index 0000000000..4aee6992ec --- /dev/null +++ b/docs/message-channel/push-plus.md @@ -0,0 +1,63 @@ +[📌返回首页 >>>](../../README.md) + +# 使用PushDeer + +运行图示: + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/server-chan3.jpg) + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/server-chan4.jpg) + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/server-chan2.jpg) + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/push-plus.png) + +## Ⅰ. 注册并使用push-plus服务 + +- 浏览器打开并登录 [push-plus首页](https://www.pushplus.plus/login.html) + + ![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/use-push-plus.png) + + ![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/use-push-plus-2.png) + +- 复制你的token保存备用 + + ![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/use-push-plus-4.png) + +## Ⅱ. 进行模板配置 + +仓库`config/template-config.cjs` 已内置两个模板,可以根据个人需求进行相应修改 + +> 模板中{{***.DATA}}都对应相应的数据,需要就保留,不需要就删掉 + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/template-config.png) + +## Ⅲ. 进行基础config配置 + +### 打开仓库中`config/index.cjs`的进行,进行编辑 + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/how-to-use/github-into-config.png) + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/how-to-use/github-into-config-2.png) + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/how-to-use/github-into-config-3.png) + +### 1. 使用push-plus模式 + ```javascript + // 请将以下代码按照图示粘贴到对应位置 + USE_PASSAGE: 'push-plus', + ``` +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/use-push-plus-3.png) + +### 2. 你的token填到哪里? + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/use-push-deer.png) + +### 3. Ⅲ. 中的模板id填到哪里? + +![图片无法查看请移步顶部访问 国内备用仓库地址](../../img/message-channel/use-push-deer2.png) + + +**以上步骤完成后请返回首页继续进行后续操作** + +[📌返回首页 >>>](../../README.md) \ No newline at end of file diff --git a/img/message-channel/push-plus.png b/img/message-channel/push-plus.png new file mode 100644 index 0000000000..56301f2db5 Binary files /dev/null and b/img/message-channel/push-plus.png differ diff --git a/img/message-channel/use-push-plus-2.png b/img/message-channel/use-push-plus-2.png new file mode 100644 index 0000000000..39a4d12258 Binary files /dev/null and b/img/message-channel/use-push-plus-2.png differ diff --git a/img/message-channel/use-push-plus-3.png b/img/message-channel/use-push-plus-3.png new file mode 100644 index 0000000000..47c2c7d5d7 Binary files /dev/null and b/img/message-channel/use-push-plus-3.png differ diff --git a/img/message-channel/use-push-plus-4.png b/img/message-channel/use-push-plus-4.png new file mode 100644 index 0000000000..a7d122a333 Binary files /dev/null and b/img/message-channel/use-push-plus-4.png differ diff --git a/img/message-channel/use-push-plus.png b/img/message-channel/use-push-plus.png new file mode 100644 index 0000000000..7499c2a57c Binary files /dev/null and b/img/message-channel/use-push-plus.png differ diff --git a/src/services/index.js b/src/services/index.js index cce54589ba..0ae77fe266 100644 --- a/src/services/index.js +++ b/src/services/index.js @@ -893,6 +893,50 @@ const sendMessageByPushDeer = async (user, templateId, wxTemplateData) => { } } +/** + * 使用pushplus + * @param user + * @param templateId + * @param wxTemplateData + * @returns {Promise<{success: boolean, name}>} + */ +const sendMessageByPushPlus = async (user, templateId, wxTemplateData) => { + // 模板拼装 + const modelData = model2Data(templateId, wxTemplateData, false, false) + if (!modelData) { + return { + name: user.name, + success: false, + } + } + + const url = 'http://www.pushplus.plus/send' + // 发送消息 + const res = await axios.post(url, { + token: user.id, + title: modelData.title, + content: modelData.desc, + template: 'markdown', + }, { + headers: { + 'Content-Type': 'application/json', + }, + }).catch((err) => err) + + if (res.data && res.data.code === 200) { + console.log(`${user.name}: 推送消息成功`) + return { + name: user.name, + success: true, + } + } + console.error(`${user.name}: 推送消息失败`, res) + return { + name: user.name, + success: false, + } +} + /** * 使用server-chan * @param user @@ -1019,6 +1063,9 @@ export const sendMessage = async (templateId, user, params, usePassage) => { } if (usePassage === 'server-chan') { console.log('使用server-chan推送') return sendMessageByServerChan(user, templateId, wxTemplateData) + } if (usePassage === 'push-plus') { + console.log('使用push-plus推送') + return sendMessageByPushPlus(user, templateId, wxTemplateData) } console.log('使用微信测试号推送')