We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
企业微信机器人 调用机器人的web hook,发起一个post请求,就可以把消息发送到包含该机器人的企业微信群组中。
主要使用nodejs ,node-cron, axios来实现。
nodejs
node-cron
axios
const axios = require('axios'); const cron = require('node-cron'); const express = require('express'); const app = express(); const URL = 'https://qyapi.weixin.qq.com/xxxxxxxxxxxxxxxx' // 机器人的web hook地址 const PORT = 8578; const sendTextMsg = (url, msg) => { try { axios.post(url, { msgtype: 'text', text: { content: msg, mentioned_list: ['@all'] // 通知所有人 } }) } catch (error) { console.log(error) } } app.listen(PORT) // 在每天19:00 的时候会发消息到群组中 cron.schedule("0 19 * * *", function() { sendTextMsg(URL, '记得填写每日工作任务汇报'); console.log("running a task call sendTextMsg"); });
该nodejs 程序使用pm2来管理
安装pm2
npm i pm2 -g
pm2 // pm2: command not found
报以上错误,说明需要创建个软连接
首先找到pm2的安装目录
find / -name pm2 /usr/local/Celler/node/12.6.0/bin/pm2 // ....
得到的路径从上到下依次尝试创建软连接
ln -s /usr/local/Celler/node/12.6.0/bin/pm2 /usr/local/bin/pm2
如提示ln: creating symbolic link /usr/local/bin/pm2': File exists` 则将软链接删除后重新创建
ln: creating symbolic link
# 删除软链接 mv /usr/local/bin/pm2 /tmp/ # 重新创建 ln -s /usr/local/Celler/node/12.6.0/bin/pm2 /usr/local/bin/pm2
# 查看结果 which pm2 # 结果 /usr/local/bin/pm2
开启程序
pm2 start index.js index
终止程序,stop后跟程序名字
pm2 stop index
The text was updated successfully, but these errors were encountered:
No branches or pull requests
企业微信机器人
调用机器人的web hook,发起一个post请求,就可以把消息发送到包含该机器人的企业微信群组中。
主要使用
nodejs
,node-cron
,axios
来实现。该nodejs 程序使用pm2来管理
安装pm2
pm2 // pm2: command not found
报以上错误,说明需要创建个软连接
首先找到pm2的安装目录
得到的路径从上到下依次尝试创建软连接
如提示
ln: creating symbolic link
/usr/local/bin/pm2': File exists`则将软链接删除后重新创建
开启程序
终止程序,stop后跟程序名字
The text was updated successfully, but these errors were encountered: