@whyour/qinglong 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sample/config.sample.sh +40 -9
- package/sample/notify.js +386 -507
- package/sample/notify.py +45 -4
- package/sample/ql_sample.js +11 -0
- package/sample/{test.py → ql_sample.py} +2 -0
- package/shell/share.sh +4 -4
- package/static/build/services/cron.js +7 -4
- package/static/build/services/notify.js +37 -4
- package/static/build/services/script.js +5 -2
- package/static/build/services/system.js +2 -2
- package/static/build/shared/pLimit.js +8 -0
- package/static/dist/419.3db0078b.async.js +1 -0
- package/static/dist/833.2736fc54.async.js +1 -0
- package/static/dist/index.html +1 -1
- package/static/dist/src__pages__config__index.aac592a5.async.js +1 -0
- package/static/dist/src__pages__crontab__detail.f691fe2e.async.js +1 -0
- package/static/dist/src__pages__crontab__index.07741ece.async.js +1 -0
- package/static/dist/src__pages__crontab__index.5bbea517.chunk.css +1 -0
- package/static/dist/src__pages__crontab__modal.ad51946f.async.js +1 -0
- package/static/dist/src__pages__dependence__logModal.c5a14f52.async.js +1 -0
- package/static/dist/src__pages__dependence__modal.6c4464a7.async.js +1 -0
- package/static/dist/src__pages__env__editNameModal.95e1a409.async.js +1 -0
- package/static/dist/src__pages__env__modal.44744cbd.async.js +1 -0
- package/static/dist/src__pages__error__index.e57ca77b.async.js +1 -0
- package/static/dist/src__pages__initialization__index.77ae800f.async.js +1 -0
- package/static/dist/src__pages__script__editModal.3a322b87.async.js +1 -0
- package/static/dist/src__pages__script__editNameModal.47d0b164.async.js +1 -0
- package/static/dist/src__pages__script__index.64391ed8.async.js +1 -0
- package/static/dist/src__pages__script__renameModal.13cccb93.async.js +1 -0
- package/static/dist/src__pages__script__saveModal.11771975.async.js +1 -0
- package/static/dist/src__pages__script__setting.45f668a1.async.js +1 -0
- package/static/dist/src__pages__setting__appModal.b8c9bd3c.async.js +1 -0
- package/static/dist/src__pages__setting__dependence.a3fd86f3.async.js +1 -0
- package/static/dist/{src__pages__setting__index.7ab054fb.async.js → src__pages__setting__index.a98235ab.async.js} +1 -1
- package/static/dist/src__pages__setting__notification.38ed438e.async.js +1 -0
- package/static/dist/src__pages__setting__security.c11b8cbe.async.js +1 -0
- package/static/dist/src__pages__subscription__modal.55630242.async.js +1 -0
- package/static/dist/{umi.11c81ea6.js → umi.35a4566e.js} +1 -1
- package/version.yaml +8 -10
- package/sample/test.js +0 -8
- package/static/dist/419.71c3c9c2.async.js +0 -1
- package/static/dist/833.ea0fd669.async.js +0 -1
- package/static/dist/src__pages__config__index.634c902a.async.js +0 -1
- package/static/dist/src__pages__crontab__detail.a2bfd72a.async.js +0 -1
- package/static/dist/src__pages__crontab__index.73fc56e9.chunk.css +0 -1
- package/static/dist/src__pages__crontab__index.98d464c0.async.js +0 -1
- package/static/dist/src__pages__crontab__modal.5f353876.async.js +0 -1
- package/static/dist/src__pages__dependence__logModal.baba01d6.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.663609bb.async.js +0 -1
- package/static/dist/src__pages__env__editNameModal.64e264d4.async.js +0 -1
- package/static/dist/src__pages__env__modal.ee1dbbc7.async.js +0 -1
- package/static/dist/src__pages__error__index.388743c5.async.js +0 -1
- package/static/dist/src__pages__initialization__index.b522cc95.async.js +0 -1
- package/static/dist/src__pages__script__editModal.1822dae7.async.js +0 -1
- package/static/dist/src__pages__script__editNameModal.3eabdcdb.async.js +0 -1
- package/static/dist/src__pages__script__index.8d14185b.async.js +0 -1
- package/static/dist/src__pages__script__renameModal.8bbbc126.async.js +0 -1
- package/static/dist/src__pages__script__saveModal.2012fa2c.async.js +0 -1
- package/static/dist/src__pages__script__setting.0daecd62.async.js +0 -1
- package/static/dist/src__pages__setting__appModal.476d1f54.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.28193e94.async.js +0 -1
- package/static/dist/src__pages__setting__notification.dd201d2a.async.js +0 -1
- package/static/dist/src__pages__setting__security.dbfad79b.async.js +0 -1
- package/static/dist/src__pages__subscription__modal.69a7f91a.async.js +0 -1
package/sample/notify.js
CHANGED
|
@@ -1,399 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
* @Author: lxk0301 https://gitee.com/lxk0301
|
|
3
|
-
* @Date: 2020-08-19 16:12:40
|
|
4
|
-
* @Last Modified by: whyour
|
|
5
|
-
* @Last Modified time: 2021-5-1 15:00:54
|
|
6
|
-
* sendNotify 推送通知功能
|
|
7
|
-
* @param text 通知头
|
|
8
|
-
* @param desp 通知体
|
|
9
|
-
* @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' }
|
|
10
|
-
* @param author 作者仓库等信息 例:`本通知 By:https://github.com/whyour/qinglong`
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const querystring = require('querystring');
|
|
1
|
+
const querystring = require('node:querystring');
|
|
14
2
|
const got = require('got');
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
// PUSH_PLUS_TOKEN:微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送
|
|
112
|
-
// PUSH_PLUS_USER: 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)
|
|
113
|
-
let PUSH_PLUS_TOKEN = '';
|
|
114
|
-
let PUSH_PLUS_USER = '';
|
|
115
|
-
|
|
116
|
-
// =======================================智能微秘书设置区域=======================================
|
|
117
|
-
// 官方文档:http://wechat.aibotk.com/docs/about
|
|
118
|
-
// AIBOTK_KEY: 填写智能微秘书个人中心的apikey
|
|
119
|
-
// AIBOTK_TYPE:填写发送的目标 room 或 contact, 填其他的不生效
|
|
120
|
-
// AIBOTK_NAME: 填写群名或用户昵称,和上面的type类型要对应
|
|
121
|
-
let AIBOTK_KEY = '';
|
|
122
|
-
let AIBOTK_TYPE = '';
|
|
123
|
-
let AIBOTK_NAME = '';
|
|
124
|
-
|
|
125
|
-
// =======================================飞书机器人设置区域=======================================
|
|
126
|
-
// 官方文档:https://www.feishu.cn/hc/zh-CN/articles/360024984973
|
|
127
|
-
// FSKEY 飞书机器人的 FSKEY
|
|
128
|
-
let FSKEY = '';
|
|
129
|
-
|
|
130
|
-
// =======================================SMTP 邮件设置区域=======================================
|
|
131
|
-
// SMTP_SERVICE: 邮箱服务名称,比如126、163、Gmail、QQ等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
|
132
|
-
// SMTP_EMAIL: 填写 SMTP 收发件邮箱,通知将会由自己发给自己
|
|
133
|
-
// SMTP_PASSWORD: 填写 SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
|
134
|
-
// SMTP_NAME: 填写 SMTP 收发件人姓名,可随意填写
|
|
135
|
-
let SMTP_SERVICE = '';
|
|
136
|
-
let SMTP_EMAIL = '';
|
|
137
|
-
let SMTP_PASSWORD = '';
|
|
138
|
-
let SMTP_NAME = '';
|
|
139
|
-
|
|
140
|
-
// =======================================PushMe通知设置区域===========================================
|
|
141
|
-
// 官方文档:https://push.i-i.me/
|
|
142
|
-
// 此处填你的PushMe KEY.
|
|
143
|
-
let PUSHME_KEY = '';
|
|
144
|
-
|
|
145
|
-
// =======================================CHRONOCAT通知设置区域===========================================
|
|
146
|
-
// CHRONOCAT_URL Red协议连接地址 例: http://127.0.0.1:16530
|
|
147
|
-
// CHRONOCAT_TOKEN 填写在CHRONOCAT文件生成的访问密钥
|
|
148
|
-
// CHRONOCAT_QQ 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群
|
|
149
|
-
// CHRONOCAT相关API https://chronocat.vercel.app/install/docker/official/
|
|
150
|
-
let CHRONOCAT_URL = ''; // CHRONOCAT Red协议连接地址
|
|
151
|
-
let CHRONOCAT_TOKEN = ''; // CHRONOCAT 生成的访问密钥
|
|
152
|
-
let CHRONOCAT_QQ = ''; // 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx
|
|
153
|
-
|
|
154
|
-
// =======================================自定义通知设置区域=======================================
|
|
155
|
-
// 自定义通知 接收回调的URL
|
|
156
|
-
let WEBHOOK_URL = '';
|
|
157
|
-
let WEBHOOK_BODY = '';
|
|
158
|
-
let WEBHOOK_HEADERS = '';
|
|
159
|
-
let WEBHOOK_METHOD = '';
|
|
160
|
-
let WEBHOOK_CONTENT_TYPE = '';
|
|
161
|
-
|
|
162
|
-
// ==========================云端环境变量的判断与接收=========================
|
|
163
|
-
if (process.env.GOTIFY_URL) {
|
|
164
|
-
GOTIFY_URL = process.env.GOTIFY_URL;
|
|
165
|
-
}
|
|
166
|
-
if (process.env.GOTIFY_TOKEN) {
|
|
167
|
-
GOTIFY_TOKEN = process.env.GOTIFY_TOKEN;
|
|
168
|
-
}
|
|
169
|
-
if (process.env.GOTIFY_PRIORITY) {
|
|
170
|
-
GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (process.env.GOBOT_URL) {
|
|
174
|
-
GOBOT_URL = process.env.GOBOT_URL;
|
|
175
|
-
}
|
|
176
|
-
if (process.env.GOBOT_TOKEN) {
|
|
177
|
-
GOBOT_TOKEN = process.env.GOBOT_TOKEN;
|
|
178
|
-
}
|
|
179
|
-
if (process.env.GOBOT_QQ) {
|
|
180
|
-
GOBOT_QQ = process.env.GOBOT_QQ;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (process.env.PUSH_KEY) {
|
|
184
|
-
SCKEY = process.env.PUSH_KEY;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (process.env.DEER_KEY) {
|
|
188
|
-
PUSHDEER_KEY = process.env.DEER_KEY;
|
|
189
|
-
PUSHDEER_URL = process.env.DEER_URL;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (process.env.CHAT_URL) {
|
|
193
|
-
CHAT_URL = process.env.CHAT_URL;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (process.env.CHAT_TOKEN) {
|
|
197
|
-
CHAT_TOKEN = process.env.CHAT_TOKEN;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (process.env.QQ_SKEY) {
|
|
201
|
-
QQ_SKEY = process.env.QQ_SKEY;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (process.env.QQ_MODE) {
|
|
205
|
-
QQ_MODE = process.env.QQ_MODE;
|
|
206
|
-
}
|
|
3
|
+
const timeout = 15000;
|
|
4
|
+
|
|
5
|
+
const push_config = {
|
|
6
|
+
HITOKOTO: true, // 启用一言(随机句子)
|
|
7
|
+
|
|
8
|
+
BARK_PUSH: '', // bark IP 或设备码,例:https://api.day.app/DxHcxxxxxRxxxxxxcm/
|
|
9
|
+
BARK_ARCHIVE: '', // bark 推送是否存档
|
|
10
|
+
BARK_GROUP: '', // bark 推送分组
|
|
11
|
+
BARK_SOUND: '', // bark 推送声音
|
|
12
|
+
BARK_ICON: '', // bark 推送图标
|
|
13
|
+
BARK_LEVEL: '', // bark 推送时效性
|
|
14
|
+
BARK_URL: '', // bark 推送跳转URL
|
|
15
|
+
|
|
16
|
+
DD_BOT_SECRET: '', // 钉钉机器人的 DD_BOT_SECRET
|
|
17
|
+
DD_BOT_TOKEN: '', // 钉钉机器人的 DD_BOT_TOKEN
|
|
18
|
+
|
|
19
|
+
FSKEY: '', // 飞书机器人的 FSKEY
|
|
20
|
+
|
|
21
|
+
// 推送到个人QQ:http://127.0.0.1/send_private_msg
|
|
22
|
+
// 群:http://127.0.0.1/send_group_msg
|
|
23
|
+
GOBOT_URL: '', // go-cqhttp
|
|
24
|
+
// 推送到个人QQ 填入 user_id=个人QQ
|
|
25
|
+
// 群 填入 group_id=QQ群
|
|
26
|
+
GOBOT_QQ: '', // go-cqhttp 的推送群或用户
|
|
27
|
+
GOBOT_TOKEN: '', // go-cqhttp 的 access_token
|
|
28
|
+
|
|
29
|
+
GOTIFY_URL: '', // gotify地址,如https://push.example.de:8080
|
|
30
|
+
GOTIFY_TOKEN: '', // gotify的消息应用token
|
|
31
|
+
GOTIFY_PRIORITY: 0, // 推送消息优先级,默认为0
|
|
32
|
+
|
|
33
|
+
IGOT_PUSH_KEY: '', // iGot 聚合推送的 IGOT_PUSH_KEY,例如:https://push.hellyw.com/XXXXXXXX
|
|
34
|
+
|
|
35
|
+
PUSH_KEY: '', // server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
|
|
36
|
+
|
|
37
|
+
DEER_KEY: '', // PushDeer 的 PUSHDEER_KEY
|
|
38
|
+
DEER_URL: '', // PushDeer 的 PUSHDEER_URL
|
|
39
|
+
|
|
40
|
+
CHAT_URL: '', // synology chat url
|
|
41
|
+
CHAT_TOKEN: '', // synology chat token
|
|
42
|
+
|
|
43
|
+
// 官方文档:http://www.pushplus.plus/
|
|
44
|
+
PUSH_PLUS_TOKEN: '', // push+ 微信推送的用户令牌
|
|
45
|
+
PUSH_PLUS_USER: '', // push+ 微信推送的群组编码
|
|
46
|
+
|
|
47
|
+
// 微加机器人,官方网站:https://www.weplusbot.com/
|
|
48
|
+
WE_PLUS_BOT_TOKEN: '', // 微加机器人的用户令牌
|
|
49
|
+
WE_PLUS_BOT_RECEIVER: '', // 微加机器人的消息接收人
|
|
50
|
+
WE_PLUS_BOT_VERSION: 'pro', //微加机器人调用版本,pro和personal;为空默认使用pro(专业版),个人版填写:personal
|
|
51
|
+
|
|
52
|
+
QMSG_KEY: '', // qmsg 酱的 QMSG_KEY
|
|
53
|
+
QMSG_TYPE: '', // qmsg 酱的 QMSG_TYPE
|
|
54
|
+
|
|
55
|
+
QYWX_ORIGIN: 'https://qyapi.weixin.qq.com', // 企业微信代理地址
|
|
56
|
+
|
|
57
|
+
/*
|
|
58
|
+
此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236)
|
|
59
|
+
环境变量名 QYWX_AM依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型)
|
|
60
|
+
注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat
|
|
61
|
+
可选推送消息类型(推荐使用图文消息(mpnews)):
|
|
62
|
+
- 文本卡片消息: 0 (数字零)
|
|
63
|
+
- 文本消息: 1 (数字一)
|
|
64
|
+
- 图文消息(mpnews): 素材库图片id, 可查看此教程(http://note.youdao.com/s/HMiudGkb)或者(https://note.youdao.com/ynoteshare1/index.html?id=1a0c8aff284ad28cbd011b29b3ad0191&type=note)
|
|
65
|
+
*/
|
|
66
|
+
QYWX_AM: '', // 企业微信应用
|
|
67
|
+
|
|
68
|
+
QYWX_KEY: '', // 企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
|
|
69
|
+
|
|
70
|
+
TG_BOT_TOKEN: '', // tg 机器人的 TG_BOT_TOKEN,例:1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ
|
|
71
|
+
TG_USER_ID: '', // tg 机器人的 TG_USER_ID,例:1434078534
|
|
72
|
+
TG_API_HOST: 'https://api.telegram.org', // tg 代理 api
|
|
73
|
+
TG_PROXY_AUTH: '', // tg 代理认证参数
|
|
74
|
+
TG_PROXY_HOST: '', // tg 机器人的 TG_PROXY_HOST
|
|
75
|
+
TG_PROXY_PORT: '', // tg 机器人的 TG_PROXY_PORT
|
|
76
|
+
|
|
77
|
+
AIBOTK_KEY: '', // 智能微秘书 个人中心的apikey 文档地址:http://wechat.aibotk.com/docs/about
|
|
78
|
+
AIBOTK_TYPE: '', // 智能微秘书 发送目标 room 或 contact
|
|
79
|
+
AIBOTK_NAME: '', // 智能微秘书 发送群名 或者好友昵称和type要对应好
|
|
80
|
+
|
|
81
|
+
SMTP_SERVICE: '', // 邮箱服务名称,比如 126、163、Gmail、QQ 等,支持列表 https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json
|
|
82
|
+
SMTP_EMAIL: '', // SMTP 收发件邮箱,通知将会由自己发给自己
|
|
83
|
+
SMTP_PASSWORD: '', // SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
|
84
|
+
SMTP_NAME: '', // SMTP 收发件人姓名,可随意填写
|
|
85
|
+
|
|
86
|
+
PUSHME_KEY: '', // 官方文档:https://push.i-i.me,PushMe 酱的 PUSHME_KEY
|
|
87
|
+
|
|
88
|
+
// CHRONOCAT API https://chronocat.vercel.app/install/docker/official/
|
|
89
|
+
CHRONOCAT_QQ: '', // 个人: user_id=个人QQ 群则填入 group_id=QQ群 多个用英文;隔开同时支持个人和群
|
|
90
|
+
CHRONOCAT_TOKEN: '', // 填写在CHRONOCAT文件生成的访问密钥
|
|
91
|
+
CHRONOCAT_URL: '', // Red 协议连接地址 例: http://127.0.0.1:16530
|
|
92
|
+
|
|
93
|
+
WEBHOOK_URL: '', // 自定义通知 请求地址
|
|
94
|
+
WEBHOOK_BODY: '', // 自定义通知 请求体
|
|
95
|
+
WEBHOOK_HEADERS: '', // 自定义通知 请求头
|
|
96
|
+
WEBHOOK_METHOD: '', // 自定义通知 请求方法
|
|
97
|
+
WEBHOOK_CONTENT_TYPE: '', // 自定义通知 content-type
|
|
98
|
+
};
|
|
207
99
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
// 兼容BARK自建用户
|
|
214
|
-
BARK_PUSH = process.env.BARK_PUSH;
|
|
215
|
-
} else {
|
|
216
|
-
BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}`;
|
|
217
|
-
}
|
|
218
|
-
if (process.env.BARK_ICON) {
|
|
219
|
-
BARK_ICON = process.env.BARK_ICON;
|
|
220
|
-
}
|
|
221
|
-
if (process.env.BARK_SOUND) {
|
|
222
|
-
BARK_SOUND = process.env.BARK_SOUND;
|
|
223
|
-
}
|
|
224
|
-
if (process.env.BARK_GROUP) {
|
|
225
|
-
BARK_GROUP = process.env.BARK_GROUP;
|
|
226
|
-
}
|
|
227
|
-
if (process.env.BARK_LEVEL) {
|
|
228
|
-
BARK_LEVEL = process.env.BARK_LEVEL;
|
|
229
|
-
}
|
|
230
|
-
if (process.env.BARK_URL) {
|
|
231
|
-
BARK_URL = process.env.BARK_URL;
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
if (
|
|
235
|
-
BARK_PUSH &&
|
|
236
|
-
BARK_PUSH.indexOf('https') === -1 &&
|
|
237
|
-
BARK_PUSH.indexOf('http') === -1
|
|
238
|
-
) {
|
|
239
|
-
// 兼容BARK本地用户只填写设备码的情况
|
|
240
|
-
BARK_PUSH = `https://api.day.app/${BARK_PUSH}`;
|
|
100
|
+
// 首先读取 面板变量 或者 github action 运行变量
|
|
101
|
+
for (const key in push_config) {
|
|
102
|
+
const v = process.env[key];
|
|
103
|
+
if (v) {
|
|
104
|
+
push_config[key] = v;
|
|
241
105
|
}
|
|
242
106
|
}
|
|
243
|
-
if (process.env.TG_BOT_TOKEN) {
|
|
244
|
-
TG_BOT_TOKEN = process.env.TG_BOT_TOKEN;
|
|
245
|
-
}
|
|
246
|
-
if (process.env.TG_USER_ID) {
|
|
247
|
-
TG_USER_ID = process.env.TG_USER_ID;
|
|
248
|
-
}
|
|
249
|
-
if (process.env.TG_PROXY_AUTH) TG_PROXY_AUTH = process.env.TG_PROXY_AUTH;
|
|
250
|
-
if (process.env.TG_PROXY_HOST) TG_PROXY_HOST = process.env.TG_PROXY_HOST;
|
|
251
|
-
if (process.env.TG_PROXY_PORT) TG_PROXY_PORT = process.env.TG_PROXY_PORT;
|
|
252
|
-
if (process.env.TG_API_HOST) TG_API_HOST = process.env.TG_API_HOST;
|
|
253
|
-
|
|
254
|
-
if (process.env.DD_BOT_TOKEN) {
|
|
255
|
-
DD_BOT_TOKEN = process.env.DD_BOT_TOKEN;
|
|
256
|
-
if (process.env.DD_BOT_SECRET) {
|
|
257
|
-
DD_BOT_SECRET = process.env.DD_BOT_SECRET;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (process.env.QYWX_ORIGIN) {
|
|
262
|
-
QYWX_ORIGIN = process.env.QYWX_ORIGIN;
|
|
263
|
-
} else {
|
|
264
|
-
QYWX_ORIGIN = 'https://qyapi.weixin.qq.com';
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (process.env.QYWX_KEY) {
|
|
268
|
-
QYWX_KEY = process.env.QYWX_KEY;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (process.env.QYWX_AM) {
|
|
272
|
-
QYWX_AM = process.env.QYWX_AM;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (process.env.IGOT_PUSH_KEY) {
|
|
276
|
-
IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (process.env.PUSH_PLUS_TOKEN) {
|
|
280
|
-
PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN;
|
|
281
|
-
}
|
|
282
|
-
if (process.env.PUSH_PLUS_USER) {
|
|
283
|
-
PUSH_PLUS_USER = process.env.PUSH_PLUS_USER;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (process.env.AIBOTK_KEY) {
|
|
287
|
-
AIBOTK_KEY = process.env.AIBOTK_KEY;
|
|
288
|
-
}
|
|
289
|
-
if (process.env.AIBOTK_TYPE) {
|
|
290
|
-
AIBOTK_TYPE = process.env.AIBOTK_TYPE;
|
|
291
|
-
}
|
|
292
|
-
if (process.env.AIBOTK_NAME) {
|
|
293
|
-
AIBOTK_NAME = process.env.AIBOTK_NAME;
|
|
294
|
-
}
|
|
295
107
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
if (process.env.WEBHOOK_BODY) {
|
|
330
|
-
WEBHOOK_BODY = process.env.WEBHOOK_BODY;
|
|
331
|
-
}
|
|
332
|
-
if (process.env.WEBHOOK_HEADERS) {
|
|
333
|
-
WEBHOOK_HEADERS = process.env.WEBHOOK_HEADERS;
|
|
334
|
-
}
|
|
335
|
-
if (process.env.WEBHOOK_METHOD) {
|
|
336
|
-
WEBHOOK_METHOD = process.env.WEBHOOK_METHOD;
|
|
337
|
-
}
|
|
338
|
-
if (process.env.WEBHOOK_CONTENT_TYPE) {
|
|
339
|
-
WEBHOOK_CONTENT_TYPE = process.env.WEBHOOK_CONTENT_TYPE;
|
|
340
|
-
}
|
|
341
|
-
// ==========================云端环境变量的判断与接收=========================
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* sendNotify 推送通知功能
|
|
345
|
-
* @param text 通知头
|
|
346
|
-
* @param desp 通知体
|
|
347
|
-
* @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' }
|
|
348
|
-
* @param author 作者仓库等信息 例:`本通知 By:https://github.com/whyour/qinglong`
|
|
349
|
-
* @returns {Promise<unknown>}
|
|
350
|
-
*/
|
|
351
|
-
async function sendNotify(
|
|
352
|
-
text,
|
|
353
|
-
desp,
|
|
354
|
-
params = {},
|
|
355
|
-
author = '\n\n本通知 By:https://github.com/whyour/qinglong',
|
|
356
|
-
) {
|
|
357
|
-
// 提供6种通知
|
|
358
|
-
desp += author; // 增加作者信息,防止被贩卖等
|
|
359
|
-
|
|
360
|
-
// 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔
|
|
361
|
-
let skipTitle = process.env.SKIP_PUSH_TITLE;
|
|
362
|
-
if (skipTitle) {
|
|
363
|
-
if (skipTitle.split('\n').includes(text)) {
|
|
364
|
-
console.info(text + '在SKIP_PUSH_TITLE环境变量内,跳过推送!');
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
108
|
+
const $ = {
|
|
109
|
+
post: (params, callback) => {
|
|
110
|
+
const { url, ...others } = params;
|
|
111
|
+
got.post(url, others).then(
|
|
112
|
+
(res) => {
|
|
113
|
+
let body = res.body;
|
|
114
|
+
try {
|
|
115
|
+
body = JSON.parse(body);
|
|
116
|
+
} catch (error) {}
|
|
117
|
+
callback(null, res, body);
|
|
118
|
+
},
|
|
119
|
+
(err) => {
|
|
120
|
+
callback(err?.response?.body || err);
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
},
|
|
124
|
+
get: (params, callback) => {
|
|
125
|
+
const { url, ...others } = params;
|
|
126
|
+
got.get(url, others).then(
|
|
127
|
+
(res) => {
|
|
128
|
+
let body = res.body;
|
|
129
|
+
try {
|
|
130
|
+
body = JSON.parse(body);
|
|
131
|
+
} catch (error) {}
|
|
132
|
+
callback(null, res, body);
|
|
133
|
+
},
|
|
134
|
+
(err) => {
|
|
135
|
+
callback(err?.response?.body || err);
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
logErr: console.log,
|
|
140
|
+
};
|
|
368
141
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text;
|
|
375
|
-
await Promise.all([
|
|
376
|
-
BarkNotify(text, desp, params), // iOS Bark APP
|
|
377
|
-
tgBotNotify(text, desp), // telegram 机器人
|
|
378
|
-
ddBotNotify(text, desp), // 钉钉机器人
|
|
379
|
-
qywxBotNotify(text, desp), // 企业微信机器人
|
|
380
|
-
qywxamNotify(text, desp), // 企业微信应用消息推送
|
|
381
|
-
iGotNotify(text, desp, params), // iGot
|
|
382
|
-
gobotNotify(text, desp), // go-cqhttp
|
|
383
|
-
gotifyNotify(text, desp), // gotify
|
|
384
|
-
ChatNotify(text, desp), // synolog chat
|
|
385
|
-
PushDeerNotify(text, desp), // PushDeer
|
|
386
|
-
aibotkNotify(text, desp), // 智能微秘书
|
|
387
|
-
fsBotNotify(text, desp), // 飞书机器人
|
|
388
|
-
smtpNotify(text, desp), // SMTP 邮件
|
|
389
|
-
pushMeNotify(text, desp, params), // PushMe
|
|
390
|
-
chronocatNotify(text, desp), // Chronocat
|
|
391
|
-
webhookNotify(text, desp), // 自定义通知
|
|
392
|
-
]);
|
|
142
|
+
async function one() {
|
|
143
|
+
const url = 'https://v1.hitokoto.cn/';
|
|
144
|
+
const res = await got.get(url);
|
|
145
|
+
const body = JSON.parse(res.body);
|
|
146
|
+
return `${body.hitokoto} ----${body.from}`;
|
|
393
147
|
}
|
|
394
148
|
|
|
395
149
|
function gotifyNotify(text, desp) {
|
|
396
150
|
return new Promise((resolve) => {
|
|
151
|
+
const { GOTIFY_URL, GOTIFY_TOKEN, GOTIFY_PRIORITY } = push_config;
|
|
397
152
|
if (GOTIFY_URL && GOTIFY_TOKEN) {
|
|
398
153
|
const options = {
|
|
399
154
|
url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`,
|
|
@@ -407,14 +162,12 @@ function gotifyNotify(text, desp) {
|
|
|
407
162
|
$.post(options, (err, resp, data) => {
|
|
408
163
|
try {
|
|
409
164
|
if (err) {
|
|
410
|
-
console.log('
|
|
411
|
-
console.log(err);
|
|
165
|
+
console.log('Gotify 发送通知调用API失败😞\n', err);
|
|
412
166
|
} else {
|
|
413
|
-
data = JSON.parse(data);
|
|
414
167
|
if (data.id) {
|
|
415
|
-
console.log('
|
|
168
|
+
console.log('Gotify 发送通知消息成功🎉\n');
|
|
416
169
|
} else {
|
|
417
|
-
console.log(
|
|
170
|
+
console.log(`Gotify 发送通知调用API失败😞 ${data.message}\n`);
|
|
418
171
|
}
|
|
419
172
|
}
|
|
420
173
|
} catch (e) {
|
|
@@ -431,6 +184,7 @@ function gotifyNotify(text, desp) {
|
|
|
431
184
|
|
|
432
185
|
function gobotNotify(text, desp) {
|
|
433
186
|
return new Promise((resolve) => {
|
|
187
|
+
const { GOBOT_URL, GOBOT_TOKEN, GOBOT_QQ } = push_config;
|
|
434
188
|
if (GOBOT_URL) {
|
|
435
189
|
const options = {
|
|
436
190
|
url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`,
|
|
@@ -443,16 +197,14 @@ function gobotNotify(text, desp) {
|
|
|
443
197
|
$.post(options, (err, resp, data) => {
|
|
444
198
|
try {
|
|
445
199
|
if (err) {
|
|
446
|
-
console.log('
|
|
447
|
-
console.log(err);
|
|
200
|
+
console.log('Go-cqhttp 通知调用API失败😞\n', err);
|
|
448
201
|
} else {
|
|
449
|
-
data = JSON.parse(data);
|
|
450
202
|
if (data.retcode === 0) {
|
|
451
|
-
console.log('
|
|
203
|
+
console.log('Go-cqhttp 发送通知消息成功🎉\n');
|
|
452
204
|
} else if (data.retcode === 100) {
|
|
453
|
-
console.log(`
|
|
205
|
+
console.log(`Go-cqhttp 发送通知消息异常 ${data.errmsg}\n`);
|
|
454
206
|
} else {
|
|
455
|
-
console.log(`
|
|
207
|
+
console.log(`Go-cqhttp 发送通知消息异常 ${JSON.stringify(data)}`);
|
|
456
208
|
}
|
|
457
209
|
}
|
|
458
210
|
} catch (e) {
|
|
@@ -469,13 +221,14 @@ function gobotNotify(text, desp) {
|
|
|
469
221
|
|
|
470
222
|
function serverNotify(text, desp) {
|
|
471
223
|
return new Promise((resolve) => {
|
|
472
|
-
|
|
224
|
+
const { PUSH_KEY } = push_config;
|
|
225
|
+
if (PUSH_KEY) {
|
|
473
226
|
// 微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换
|
|
474
227
|
desp = desp.replace(/[\n\r]/g, '\n\n');
|
|
475
228
|
const options = {
|
|
476
|
-
url:
|
|
477
|
-
? `https://sctapi.ftqq.com/${
|
|
478
|
-
: `https://sc.ftqq.com/${
|
|
229
|
+
url: PUSH_KEY.includes('SCT')
|
|
230
|
+
? `https://sctapi.ftqq.com/${PUSH_KEY}.send`
|
|
231
|
+
: `https://sc.ftqq.com/${PUSH_KEY}.send`,
|
|
479
232
|
body: `text=${text}&desp=${desp}`,
|
|
480
233
|
headers: {
|
|
481
234
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -485,18 +238,16 @@ function serverNotify(text, desp) {
|
|
|
485
238
|
$.post(options, (err, resp, data) => {
|
|
486
239
|
try {
|
|
487
240
|
if (err) {
|
|
488
|
-
console.log('
|
|
489
|
-
console.log(err);
|
|
241
|
+
console.log('Server 酱发送通知调用API失败😞\n', err);
|
|
490
242
|
} else {
|
|
491
|
-
data = JSON.parse(data);
|
|
492
243
|
// server酱和Server酱·Turbo版的返回json格式不太一样
|
|
493
244
|
if (data.errno === 0 || data.data.errno === 0) {
|
|
494
|
-
console.log('
|
|
245
|
+
console.log('Server 酱发送通知消息成功🎉\n');
|
|
495
246
|
} else if (data.errno === 1024) {
|
|
496
247
|
// 一分钟内发送相同的内容会触发
|
|
497
|
-
console.log(`
|
|
248
|
+
console.log(`Server 酱发送通知消息异常 ${data.errmsg}\n`);
|
|
498
249
|
} else {
|
|
499
|
-
console.log(`
|
|
250
|
+
console.log(`Server 酱发送通知消息异常 ${JSON.stringify(data)}`);
|
|
500
251
|
}
|
|
501
252
|
}
|
|
502
253
|
} catch (e) {
|
|
@@ -511,14 +262,15 @@ function serverNotify(text, desp) {
|
|
|
511
262
|
});
|
|
512
263
|
}
|
|
513
264
|
|
|
514
|
-
function
|
|
265
|
+
function pushDeerNotify(text, desp) {
|
|
515
266
|
return new Promise((resolve) => {
|
|
516
|
-
|
|
267
|
+
const { DEER_KEY, DEER_URL } = push_config;
|
|
268
|
+
if (DEER_KEY) {
|
|
517
269
|
// PushDeer 建议对消息内容进行 urlencode
|
|
518
270
|
desp = encodeURI(desp);
|
|
519
271
|
const options = {
|
|
520
|
-
url:
|
|
521
|
-
body: `pushkey=${
|
|
272
|
+
url: DEER_URL || `https://api2.pushdeer.com/message/push`,
|
|
273
|
+
body: `pushkey=${DEER_KEY}&text=${text}&desp=${desp}&type=markdown`,
|
|
522
274
|
headers: {
|
|
523
275
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
524
276
|
},
|
|
@@ -527,18 +279,18 @@ function PushDeerNotify(text, desp) {
|
|
|
527
279
|
$.post(options, (err, resp, data) => {
|
|
528
280
|
try {
|
|
529
281
|
if (err) {
|
|
530
|
-
console.log('
|
|
531
|
-
console.log(err);
|
|
282
|
+
console.log('PushDeer 通知调用API失败😞\n', err);
|
|
532
283
|
} else {
|
|
533
|
-
data = JSON.parse(data);
|
|
534
284
|
// 通过返回的result的长度来判断是否成功
|
|
535
285
|
if (
|
|
536
286
|
data.content.result.length !== undefined &&
|
|
537
287
|
data.content.result.length > 0
|
|
538
288
|
) {
|
|
539
|
-
console.log('PushDeer发送通知消息成功🎉\n');
|
|
289
|
+
console.log('PushDeer 发送通知消息成功🎉\n');
|
|
540
290
|
} else {
|
|
541
|
-
console.log(
|
|
291
|
+
console.log(
|
|
292
|
+
`PushDeer 发送通知消息异常😞 ${JSON.stringify(data)}`,
|
|
293
|
+
);
|
|
542
294
|
}
|
|
543
295
|
}
|
|
544
296
|
} catch (e) {
|
|
@@ -553,8 +305,9 @@ function PushDeerNotify(text, desp) {
|
|
|
553
305
|
});
|
|
554
306
|
}
|
|
555
307
|
|
|
556
|
-
function
|
|
308
|
+
function chatNotify(text, desp) {
|
|
557
309
|
return new Promise((resolve) => {
|
|
310
|
+
const { CHAT_URL, CHAT_TOKEN } = push_config;
|
|
558
311
|
if (CHAT_URL && CHAT_TOKEN) {
|
|
559
312
|
// 对消息内容进行 urlencode
|
|
560
313
|
desp = encodeURI(desp);
|
|
@@ -568,14 +321,12 @@ function ChatNotify(text, desp) {
|
|
|
568
321
|
$.post(options, (err, resp, data) => {
|
|
569
322
|
try {
|
|
570
323
|
if (err) {
|
|
571
|
-
console.log('发送通知调用API
|
|
572
|
-
console.log(err);
|
|
324
|
+
console.log('Chat 发送通知调用API失败😞\n', err);
|
|
573
325
|
} else {
|
|
574
|
-
data = JSON.parse(data);
|
|
575
326
|
if (data.success) {
|
|
576
|
-
console.log('Chat发送通知消息成功🎉\n');
|
|
327
|
+
console.log('Chat 发送通知消息成功🎉\n');
|
|
577
328
|
} else {
|
|
578
|
-
console.log(`Chat
|
|
329
|
+
console.log(`Chat 发送通知消息异常 ${JSON.stringify(data)}`);
|
|
579
330
|
}
|
|
580
331
|
}
|
|
581
332
|
} catch (e) {
|
|
@@ -590,13 +341,26 @@ function ChatNotify(text, desp) {
|
|
|
590
341
|
});
|
|
591
342
|
}
|
|
592
343
|
|
|
593
|
-
function
|
|
344
|
+
function barkNotify(text, desp, params = {}) {
|
|
594
345
|
return new Promise((resolve) => {
|
|
346
|
+
let {
|
|
347
|
+
BARK_PUSH,
|
|
348
|
+
BARK_ICON,
|
|
349
|
+
BARK_SOUND,
|
|
350
|
+
BARK_GROUP,
|
|
351
|
+
BARK_LEVEL,
|
|
352
|
+
BARK_ARCHIVE,
|
|
353
|
+
BARK_URL,
|
|
354
|
+
} = push_config;
|
|
595
355
|
if (BARK_PUSH) {
|
|
356
|
+
// 兼容BARK本地用户只填写设备码的情况
|
|
357
|
+
if (!BARK_PUSH.startsWith('http')) {
|
|
358
|
+
BARK_PUSH = `https://api.day.app/${BARK_PUSH}`;
|
|
359
|
+
}
|
|
596
360
|
const options = {
|
|
597
361
|
url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(
|
|
598
362
|
desp,
|
|
599
|
-
)}?icon=${BARK_ICON}&sound=${BARK_SOUND}&group=${BARK_GROUP}&level=${BARK_LEVEL}&url=${BARK_URL}&${querystring.stringify(
|
|
363
|
+
)}?icon=${BARK_ICON}&sound=${BARK_SOUND}&group=${BARK_GROUP}&isArchive=${BARK_ARCHIVE}&level=${BARK_LEVEL}&url=${BARK_URL}&${querystring.stringify(
|
|
600
364
|
params,
|
|
601
365
|
)}`,
|
|
602
366
|
headers: {
|
|
@@ -607,14 +371,12 @@ function BarkNotify(text, desp, params = {}) {
|
|
|
607
371
|
$.get(options, (err, resp, data) => {
|
|
608
372
|
try {
|
|
609
373
|
if (err) {
|
|
610
|
-
console.log('Bark APP发送通知调用API
|
|
611
|
-
console.log(err);
|
|
374
|
+
console.log('Bark APP 发送通知调用API失败😞\n', err);
|
|
612
375
|
} else {
|
|
613
|
-
data = JSON.parse(data);
|
|
614
376
|
if (data.code === 200) {
|
|
615
|
-
console.log('Bark APP发送通知消息成功🎉\n');
|
|
377
|
+
console.log('Bark APP 发送通知消息成功🎉\n');
|
|
616
378
|
} else {
|
|
617
|
-
console.log(
|
|
379
|
+
console.log(`Bark APP 发送通知消息异常 ${data.message}\n`);
|
|
618
380
|
}
|
|
619
381
|
}
|
|
620
382
|
} catch (e) {
|
|
@@ -631,6 +393,14 @@ function BarkNotify(text, desp, params = {}) {
|
|
|
631
393
|
|
|
632
394
|
function tgBotNotify(text, desp) {
|
|
633
395
|
return new Promise((resolve) => {
|
|
396
|
+
const {
|
|
397
|
+
TG_BOT_TOKEN,
|
|
398
|
+
TG_USER_ID,
|
|
399
|
+
TG_PROXY_HOST,
|
|
400
|
+
TG_PROXY_PORT,
|
|
401
|
+
TG_API_HOST,
|
|
402
|
+
TG_PROXY_AUTH,
|
|
403
|
+
} = push_config;
|
|
634
404
|
if (TG_BOT_TOKEN && TG_USER_ID) {
|
|
635
405
|
const options = {
|
|
636
406
|
url: `${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`,
|
|
@@ -664,12 +434,10 @@ function tgBotNotify(text, desp) {
|
|
|
664
434
|
$.post(options, (err, resp, data) => {
|
|
665
435
|
try {
|
|
666
436
|
if (err) {
|
|
667
|
-
console.log('
|
|
668
|
-
console.log(err);
|
|
437
|
+
console.log('Telegram 发送通知消息失败😞\n', err);
|
|
669
438
|
} else {
|
|
670
|
-
data = JSON.parse(data);
|
|
671
439
|
if (data.ok) {
|
|
672
|
-
console.log('Telegram发送通知消息成功🎉。\n');
|
|
440
|
+
console.log('Telegram 发送通知消息成功🎉。\n');
|
|
673
441
|
} else if (data.error_code === 400) {
|
|
674
442
|
console.log(
|
|
675
443
|
'请主动给bot发送一条消息并检查接收用户ID是否正确。\n',
|
|
@@ -691,6 +459,7 @@ function tgBotNotify(text, desp) {
|
|
|
691
459
|
}
|
|
692
460
|
function ddBotNotify(text, desp) {
|
|
693
461
|
return new Promise((resolve) => {
|
|
462
|
+
const { DD_BOT_TOKEN, DD_BOT_SECRET } = push_config;
|
|
694
463
|
const options = {
|
|
695
464
|
url: `https://oapi.dingtalk.com/robot/send?access_token=${DD_BOT_TOKEN}`,
|
|
696
465
|
json: {
|
|
@@ -714,14 +483,12 @@ function ddBotNotify(text, desp) {
|
|
|
714
483
|
$.post(options, (err, resp, data) => {
|
|
715
484
|
try {
|
|
716
485
|
if (err) {
|
|
717
|
-
console.log('
|
|
718
|
-
console.log(err);
|
|
486
|
+
console.log('钉钉发送通知消息失败😞\n', err);
|
|
719
487
|
} else {
|
|
720
|
-
data = JSON.parse(data);
|
|
721
488
|
if (data.errcode === 0) {
|
|
722
|
-
console.log('
|
|
489
|
+
console.log('钉钉发送通知消息成功🎉\n');
|
|
723
490
|
} else {
|
|
724
|
-
console.log(
|
|
491
|
+
console.log(`钉钉发送通知消息异常 ${data.errmsg}\n`);
|
|
725
492
|
}
|
|
726
493
|
}
|
|
727
494
|
} catch (e) {
|
|
@@ -734,14 +501,12 @@ function ddBotNotify(text, desp) {
|
|
|
734
501
|
$.post(options, (err, resp, data) => {
|
|
735
502
|
try {
|
|
736
503
|
if (err) {
|
|
737
|
-
console.log('
|
|
738
|
-
console.log(err);
|
|
504
|
+
console.log('钉钉发送通知消息失败😞\n', err);
|
|
739
505
|
} else {
|
|
740
|
-
data = JSON.parse(data);
|
|
741
506
|
if (data.errcode === 0) {
|
|
742
|
-
console.log('
|
|
507
|
+
console.log('钉钉发送通知消息成功🎉\n');
|
|
743
508
|
} else {
|
|
744
|
-
console.log(
|
|
509
|
+
console.log(`钉钉发送通知消息异常 ${data.errmsg}\n`);
|
|
745
510
|
}
|
|
746
511
|
}
|
|
747
512
|
} catch (e) {
|
|
@@ -758,6 +523,7 @@ function ddBotNotify(text, desp) {
|
|
|
758
523
|
|
|
759
524
|
function qywxBotNotify(text, desp) {
|
|
760
525
|
return new Promise((resolve) => {
|
|
526
|
+
const { QYWX_ORIGIN, QYWX_KEY } = push_config;
|
|
761
527
|
const options = {
|
|
762
528
|
url: `${QYWX_ORIGIN}/cgi-bin/webhook/send?key=${QYWX_KEY}`,
|
|
763
529
|
json: {
|
|
@@ -775,14 +541,12 @@ function qywxBotNotify(text, desp) {
|
|
|
775
541
|
$.post(options, (err, resp, data) => {
|
|
776
542
|
try {
|
|
777
543
|
if (err) {
|
|
778
|
-
console.log('
|
|
779
|
-
console.log(err);
|
|
544
|
+
console.log('企业微信发送通知消息失败😞\n', err);
|
|
780
545
|
} else {
|
|
781
|
-
data = JSON.parse(data);
|
|
782
546
|
if (data.errcode === 0) {
|
|
783
547
|
console.log('企业微信发送通知消息成功🎉。\n');
|
|
784
548
|
} else {
|
|
785
|
-
console.log(
|
|
549
|
+
console.log(`企业微信发送通知消息异常 ${data.errmsg}\n`);
|
|
786
550
|
}
|
|
787
551
|
}
|
|
788
552
|
} catch (e) {
|
|
@@ -798,6 +562,7 @@ function qywxBotNotify(text, desp) {
|
|
|
798
562
|
}
|
|
799
563
|
|
|
800
564
|
function ChangeUserId(desp) {
|
|
565
|
+
const { QYWX_AM } = push_config;
|
|
801
566
|
const QYWX_AM_AY = QYWX_AM.split(',');
|
|
802
567
|
if (QYWX_AM_AY[2]) {
|
|
803
568
|
const userIdTmp = QYWX_AM_AY[2].split('|');
|
|
@@ -829,6 +594,7 @@ async function qywxamNotify(text, desp) {
|
|
|
829
594
|
|
|
830
595
|
function do_qywxamNotify(text, desp) {
|
|
831
596
|
return new Promise((resolve) => {
|
|
597
|
+
const { QYWX_AM, QYWX_ORIGIN } = push_config;
|
|
832
598
|
if (QYWX_AM) {
|
|
833
599
|
const QYWX_AM_AY = QYWX_AM.split(',');
|
|
834
600
|
const options_accesstoken = {
|
|
@@ -842,9 +608,8 @@ function do_qywxamNotify(text, desp) {
|
|
|
842
608
|
},
|
|
843
609
|
timeout,
|
|
844
610
|
};
|
|
845
|
-
$.post(options_accesstoken, (err, resp,
|
|
611
|
+
$.post(options_accesstoken, (err, resp, json) => {
|
|
846
612
|
let html = desp.replace(/\n/g, '<br/>');
|
|
847
|
-
let json = JSON.parse(data);
|
|
848
613
|
let accesstoken = json.access_token;
|
|
849
614
|
let options;
|
|
850
615
|
|
|
@@ -915,11 +680,10 @@ function do_qywxamNotify(text, desp) {
|
|
|
915
680
|
console.log(
|
|
916
681
|
'成员ID:' +
|
|
917
682
|
ChangeUserId(desp) +
|
|
918
|
-
'
|
|
683
|
+
'企业微信应用消息发送通知消息失败😞\n',
|
|
684
|
+
err,
|
|
919
685
|
);
|
|
920
|
-
console.log(err);
|
|
921
686
|
} else {
|
|
922
|
-
data = JSON.parse(data);
|
|
923
687
|
if (data.errcode === 0) {
|
|
924
688
|
console.log(
|
|
925
689
|
'成员ID:' +
|
|
@@ -927,7 +691,9 @@ function do_qywxamNotify(text, desp) {
|
|
|
927
691
|
'企业微信应用消息发送通知消息成功🎉。\n',
|
|
928
692
|
);
|
|
929
693
|
} else {
|
|
930
|
-
console.log(
|
|
694
|
+
console.log(
|
|
695
|
+
`企业微信应用消息发送通知消息异常 ${data.errmsg}\n`,
|
|
696
|
+
);
|
|
931
697
|
}
|
|
932
698
|
}
|
|
933
699
|
} catch (e) {
|
|
@@ -945,11 +711,12 @@ function do_qywxamNotify(text, desp) {
|
|
|
945
711
|
|
|
946
712
|
function iGotNotify(text, desp, params = {}) {
|
|
947
713
|
return new Promise((resolve) => {
|
|
714
|
+
const { IGOT_PUSH_KEY } = push_config;
|
|
948
715
|
if (IGOT_PUSH_KEY) {
|
|
949
716
|
// 校验传入的IGOT_PUSH_KEY是否有效
|
|
950
717
|
const IGOT_PUSH_KEY_REGX = new RegExp('^[a-zA-Z0-9]{24}$');
|
|
951
718
|
if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) {
|
|
952
|
-
console.log('您所提供的IGOT_PUSH_KEY无效\n');
|
|
719
|
+
console.log('您所提供的 IGOT_PUSH_KEY 无效\n');
|
|
953
720
|
resolve();
|
|
954
721
|
return;
|
|
955
722
|
}
|
|
@@ -964,14 +731,12 @@ function iGotNotify(text, desp, params = {}) {
|
|
|
964
731
|
$.post(options, (err, resp, data) => {
|
|
965
732
|
try {
|
|
966
733
|
if (err) {
|
|
967
|
-
console.log('发送通知调用API
|
|
968
|
-
console.log(err);
|
|
734
|
+
console.log('IGot 发送通知调用API失败😞\n', err);
|
|
969
735
|
} else {
|
|
970
|
-
if (typeof data === 'string') data = JSON.parse(data);
|
|
971
736
|
if (data.ret === 0) {
|
|
972
|
-
console.log('
|
|
737
|
+
console.log('IGot 发送通知消息成功🎉\n');
|
|
973
738
|
} else {
|
|
974
|
-
console.log(`
|
|
739
|
+
console.log(`IGot 发送通知消息异常 ${data.errMsg}\n`);
|
|
975
740
|
}
|
|
976
741
|
}
|
|
977
742
|
} catch (e) {
|
|
@@ -988,6 +753,7 @@ function iGotNotify(text, desp, params = {}) {
|
|
|
988
753
|
|
|
989
754
|
function pushPlusNotify(text, desp) {
|
|
990
755
|
return new Promise((resolve) => {
|
|
756
|
+
const { PUSH_PLUS_TOKEN, PUSH_PLUS_USER } = push_config;
|
|
991
757
|
if (PUSH_PLUS_TOKEN) {
|
|
992
758
|
desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext
|
|
993
759
|
const body = {
|
|
@@ -1008,24 +774,23 @@ function pushPlusNotify(text, desp) {
|
|
|
1008
774
|
try {
|
|
1009
775
|
if (err) {
|
|
1010
776
|
console.log(
|
|
1011
|
-
`
|
|
777
|
+
`Push+ 发送${
|
|
1012
778
|
PUSH_PLUS_USER ? '一对多' : '一对一'
|
|
1013
|
-
}
|
|
779
|
+
}通知消息失败😞\n`,
|
|
780
|
+
err,
|
|
1014
781
|
);
|
|
1015
|
-
console.log(err);
|
|
1016
782
|
} else {
|
|
1017
|
-
data = JSON.parse(data);
|
|
1018
783
|
if (data.code === 200) {
|
|
1019
784
|
console.log(
|
|
1020
|
-
`
|
|
785
|
+
`Push+ 发送${
|
|
1021
786
|
PUSH_PLUS_USER ? '一对多' : '一对一'
|
|
1022
|
-
}
|
|
787
|
+
}通知消息完成🎉\n`,
|
|
1023
788
|
);
|
|
1024
789
|
} else {
|
|
1025
790
|
console.log(
|
|
1026
|
-
`
|
|
791
|
+
`Push+ 发送${
|
|
1027
792
|
PUSH_PLUS_USER ? '一对多' : '一对一'
|
|
1028
|
-
}
|
|
793
|
+
}通知消息异常 ${data.msg}\n`,
|
|
1029
794
|
);
|
|
1030
795
|
}
|
|
1031
796
|
}
|
|
@@ -1041,8 +806,58 @@ function pushPlusNotify(text, desp) {
|
|
|
1041
806
|
});
|
|
1042
807
|
}
|
|
1043
808
|
|
|
809
|
+
function wePlusBotNotify(text, desp) {
|
|
810
|
+
return new Promise((resolve) => {
|
|
811
|
+
const { WE_PLUS_BOT_TOKEN, WE_PLUS_BOT_RECEIVER, WE_PLUS_BOT_VERSION } =
|
|
812
|
+
push_config;
|
|
813
|
+
if (WE_PLUS_BOT_TOKEN) {
|
|
814
|
+
const template = 'txt';
|
|
815
|
+
if (desp.length > 800) {
|
|
816
|
+
desp = desp.replace(/[\n\r]/g, '<br>');
|
|
817
|
+
template = 'html';
|
|
818
|
+
}
|
|
819
|
+
const body = {
|
|
820
|
+
token: `${WE_PLUS_BOT_TOKEN}`,
|
|
821
|
+
title: `${text}`,
|
|
822
|
+
content: `${desp}`,
|
|
823
|
+
template: `${template}`,
|
|
824
|
+
receiver: `${WE_PLUS_BOT_RECEIVER}`,
|
|
825
|
+
version: `${WE_PLUS_BOT_VERSION}`,
|
|
826
|
+
};
|
|
827
|
+
const options = {
|
|
828
|
+
url: `https://www.weplusbot.com/send`,
|
|
829
|
+
body: JSON.stringify(body),
|
|
830
|
+
headers: {
|
|
831
|
+
'Content-Type': ' application/json',
|
|
832
|
+
},
|
|
833
|
+
timeout,
|
|
834
|
+
};
|
|
835
|
+
$.post(options, (err, resp, data) => {
|
|
836
|
+
try {
|
|
837
|
+
if (err) {
|
|
838
|
+
console.log(`微加机器人发送通知消息失败😞\n`, err);
|
|
839
|
+
} else {
|
|
840
|
+
if (data.code === 200) {
|
|
841
|
+
console.log(`微加机器人发送通知消息完成🎉\n`);
|
|
842
|
+
} else {
|
|
843
|
+
console.log(`微加机器人发送通知消息异常 ${data.msg}\n`);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
} catch (e) {
|
|
847
|
+
$.logErr(e, resp);
|
|
848
|
+
} finally {
|
|
849
|
+
resolve(data);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
} else {
|
|
853
|
+
resolve();
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
|
|
1044
858
|
function aibotkNotify(text, desp) {
|
|
1045
859
|
return new Promise((resolve) => {
|
|
860
|
+
const { AIBOTK_KEY, AIBOTK_TYPE, AIBOTK_NAME } = push_config;
|
|
1046
861
|
if (AIBOTK_KEY && AIBOTK_TYPE && AIBOTK_NAME) {
|
|
1047
862
|
let json = {};
|
|
1048
863
|
let url = '';
|
|
@@ -1081,14 +896,12 @@ function aibotkNotify(text, desp) {
|
|
|
1081
896
|
$.post(options, (err, resp, data) => {
|
|
1082
897
|
try {
|
|
1083
898
|
if (err) {
|
|
1084
|
-
console.log('
|
|
1085
|
-
console.log(err);
|
|
899
|
+
console.log('智能微秘书发送通知消息失败😞\n', err);
|
|
1086
900
|
} else {
|
|
1087
|
-
data = JSON.parse(data);
|
|
1088
901
|
if (data.code === 0) {
|
|
1089
902
|
console.log('智能微秘书发送通知消息成功🎉。\n');
|
|
1090
903
|
} else {
|
|
1091
|
-
console.log(
|
|
904
|
+
console.log(`智能微秘书发送通知消息异常 ${data.error}\n`);
|
|
1092
905
|
}
|
|
1093
906
|
}
|
|
1094
907
|
} catch (e) {
|
|
@@ -1105,6 +918,7 @@ function aibotkNotify(text, desp) {
|
|
|
1105
918
|
|
|
1106
919
|
function fsBotNotify(text, desp) {
|
|
1107
920
|
return new Promise((resolve) => {
|
|
921
|
+
const { FSKEY } = push_config;
|
|
1108
922
|
if (FSKEY) {
|
|
1109
923
|
const options = {
|
|
1110
924
|
url: `https://open.feishu.cn/open-apis/bot/v2/hook/${FSKEY}`,
|
|
@@ -1117,14 +931,12 @@ function fsBotNotify(text, desp) {
|
|
|
1117
931
|
$.post(options, (err, resp, data) => {
|
|
1118
932
|
try {
|
|
1119
933
|
if (err) {
|
|
1120
|
-
console.log('
|
|
1121
|
-
console.log(err);
|
|
934
|
+
console.log('飞书发送通知调用API失败😞\n', err);
|
|
1122
935
|
} else {
|
|
1123
|
-
data = JSON.parse(data);
|
|
1124
936
|
if (data.StatusCode === 0 || data.code === 0) {
|
|
1125
937
|
console.log('飞书发送通知消息成功🎉\n');
|
|
1126
938
|
} else {
|
|
1127
|
-
console.log(
|
|
939
|
+
console.log(`飞书发送通知消息异常 ${data.msg}\n`);
|
|
1128
940
|
}
|
|
1129
941
|
}
|
|
1130
942
|
} catch (e) {
|
|
@@ -1140,6 +952,7 @@ function fsBotNotify(text, desp) {
|
|
|
1140
952
|
}
|
|
1141
953
|
|
|
1142
954
|
async function smtpNotify(text, desp) {
|
|
955
|
+
const { SMTP_EMAIL, SMTP_PASSWORD, SMTP_SERVICE, SMTP_NAME } = push_config;
|
|
1143
956
|
if (![SMTP_EMAIL, SMTP_PASSWORD].every(Boolean) || !SMTP_SERVICE) {
|
|
1144
957
|
return;
|
|
1145
958
|
}
|
|
@@ -1165,22 +978,22 @@ async function smtpNotify(text, desp) {
|
|
|
1165
978
|
transporter.close();
|
|
1166
979
|
|
|
1167
980
|
if (info.messageId) {
|
|
1168
|
-
console.log('SMTP发送通知消息成功🎉\n');
|
|
981
|
+
console.log('SMTP 发送通知消息成功🎉\n');
|
|
1169
982
|
return true;
|
|
1170
983
|
}
|
|
1171
|
-
console.log('SMTP
|
|
984
|
+
console.log('SMTP 发送通知消息失败😞\n');
|
|
1172
985
|
} catch (e) {
|
|
1173
|
-
console.log('SMTP
|
|
1174
|
-
console.log(e);
|
|
986
|
+
console.log('SMTP 发送通知消息出现异常😞\n', e);
|
|
1175
987
|
}
|
|
1176
988
|
}
|
|
1177
989
|
|
|
1178
990
|
function pushMeNotify(text, desp, params = {}) {
|
|
1179
991
|
return new Promise((resolve) => {
|
|
992
|
+
const { PUSHME_KEY, PUSHME_URL } = push_config;
|
|
1180
993
|
if (PUSHME_KEY) {
|
|
1181
994
|
const options = {
|
|
1182
|
-
url:
|
|
1183
|
-
json: { title: text, content: desp, ...params },
|
|
995
|
+
url: PUSHME_URL || 'https://push.i-i.me',
|
|
996
|
+
json: { push_key: PUSHME_KEY, title: text, content: desp, ...params },
|
|
1184
997
|
headers: {
|
|
1185
998
|
'Content-Type': 'application/json',
|
|
1186
999
|
},
|
|
@@ -1189,13 +1002,12 @@ function pushMeNotify(text, desp, params = {}) {
|
|
|
1189
1002
|
$.post(options, (err, resp, data) => {
|
|
1190
1003
|
try {
|
|
1191
1004
|
if (err) {
|
|
1192
|
-
console.log('
|
|
1193
|
-
console.log(err);
|
|
1005
|
+
console.log('PushMe 发送通知调用API失败😞\n', err);
|
|
1194
1006
|
} else {
|
|
1195
1007
|
if (data === 'success') {
|
|
1196
|
-
console.log('PushMe发送通知消息成功🎉\n');
|
|
1008
|
+
console.log('PushMe 发送通知消息成功🎉\n');
|
|
1197
1009
|
} else {
|
|
1198
|
-
console.log(
|
|
1010
|
+
console.log(`PushMe 发送通知消息异常 ${data}\n`);
|
|
1199
1011
|
}
|
|
1200
1012
|
}
|
|
1201
1013
|
} catch (e) {
|
|
@@ -1212,6 +1024,7 @@ function pushMeNotify(text, desp, params = {}) {
|
|
|
1212
1024
|
|
|
1213
1025
|
function chronocatNotify(title, desp) {
|
|
1214
1026
|
return new Promise((resolve) => {
|
|
1027
|
+
const { CHRONOCAT_TOKEN, CHRONOCAT_QQ, CHRONOCAT_URL } = push_config;
|
|
1215
1028
|
if (!CHRONOCAT_TOKEN || !CHRONOCAT_QQ || !CHRONOCAT_URL) {
|
|
1216
1029
|
resolve();
|
|
1217
1030
|
return;
|
|
@@ -1261,14 +1074,12 @@ function chronocatNotify(title, desp) {
|
|
|
1261
1074
|
$.post(options, (err, resp, data) => {
|
|
1262
1075
|
try {
|
|
1263
1076
|
if (err) {
|
|
1264
|
-
console.log('Chronocat发送QQ
|
|
1265
|
-
console.log(err);
|
|
1077
|
+
console.log('Chronocat 发送QQ通知消息失败😞\n', err);
|
|
1266
1078
|
} else {
|
|
1267
|
-
data = JSON.parse(data);
|
|
1268
1079
|
if (chat_type === 1) {
|
|
1269
|
-
console.log(`
|
|
1080
|
+
console.log(`Chronocat 个人消息 ${ids}推送成功🎉`);
|
|
1270
1081
|
} else {
|
|
1271
|
-
console.log(`
|
|
1082
|
+
console.log(`Chronocat 群消息 ${ids}推送成功🎉`);
|
|
1272
1083
|
}
|
|
1273
1084
|
}
|
|
1274
1085
|
} catch (e) {
|
|
@@ -1282,8 +1093,50 @@ function chronocatNotify(title, desp) {
|
|
|
1282
1093
|
});
|
|
1283
1094
|
}
|
|
1284
1095
|
|
|
1096
|
+
function qmsgNotify(text, desp) {
|
|
1097
|
+
return new Promise((resolve) => {
|
|
1098
|
+
const { QMSG_KEY, QMSG_TYPE } = push_config;
|
|
1099
|
+
if (QMSG_KEY && QMSG_TYPE) {
|
|
1100
|
+
const options = {
|
|
1101
|
+
url: `https://qmsg.zendee.cn/${QMSG_TYPE}/${QMSG_KEY}`,
|
|
1102
|
+
body: `msg=${text}\n\n${desp.replace('----', '-')}`,
|
|
1103
|
+
headers: {
|
|
1104
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
1105
|
+
},
|
|
1106
|
+
timeout,
|
|
1107
|
+
};
|
|
1108
|
+
$.post(options, (err, resp, data) => {
|
|
1109
|
+
try {
|
|
1110
|
+
if (err) {
|
|
1111
|
+
console.log('Qmsg 发送通知调用API失败😞\n', err);
|
|
1112
|
+
} else {
|
|
1113
|
+
if (data.code === 0) {
|
|
1114
|
+
console.log('Qmsg 发送通知消息成功🎉\n');
|
|
1115
|
+
} else {
|
|
1116
|
+
console.log(`Qmsg 发送通知消息异常 ${data}\n`);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
$.logErr(e, resp);
|
|
1121
|
+
} finally {
|
|
1122
|
+
resolve(data);
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1125
|
+
} else {
|
|
1126
|
+
resolve();
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1285
1131
|
function webhookNotify(text, desp) {
|
|
1286
1132
|
return new Promise((resolve) => {
|
|
1133
|
+
const {
|
|
1134
|
+
WEBHOOK_URL,
|
|
1135
|
+
WEBHOOK_BODY,
|
|
1136
|
+
WEBHOOK_HEADERS,
|
|
1137
|
+
WEBHOOK_CONTENT_TYPE,
|
|
1138
|
+
WEBHOOK_METHOD,
|
|
1139
|
+
} = push_config;
|
|
1287
1140
|
if (!WEBHOOK_URL.includes('$title') && !WEBHOOK_BODY.includes('$title')) {
|
|
1288
1141
|
resolve();
|
|
1289
1142
|
return;
|
|
@@ -1311,9 +1164,9 @@ function webhookNotify(text, desp) {
|
|
|
1311
1164
|
got(formatUrl, options).then((resp) => {
|
|
1312
1165
|
try {
|
|
1313
1166
|
if (resp.statusCode !== 200) {
|
|
1314
|
-
console.log(
|
|
1167
|
+
console.log(`自定义发送通知消息失败😞 ${resp.body}\n`);
|
|
1315
1168
|
} else {
|
|
1316
|
-
console.log(
|
|
1169
|
+
console.log(`自定义发送通知消息成功🎉 ${resp.body}\n`);
|
|
1317
1170
|
}
|
|
1318
1171
|
} catch (e) {
|
|
1319
1172
|
$.logErr(e, resp);
|
|
@@ -1413,25 +1266,51 @@ function formatBodyFun(contentType, body) {
|
|
|
1413
1266
|
return {};
|
|
1414
1267
|
}
|
|
1415
1268
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1269
|
+
/**
|
|
1270
|
+
* sendNotify 推送通知功能
|
|
1271
|
+
* @param text 通知头
|
|
1272
|
+
* @param desp 通知体
|
|
1273
|
+
* @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' }
|
|
1274
|
+
* @returns {Promise<unknown>}
|
|
1275
|
+
*/
|
|
1276
|
+
async function sendNotify(text, desp, params = {}) {
|
|
1277
|
+
// 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔
|
|
1278
|
+
let skipTitle = process.env.SKIP_PUSH_TITLE;
|
|
1279
|
+
if (skipTitle) {
|
|
1280
|
+
if (skipTitle.split('\n').includes(text)) {
|
|
1281
|
+
console.info(text + '在 SKIP_PUSH_TITLE 环境变量内,跳过推送');
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
if (push_config.HITOKOTO) {
|
|
1287
|
+
desp += '\n\n' + (await one());
|
|
1419
1288
|
}
|
|
1420
1289
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1290
|
+
await Promise.all([
|
|
1291
|
+
serverNotify(text, desp), // 微信server酱
|
|
1292
|
+
pushPlusNotify(text, desp), // pushplus
|
|
1293
|
+
wePlusBotNotify(text, desp), // 微加机器人
|
|
1294
|
+
barkNotify(text, desp, params), // iOS Bark APP
|
|
1295
|
+
tgBotNotify(text, desp), // telegram 机器人
|
|
1296
|
+
ddBotNotify(text, desp), // 钉钉机器人
|
|
1297
|
+
qywxBotNotify(text, desp), // 企业微信机器人
|
|
1298
|
+
qywxamNotify(text, desp), // 企业微信应用消息推送
|
|
1299
|
+
iGotNotify(text, desp, params), // iGot
|
|
1300
|
+
gobotNotify(text, desp), // go-cqhttp
|
|
1301
|
+
gotifyNotify(text, desp), // gotify
|
|
1302
|
+
chatNotify(text, desp), // synolog chat
|
|
1303
|
+
pushDeerNotify(text, desp), // PushDeer
|
|
1304
|
+
aibotkNotify(text, desp), // 智能微秘书
|
|
1305
|
+
fsBotNotify(text, desp), // 飞书机器人
|
|
1306
|
+
smtpNotify(text, desp), // SMTP 邮件
|
|
1307
|
+
pushMeNotify(text, desp, params), // PushMe
|
|
1308
|
+
chronocatNotify(text, desp), // Chronocat
|
|
1309
|
+
webhookNotify(text, desp), // 自定义通知
|
|
1310
|
+
qmsgNotify(text, desp), // 自定义通知
|
|
1311
|
+
]);
|
|
1429
1312
|
}
|
|
1430
1313
|
|
|
1431
1314
|
module.exports = {
|
|
1432
1315
|
sendNotify,
|
|
1433
|
-
BARK_PUSH,
|
|
1434
1316
|
};
|
|
1435
|
-
|
|
1436
|
-
// prettier-ignore
|
|
1437
|
-
function Env(t, s) { return new class { constructor(t, s) { this.name = t, this.data = null, this.dataFile = "box.dat", this.logs = [], this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, s), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } getScript(t) { return new Promise(s => { $.get({ url: t }, (t, e, i) => s(i)) }) } runScript(t, s) { return new Promise(e => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let o = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); o = o ? 1 * o : 20, o = s && s.timeout ? s.timeout : o; const [h, a] = i.split("@"), r = { url: `http://${a}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: o }, headers: { "X-Key": h, Accept: "*/*" } }; $.post(r, (t, s, i) => e(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile), e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s); if (!e && !i) return {}; { const i = e ? t : s; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile), e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s), o = JSON.stringify(this.data); e ? this.fs.writeFileSync(t, o) : i ? this.fs.writeFileSync(s, o) : this.fs.writeFileSync(t, o) } } lodash_get(t, s, e) { const i = s.replace(/\[(\d+)\]/g, ".$1").split("."); let o = t; for (const t of i) if (o = Object(o)[t], void 0 === o) return e; return o } lodash_set(t, s, e) { return Object(t) !== t ? t : (Array.isArray(s) || (s = s.toString().match(/[^.[\]]+/g) || []), s.slice(0, -1).reduce((t, e, i) => Object(t[e]) === t[e] ? t[e] : t[e] = Math.abs(s[i + 1]) >> 0 == +s[i + 1] ? [] : {}, t)[s[s.length - 1]] = e, t) } getdata(t) { let s = this.getval(t); if (/^@/.test(t)) { const [, e, i] = /^@(.*?)\.(.*?)$/.exec(t), o = e ? this.getval(e) : ""; if (o) try { const t = JSON.parse(o); s = t ? this.lodash_get(t, i, "") : s } catch (t) { s = "" } } return s } setdata(t, s) { let e = !1; if (/^@/.test(s)) { const [, i, o] = /^@(.*?)\.(.*?)$/.exec(s), h = this.getval(i), a = i ? "null" === h ? null : h || "{}" : "{}"; try { const s = JSON.parse(a); this.lodash_set(s, o, t), e = this.setval(JSON.stringify(s), i) } catch (s) { const h = {}; this.lodash_set(h, o, t), e = this.setval(JSON.stringify(h), i) } } else e = $.setval(t, s); return e } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, s) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : this.isNode() ? (this.data = this.loaddata(), this.data[s] = t, this.writedata(), !0) : this.data && this.data[s] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, s = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? $httpClient.get(t, (t, e, i) => { !t && e && (e.body = i, e.statusCode = e.status), s(t, e, i) }) : this.isQuanX() ? $task.fetch(t).then(t => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, t => s(t)) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, s) => { try { const e = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); this.ckjar.setCookieSync(e, null), s.cookieJar = this.ckjar } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, t => s(t))) } post(t, s = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) $httpClient.post(t, (t, e, i) => { !t && e && (e.body = i, e.statusCode = e.status), s(t, e, i) }); else if (this.isQuanX()) t.method = "POST", $task.fetch(t).then(t => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, t => s(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: e, ...i } = t; this.got.post(e, i).then(t => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, t => s(t)) } } time(t) { let s = { "M+": (new Date).getMonth() + 1, "d+": (new Date).getDate(), "H+": (new Date).getHours(), "m+": (new Date).getMinutes(), "s+": (new Date).getSeconds(), "q+": Math.floor(((new Date).getMonth() + 3) / 3), S: (new Date).getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in s) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? s[e] : ("00" + s[e]).substr(("" + s[e]).length))); return t } msg(s = t, e = "", i = "", o) { const h = t => !t || !this.isLoon() && this.isSurge() ? t : "string" == typeof t ? this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : void 0 : "object" == typeof t && (t["open-url"] || t["media-url"]) ? this.isLoon() ? t["open-url"] : this.isQuanX() ? t : void 0 : void 0; $.isMute || (this.isSurge() || this.isLoon() ? $notification.post(s, e, i, h(o)) : this.isQuanX() && $notify(s, e, i, h(o))), this.logs.push("", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="), this.logs.push(s), e && this.logs.push(e), i && this.logs.push(i) } log(...t) { t.length > 0 ? this.logs = [...this.logs, ...t] : console.log(this.logs.join(this.logSeparator)) } logErr(t, s) { const e = !this.isSurge() && !this.isQuanX() && !this.isLoon(); e ? $.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : $.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t) } wait(t) { return new Promise(s => setTimeout(s, t)) } done(t = {}) { const s = (new Date).getTime(), e = (s - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, s) }
|