forked from ccwav/QLScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendNotify.js
2326 lines (2183 loc) · 94.3 KB
/
sendNotify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* @Author: ccwav https://github.com/ccwav/QLScript2
* sendNotify 推送通知功能 (text, desp, params , author , strsummary)
* @param text 通知标题 (必要)
* @param desp 通知内容 (必要)
* @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } ,没啥用,只是为了兼容旧脚本保留 (非必要)
* @param author 通知底部作者` (非必要)
* @param strsummary 指定某些微信模板通知的预览信息,空则默认为desp (非必要)
* sendNotifybyWxPucher 一对一推送通知功能 (text, desp, PtPin, author, strsummary )
* @param text 通知标题 (必要)
* @param desp 通知内容 (必要)
* @param PtPin CK的PTPIN (必要)
* @param author 通知底部作者` (非必要)
* @param strsummary 指定某些微信模板通知的预览信息,空则默认为desp (非必要)
*/
//详细说明参考 https://github.com/ccwav/QLScript2.
const querystring = require('querystring');
const exec = require('child_process').exec;
const $ = new Env();
const timeout = 15000; //超时时间(单位毫秒)
console.log("加载sendNotify,当前版本: 20221118");
// =======================================go-cqhttp通知设置区域===========================================
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
//gobot_token 填写在go-cqhttp文件设置的访问密钥
//gobot_qq 填写推送到个人QQ或者QQ群号
//go-cqhttp相关API https://docs.go-cqhttp.org/api
let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg
let GOBOT_TOKEN = ''; //访问密钥
let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群
// =======================================微信server酱通知设置区域===========================================
//此处填你申请的SCKEY.
//(环境变量名 PUSH_KEY)
let SCKEY = '';
// =======================================Bark App通知设置区域===========================================
//此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX)
let BARK_PUSH = '';
//BARK app推送铃声,铃声列表去APP查看复制填写
let BARK_SOUND = '';
//BARK app推送消息的分组, 默认为"QingLong"
let BARK_GROUP = 'QingLong';
// =======================================telegram机器人通知设置区域===========================================
//此处填你telegram bot 的Token,telegram机器人通知推送必填项.例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw
//(环境变量名 TG_BOT_TOKEN)
let TG_BOT_TOKEN = '';
//此处填你接收通知消息的telegram用户的id,telegram机器人通知推送必填项.例如:129xxx206
//(环境变量名 TG_USER_ID)
let TG_USER_ID = '';
//tg推送HTTP代理设置(不懂可忽略,telegram机器人通知推送功能中非必填)
let TG_PROXY_HOST = ''; //例如:127.0.0.1(环境变量名:TG_PROXY_HOST)
let TG_PROXY_PORT = ''; //例如:1080(环境变量名:TG_PROXY_PORT)
let TG_PROXY_AUTH = ''; //tg代理配置认证参数
//Telegram api自建的反向代理地址(不懂可忽略,telegram机器人通知推送功能中非必填),默认tg官方api(环境变量名:TG_API_HOST)
let TG_API_HOST = 'api.telegram.org';
// =======================================钉钉机器人通知设置区域===========================================
//此处填你钉钉 bot 的webhook,例如:5a544165465465645d0f31dca676e7bd07415asdasd
//(环境变量名 DD_BOT_TOKEN)
let DD_BOT_TOKEN = '';
//密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串
let DD_BOT_SECRET = '';
// =======================================企业微信机器人通知设置区域===========================================
//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
//(环境变量名 QYWX_KEY)
let QYWX_KEY = '';
// =======================================企业微信应用消息通知设置区域===========================================
/*
此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236)
环境变量名 QYWX_AM依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型)
注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat
可选推送消息类型(推荐使用图文消息(mpnews)):
- 文本卡片消息: 0 (数字零)
- 文本消息: 1 (数字一)
- 图文消息(mpnews): 素材库图片id, 可查看此教程(http://note.youdao.com/s/HMiudGkb)或者(https://note.youdao.com/ynoteshare1/index.html?id=1a0c8aff284ad28cbd011b29b3ad0191&type=note)
*/
let QYWX_AM = '';
// =======================================iGot聚合推送通知设置区域===========================================
//此处填您iGot的信息(推送key,例如:https://push.hellyw.com/XXXXXXXX)
let IGOT_PUSH_KEY = '';
// =======================================push+设置区域=======================================
//官方文档:http://www.pushplus.plus/
//PUSH_PLUS_TOKEN:微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送
//PUSH_PLUS_USER: 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)
let PUSH_PLUS_TOKEN = '';
let PUSH_PLUS_USER = '';
let PUSH_PLUS_TOKEN_hxtrip = '';
let PUSH_PLUS_USER_hxtrip = '';
// ======================================= WxPusher 通知设置区域 ===========================================
// 此处填你申请的 appToken. 官方文档:https://wxpusher.zjiecode.com/docs
// WP_APP_TOKEN 可在管理台查看: https://wxpusher.zjiecode.com/admin/main/app/appToken
// WP_TOPICIDS 群发, 发送目标的 topicId, 以 ; 分隔! 使用 WP_UIDS 单发的时候, 可以不传
// WP_UIDS 发送目标的 uid, 以 ; 分隔。注意 WP_UIDS 和 WP_TOPICIDS 可以同时填写, 也可以只填写一个。
// WP_URL 原文链接, 可选参数
let WP_APP_TOKEN = "";
let WP_TOPICIDS = "";
let WP_UIDS = "";
let WP_URL = "";
let WP_APP_TOKEN_ONE = "";
if (process.env.WP_APP_TOKEN_ONE) {
WP_APP_TOKEN_ONE = process.env.WP_APP_TOKEN_ONE;
}
let WP_UIDS_ONE = "";
// =======================================gotify通知设置区域==============================================
//gotify_url 填写gotify地址,如https://push.example.de:8080
//gotify_token 填写gotify的消息应用token
//gotify_priority 填写推送消息优先级,默认为0
let GOTIFY_URL = '';
let GOTIFY_TOKEN = '';
let GOTIFY_PRIORITY = 0;
let PushErrorTime = 0;
let strTitle = "";
let ShowRemarkType = "1";
let Notify_NoCKFalse = "false";
let Notify_NoLoginSuccess = "false";
let UseGroupNotify = 1;
const {
getEnvs,
DisableCk,
getEnvByPtPin
} = require('./ql');
const fs = require('fs');
let isnewql = fs.existsSync('/ql/data/config/auth.json');
let strCKFile="";
let strUidFile ="";
if(isnewql){
strCKFile = '/ql/data/scripts/CKName_cache.json';
strUidFile = '/ql/data/scripts/CK_WxPusherUid.json';
}else{
strCKFile = '/ql/scripts/CKName_cache.json';
strUidFile = '/ql/scripts/CK_WxPusherUid.json';
}
let Fileexists = fs.existsSync(strCKFile);
let TempCK = [];
if (Fileexists) {
console.log("检测到别名缓存文件CKName_cache.json,载入...");
TempCK = fs.readFileSync(strCKFile, 'utf-8');
if (TempCK) {
TempCK = TempCK.toString();
TempCK = JSON.parse(TempCK);
}
}
let UidFileexists = fs.existsSync(strUidFile);
let TempCKUid = [];
if (UidFileexists) {
console.log("检测到一对一Uid文件WxPusherUid.json,载入...");
TempCKUid = fs.readFileSync(strUidFile, 'utf-8');
if (TempCKUid) {
TempCKUid = TempCKUid.toString();
TempCKUid = JSON.parse(TempCKUid);
}
}
let tempAddCK = {};
let boolneedUpdate = false;
let strCustom = "";
let strCustomArr = [];
let strCustomTempArr = [];
let Notify_CKTask = "";
let Notify_SkipText = [];
let isLogin = false;
if (process.env.NOTIFY_SHOWNAMETYPE) {
ShowRemarkType = process.env.NOTIFY_SHOWNAMETYPE;
if (ShowRemarkType == "2")
console.log("检测到显示备注名称,格式为: 京东别名(备注)");
if (ShowRemarkType == "3")
console.log("检测到显示备注名称,格式为: 京东账号(备注)");
if (ShowRemarkType == "4")
console.log("检测到显示备注名称,格式为: 备注");
}
async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ccwav Mod', strsummary = "") {
console.log(`开始发送通知...`);
//NOTIFY_FILTERBYFILE代码来自Ca11back.
if (process.env.NOTIFY_FILTERBYFILE) {
var no_notify = process.env.NOTIFY_FILTERBYFILE.split('&');
if (module.parent.filename) {
const script_name = module.parent.filename.split('/').slice(-1)[0];
if (no_notify.some(key_word => {
const flag = script_name.includes(key_word);
if (flag) {
console.log(`${script_name}含有关键字${key_word},不推送`);
}
return flag;
})) {
return;
}
}
}
try {
//Reset 变量
UseGroupNotify = 1;
strTitle = "";
GOBOT_URL = '';
GOBOT_TOKEN = '';
GOBOT_QQ = '';
SCKEY = '';
BARK_PUSH = '';
BARK_SOUND = '';
BARK_GROUP = 'QingLong';
TG_BOT_TOKEN = '';
TG_USER_ID = '';
TG_PROXY_HOST = '';
TG_PROXY_PORT = '';
TG_PROXY_AUTH = '';
TG_API_HOST = 'api.telegram.org';
DD_BOT_TOKEN = '';
DD_BOT_SECRET = '';
QYWX_KEY = '';
QYWX_AM = '';
IGOT_PUSH_KEY = '';
PUSH_PLUS_TOKEN = '';
PUSH_PLUS_USER = '';
PUSH_PLUS_TOKEN_hxtrip = '';
PUSH_PLUS_USER_hxtrip = '';
Notify_CKTask = "";
Notify_SkipText = [];
//变量开关
var Use_serverNotify = true;
var Use_pushPlusNotify = true;
var Use_BarkNotify = true;
var Use_tgBotNotify = true;
var Use_ddBotNotify = true;
var Use_qywxBotNotify = true;
var Use_qywxamNotify = true;
var Use_iGotNotify = true;
var Use_gobotNotify = true;
var Use_pushPlushxtripNotify = true;
var Use_WxPusher = true;
var strtext = text;
var strdesp = desp;
var titleIndex =-1;
if (process.env.NOTIFY_NOCKFALSE) {
Notify_NoCKFalse = process.env.NOTIFY_NOCKFALSE;
}
if (process.env.NOTIFY_NOLOGINSUCCESS) {
Notify_NoLoginSuccess = process.env.NOTIFY_NOLOGINSUCCESS;
}
if (process.env.NOTIFY_CKTASK) {
Notify_CKTask = process.env.NOTIFY_CKTASK;
}
if (process.env.NOTIFY_SKIP_TEXT && desp) {
Notify_SkipText = process.env.NOTIFY_SKIP_TEXT.split('&');
if (Notify_SkipText.length > 0) {
for (var Templ in Notify_SkipText) {
if (desp.indexOf(Notify_SkipText[Templ]) != -1) {
console.log("检测内容到内容存在屏蔽推送的关键字(" + Notify_SkipText[Templ] + "),将跳过推送...");
return;
}
}
}
}
if (text.indexOf("cookie已失效") != -1 || desp.indexOf("重新登录获取") != -1 || text == "Ninja 运行通知") {
if (Notify_CKTask) {
console.log("触发CK脚本,开始执行....");
Notify_CKTask = "task " + Notify_CKTask + " now";
await exec(Notify_CKTask, function (error, stdout, stderr) {
console.log(error, stdout, stderr)
});
}
}
if (process.env.NOTIFY_AUTOCHECKCK == "true") {
if (text.indexOf("cookie已失效") != -1 || desp.indexOf("重新登录获取") != -1) {
console.log(`捕获CK过期通知,开始尝试处理...`);
var strPtPin = await GetPtPin(text);
var strdecPtPin = decodeURIComponent(strPtPin);
var llHaderror = false;
if (strPtPin) {
var temptest = await getEnvByPtPin(strdecPtPin);
if (temptest) {
if (temptest.status == 0) {
isLogin = true;
await isLoginByX1a0He(temptest.value);
if (!isLogin) {
var tempid = 0;
if (temptest._id) {
tempid = temptest._id;
}
if (temptest.id) {
tempid =temptest.id;
}
const DisableCkBody = await DisableCk(tempid);
strPtPin = temptest.value;
strPtPin = (strPtPin.match(/pt_pin=([^; ]+)(?=;?)/) && strPtPin.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
var strAllNotify = "";
var MessageUserGp2 = "";
var MessageUserGp3 = "";
var MessageUserGp4 = "";
var userIndex2 = -1;
var userIndex3 = -1;
var userIndex4 = -1;
var strNotifyOneTemp = "";
if ($.isNode() && process.env.BEANCHANGE_USERGP2) {
MessageUserGp2 = process.env.BEANCHANGE_USERGP2 ? process.env.BEANCHANGE_USERGP2.split('&') : [];
}
if ($.isNode() && process.env.BEANCHANGE_USERGP3) {
MessageUserGp3 = process.env.BEANCHANGE_USERGP3 ? process.env.BEANCHANGE_USERGP3.split('&') : [];
}
if ($.isNode() && process.env.BEANCHANGE_USERGP4) {
MessageUserGp4 = process.env.BEANCHANGE_USERGP4 ? process.env.BEANCHANGE_USERGP4.split('&') : [];
}
if (MessageUserGp4) {
userIndex4 = MessageUserGp4.findIndex((item) => item === strPtPin);
}
if (MessageUserGp2) {
userIndex2 = MessageUserGp2.findIndex((item) => item === strPtPin);
}
if (MessageUserGp3) {
userIndex3 = MessageUserGp3.findIndex((item) => item === strPtPin);
}
if (userIndex2 != -1) {
console.log(`该账号属于分组2`);
text = "京东CK检测#2";
}
if (userIndex3 != -1) {
console.log(`该账号属于分组3`);
text = "京东CK检测#3";
}
if (userIndex4 != -1) {
console.log(`该账号属于分组4`);
text = "京东CK检测#4";
}
if (userIndex4 == -1 && userIndex2 == -1 && userIndex3 == -1) {
text = "京东CK检测";
}
if (process.env.CHECKCK_ALLNOTIFY) {
strAllNotify = process.env.CHECKCK_ALLNOTIFY;
/* if (strTempNotify.length > 0) {
for (var TempNotifyl in strTempNotify) {
strAllNotify += strTempNotify[TempNotifyl] + '\n';
}
}*/
console.log(`检测到设定了温馨提示,将在推送信息中置顶显示...`);
strAllNotify = `\n【✨✨✨✨温馨提示✨✨✨✨】\n` + strAllNotify;
console.log(strAllNotify);
}
if (DisableCkBody.code == 200) {
console.log(`京东账号` + strdecPtPin + `已失效,自动禁用成功!\n`);
strNotifyOneTemp = `京东账号: ` + strdecPtPin + ` 已失效,自动禁用成功!\n如果要继续挂机,请联系管理员重新登录账号,账号有效期为30天.`;
strNotifyOneTemp += "\n任务标题:" + strtext;
if (strAllNotify)
strNotifyOneTemp += `\n` + strAllNotify;
desp = strNotifyOneTemp;
if (WP_APP_TOKEN_ONE) {
await sendNotifybyWxPucher(`账号过期下线通知`, strNotifyOneTemp, strdecPtPin);
}
} else {
console.log(`京东账号` + strPtPin + `已失效,自动禁用失败!\n`);
strNotifyOneTemp = `京东账号: ` + strdecPtPin + ` 已失效!\n如果要继续挂机,请联系管理员重新登录账号,账号有效期为30天.`;
strNotifyOneTemp += "\n任务标题:" + strtext;
if (strAllNotify)
strNotifyOneTemp += `\n` + strAllNotify;
desp = strNotifyOneTemp;
if (WP_APP_TOKEN_ONE) {
await sendNotifybyWxPucher(`账号过期下线通知`, strNotifyOneTemp, strdecPtPin);
}
}
} else {
console.log(`该CK已经检测没有有效,跳过通知...`);
llHaderror = true;
}
} else {
console.log(`该CK已经禁用不需要处理`);
llHaderror = true;
}
}
} else {
console.log(`CK过期通知处理失败...`);
}
if (llHaderror)
return;
}
}
if (strtext.indexOf("cookie已失效") != -1 || strdesp.indexOf("重新登录获取") != -1 || strtext == "Ninja 运行通知") {
if (Notify_NoCKFalse == "true" && text != "Ninja 运行通知") {
console.log(`检测到NOTIFY_NOCKFALSE变量为true,不发送ck失效通知...`);
return;
}
}
if (text.indexOf("已可领取") != -1) {
if (text.indexOf("农场") != -1) {
strTitle = "东东农场领取";
} else {
strTitle = "东东萌宠领取";
}
}
if (text.indexOf("汪汪乐园养joy") != -1) {
strTitle = "汪汪乐园养joy领取";
}
if (text == "京喜工厂") {
if (desp.indexOf("元造进行兑换") != -1) {
strTitle = "京喜工厂领取";
}
}
if (text.indexOf("任务") != -1 && (text.indexOf("新增") != -1 || text.indexOf("删除") != -1)) {
strTitle = "脚本任务更新";
}
if (strTitle) {
const notifyRemindList = process.env.NOTIFY_NOREMIND ? process.env.NOTIFY_NOREMIND.split('&') : [];
titleIndex = notifyRemindList.findIndex((item) => item === strTitle);
if (titleIndex !== -1) {
console.log(`${text} 在领取信息黑名单中,已跳过推送`);
return;
}
} else {
strTitle = text;
}
if (Notify_NoLoginSuccess == "true") {
if (desp.indexOf("登陆成功") != -1) {
console.log(`登陆成功不推送`);
return;
}
}
if (strTitle == "汪汪乐园养joy领取" && WP_APP_TOKEN_ONE) {
console.log(`捕获汪汪乐园养joy领取通知,开始尝试一对一推送...`);
var strPtPin = await GetPtPin(text);
var strdecPtPin = decodeURIComponent(strPtPin);
if (strPtPin) {
await sendNotifybyWxPucher("汪汪乐园领取通知", `【京东账号】${strdecPtPin}\n当前等级: 30\n请自行去解锁新场景,奖励领取方式如下:\n极速版APP->我的->汪汪乐园,点击左上角头像,点击中间靠左的现金奖励图标,弹出历史奖励中点击领取.`, strdecPtPin);
}
}
console.log("通知标题: " + strTitle);
//检查黑名单屏蔽通知
const notifySkipList = process.env.NOTIFY_SKIP_LIST ? process.env.NOTIFY_SKIP_LIST.split('&') : [];
titleIndex = notifySkipList.findIndex((item) => item === strTitle);
if (titleIndex !== -1) {
console.log(`${strTitle} 在推送黑名单中,已跳过推送`);
return;
}
//检查脚本名称是否需要通知到Group2,Group2读取原环境配置的变量名后加2的值.例如: QYWX_AM2
for (lncount = 2; lncount < 20; lncount++) {
if (process.env["NOTIFY_GROUP" + lncount + "_LIST"]) {
const strtemp = process.env["NOTIFY_GROUP" + lncount + "_LIST"];
const notifyGroupList = strtemp ? strtemp.split('&') : [];
const titleIndex = notifyGroupList.findIndex((item) => item === strTitle);
if (titleIndex !== -1) {
console.log(`${strTitle} 在群组${lncount}推送名单中,初始化群组推送`);
UseGroupNotify = lncount;
}
}
}
if (process.env.NOTIFY_CUSTOMNOTIFY) {
strCustom = process.env.NOTIFY_CUSTOMNOTIFY;
strCustomArr = strCustom.replace(/^\[|\]$/g, "").split(",");
strCustomTempArr = [];
for (var Tempj in strCustomArr) {
strCustomTempArr = strCustomArr[Tempj].split("&");
if (strCustomTempArr.length > 1) {
if (strTitle == strCustomTempArr[0]) {
console.log("检测到自定义设定,开始执行配置...");
if(strCustomTempArr[1].indexOf("组")!=-1){
UseGroupNotify = strCustomTempArr[1].replace("组","") * 1;
console.log("自定义设定强制使用组"+UseGroupNotify+"配置通知...");
} else {
UseGroupNotify = 1;
}
if (strCustomTempArr.length > 2) {
console.log("关闭所有通知变量...");
Use_serverNotify = false;
Use_pushPlusNotify = false;
Use_pushPlushxtripNotify = false;
Use_BarkNotify = false;
Use_tgBotNotify = false;
Use_ddBotNotify = false;
Use_qywxBotNotify = false;
Use_qywxamNotify = false;
Use_iGotNotify = false;
Use_gobotNotify = false;
for (let Tempk = 2; Tempk < strCustomTempArr.length; Tempk++) {
var strTrmp = strCustomTempArr[Tempk];
switch (strTrmp) {
case "Server酱":
Use_serverNotify = true;
console.log("自定义设定启用Server酱进行通知...");
break;
case "pushplus":
Use_pushPlusNotify = true;
console.log("自定义设定启用pushplus(推送加)进行通知...");
break;
case "pushplushxtrip":
Use_pushPlushxtripNotify = true;
console.log("自定义设定启用pushplus_hxtrip(推送加)进行通知...");
break;
case "Bark":
Use_BarkNotify = true;
console.log("自定义设定启用Bark进行通知...");
break;
case "TG机器人":
Use_tgBotNotify = true;
console.log("自定义设定启用telegram机器人进行通知...");
break;
case "钉钉":
Use_ddBotNotify = true;
console.log("自定义设定启用钉钉机器人进行通知...");
break;
case "企业微信机器人":
Use_qywxBotNotify = true;
console.log("自定义设定启用企业微信机器人进行通知...");
break;
case "企业微信应用消息":
Use_qywxamNotify = true;
console.log("自定义设定启用企业微信应用消息进行通知...");
break;
case "iGotNotify":
Use_iGotNotify = true;
console.log("自定义设定启用iGot进行通知...");
break;
case "gobotNotify":
Use_gobotNotify = true;
console.log("自定义设定启用go-cqhttp进行通知...");
break;
case "WxPusher":
Use_WxPusher = true;
console.log("自定义设定启用WxPusher进行通知...");
break;
}
}
}
}
}
}
}
if (desp) {
for (lncount = 2; lncount < 20; lncount++) {
if (process.env["NOTIFY_INCLUDE_TEXT" + lncount]) {
Notify_IncludeText = process.env["NOTIFY_INCLUDE_TEXT" + lncount].split('&');
if (Notify_IncludeText.length > 0) {
for (var Templ in Notify_IncludeText) {
if (desp.indexOf(Notify_IncludeText[Templ]) != -1) {
console.log("检测内容到内容存在组别推送的关键字(" + Notify_IncludeText[Templ] + "),将推送到组" + lncount + "...");
UseGroupNotify = lncount;
break;
}
}
}
}
}
}
if (UseGroupNotify == 1)
UseGroupNotify = "";
if (process.env["GOBOT_URL" + UseGroupNotify] && Use_gobotNotify) {
GOBOT_URL = process.env["GOBOT_URL" + UseGroupNotify];
}
if (process.env["GOBOT_TOKEN" + UseGroupNotify] && Use_gobotNotify) {
GOBOT_TOKEN = process.env["GOBOT_TOKEN" + UseGroupNotify];
}
if (process.env["GOBOT_QQ" + UseGroupNotify] && Use_gobotNotify) {
GOBOT_QQ = process.env["GOBOT_QQ" + UseGroupNotify];
}
if (process.env["PUSH_KEY" + UseGroupNotify] && Use_serverNotify) {
SCKEY = process.env["PUSH_KEY" + UseGroupNotify];
}
if (process.env["WP_APP_TOKEN" + UseGroupNotify] && Use_WxPusher) {
WP_APP_TOKEN = process.env["WP_APP_TOKEN" + UseGroupNotify];
}
if (process.env["WP_TOPICIDS" + UseGroupNotify] && Use_WxPusher) {
WP_TOPICIDS = process.env["WP_TOPICIDS" + UseGroupNotify];
}
if (process.env["WP_UIDS" + UseGroupNotify] && Use_WxPusher) {
WP_UIDS = process.env["WP_UIDS" + UseGroupNotify];
}
if (process.env["WP_URL" + UseGroupNotify] && Use_WxPusher) {
WP_URL = process.env["WP_URL" + UseGroupNotify];
}
if (process.env["BARK_PUSH" + UseGroupNotify] && Use_BarkNotify) {
if (process.env["BARK_PUSH" + UseGroupNotify].indexOf('https') > -1 || process.env["BARK_PUSH" + UseGroupNotify].indexOf('http') > -1) {
//兼容BARK自建用户
BARK_PUSH = process.env["BARK_PUSH" + UseGroupNotify];
} else {
//兼容BARK本地用户只填写设备码的情况
BARK_PUSH = `https://api.day.app/${process.env["BARK_PUSH" + UseGroupNotify]}`;
}
if (process.env["BARK_SOUND" + UseGroupNotify]) {
BARK_SOUND = process.env["BARK_SOUND" + UseGroupNotify];
}
if (process.env["BARK_GROUP" + UseGroupNotify]) {
BARK_GROUP = process.env;
}
}
if (process.env["TG_BOT_TOKEN" + UseGroupNotify] && Use_tgBotNotify) {
TG_BOT_TOKEN = process.env["TG_BOT_TOKEN" + UseGroupNotify];
}
if (process.env["TG_USER_ID" + UseGroupNotify] && Use_tgBotNotify) {
TG_USER_ID = process.env["TG_USER_ID" + UseGroupNotify];
}
if (process.env["TG_PROXY_AUTH" + UseGroupNotify] && Use_tgBotNotify)
TG_PROXY_AUTH = process.env["TG_PROXY_AUTH" + UseGroupNotify];
if (process.env["TG_PROXY_HOST" + UseGroupNotify] && Use_tgBotNotify)
TG_PROXY_HOST = process.env["TG_PROXY_HOST" + UseGroupNotify];
if (process.env["TG_PROXY_PORT" + UseGroupNotify] && Use_tgBotNotify)
TG_PROXY_PORT = process.env["TG_PROXY_PORT" + UseGroupNotify];
if (process.env["TG_API_HOST" + UseGroupNotify] && Use_tgBotNotify)
TG_API_HOST = process.env["TG_API_HOST" + UseGroupNotify];
if (process.env["DD_BOT_TOKEN" + UseGroupNotify] && Use_ddBotNotify) {
DD_BOT_TOKEN = process.env["DD_BOT_TOKEN" + UseGroupNotify];
if (process.env["DD_BOT_SECRET" + UseGroupNotify]) {
DD_BOT_SECRET = process.env["DD_BOT_SECRET" + UseGroupNotify];
}
}
if (process.env["QYWX_KEY" + UseGroupNotify] && Use_qywxBotNotify) {
QYWX_KEY = process.env["QYWX_KEY" + UseGroupNotify];
}
if (process.env["QYWX_AM" + UseGroupNotify] && Use_qywxamNotify) {
QYWX_AM = process.env["QYWX_AM" + UseGroupNotify];
}
if (process.env["IGOT_PUSH_KEY" + UseGroupNotify] && Use_iGotNotify) {
IGOT_PUSH_KEY = process.env["IGOT_PUSH_KEY" + UseGroupNotify];
}
if (process.env["PUSH_PLUS_TOKEN" + UseGroupNotify] && Use_pushPlusNotify) {
PUSH_PLUS_TOKEN = process.env["PUSH_PLUS_TOKEN" + UseGroupNotify];
}
if (process.env["PUSH_PLUS_USER" + UseGroupNotify] && Use_pushPlusNotify) {
PUSH_PLUS_USER = process.env["PUSH_PLUS_USER" + UseGroupNotify];
}
if (process.env["PUSH_PLUS_TOKEN_hxtrip" + UseGroupNotify] && Use_pushPlushxtripNotify) {
PUSH_PLUS_TOKEN_hxtrip = process.env["PUSH_PLUS_TOKEN_hxtrip" + UseGroupNotify];
}
if (process.env["PUSH_PLUS_USER_hxtrip" + UseGroupNotify] && Use_pushPlushxtripNotify) {
PUSH_PLUS_USER_hxtrip = process.env["PUSH_PLUS_USER_hxtrip" + UseGroupNotify];
}
if (process.env["GOTIFY_URL" + UseGroupNotify]) {
GOTIFY_URL = process.env["GOTIFY_URL" + UseGroupNotify];
}
if (process.env["GOTIFY_TOKEN" + UseGroupNotify]) {
GOTIFY_TOKEN = process.env["GOTIFY_TOKEN" + UseGroupNotify];
}
if (process.env["GOTIFY_PRIORITY" + UseGroupNotify]) {
GOTIFY_PRIORITY = process.env["GOTIFY_PRIORITY" + UseGroupNotify];
}
//检查是否在不使用Remark进行名称替换的名单
const notifySkipRemarkList = process.env.NOTIFY_SKIP_NAMETYPELIST ? process.env.NOTIFY_SKIP_NAMETYPELIST.split('&') : [];
const titleIndex3 = notifySkipRemarkList.findIndex((item) => item === strTitle);
if (text == "京东到家果园互助码:") {
ShowRemarkType = "1";
if (desp) {
var arrTemp = desp.split(",");
var allCode = "";
for (let k = 0; k < arrTemp.length; k++) {
if (arrTemp[k]) {
if (arrTemp[k].substring(0, 1) != "@")
allCode += arrTemp[k] + ",";
}
}
if (allCode) {
desp += '\n' + '\n' + "ccwav格式化后的互助码:" + '\n' + allCode;
}
}
}
if (ShowRemarkType != "1" && titleIndex3 == -1) {
console.log("sendNotify正在处理账号Remark.....");
//开始读取青龙变量列表
const envs = await getEnvs();
if (envs[0]) {
var strTempdesp = [];
var strAllNotify = "";
if (text == "京东资产变动" || text == "京东资产变动#2" || text == "京东资产变动#3" || text == "京东资产变动#4") {
strTempdesp = desp.split('🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏');
if (strTempdesp.length == 2) {
strAllNotify = strTempdesp[0];
desp = strTempdesp[1];
}
}
for (let i = 0; i < envs.length; i++) {
cookie = envs[i].value;
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
$.Remark = getRemark(envs[i].remarks);
$.nickName = "";
$.FoundnickName = "";
$.FoundPin = "";
//判断有没有Remark,没有搞个屁,有的继续
if ($.Remark) {
//先查找缓存文件中有没有这个账号,有的话直接读取别名
if (envs[i].status == 0) {
if (TempCK) {
for (let j = 0; j < TempCK.length; j++) {
if (TempCK[j].pt_pin == $.UserName) {
$.FoundPin = TempCK[j].pt_pin;
$.nickName = TempCK[j].nickName;
}
}
}
if (!$.FoundPin) {
//缓存文件中有没有这个账号,调用京东接口获取别名,并更新缓存文件
console.log($.UserName + "好像是新账号,尝试获取别名.....");
await GetnickName();
if (!$.nickName) {
console.log("别名获取失败,尝试调用另一个接口获取别名.....");
await GetnickName2();
}
if ($.nickName) {
console.log("好像是新账号,从接口获取别名" + $.nickName);
} else {
console.log($.UserName + "该账号没有别名.....");
}
tempAddCK = {
"pt_pin": $.UserName,
"nickName": $.nickName
};
TempCK.push(tempAddCK);
//标识,需要更新缓存文件
boolneedUpdate = true;
}
}
$.nickName = $.nickName || $.UserName;
//开始替换内容中的名字
if (ShowRemarkType == "2") {
$.Remark = $.nickName + "(" + $.Remark + ")";
}
if (ShowRemarkType == "3") {
$.Remark = $.UserName + "(" + $.Remark + ")";
}
try {
//额外处理1,nickName包含星号
$.nickName = $.nickName.replace(new RegExp(`[*]`, 'gm'), "[*]");
text = text.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark);
if (text == "京东资产变动" || text == "京东资产变动#2" || text == "京东资产变动#3" || text == "京东资产变动#4") {
var Tempinfo = "";
if(envs[i].created)
Tempinfo=getQLinfo(cookie, envs[i].created, envs[i].timestamp, envs[i].remarks);
else
if(envs[i].updatedAt)
Tempinfo=getQLinfo(cookie, envs[i].createdAt, envs[i].updatedAt, envs[i].remarks);
else
Tempinfo=getQLinfo(cookie, envs[i].createdAt, envs[i].timestamp, envs[i].remarks);
if (Tempinfo) {
$.Remark += Tempinfo;
}
}
desp = desp.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark);
strsummary = strsummary.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark);
//额外处理2,nickName不包含星号,但是确实是手机号
var tempname = $.UserName;
if (tempname.length == 13 && tempname.substring(8)) {
tempname = tempname.substring(0, 3) + "[*][*][*][*][*]" + tempname.substring(8);
//console.log("额外处理2:"+tempname);
text = text.replace(new RegExp(tempname, 'gm'), $.Remark);
desp = desp.replace(new RegExp(tempname, 'gm'), $.Remark);
strsummary = strsummary.replace(new RegExp(tempname, 'gm'), $.Remark);
}
} catch (err) {
console.log("替换出错了");
console.log("Debug Name1 :" + $.UserName);
console.log("Debug Name2 :" + $.nickName);
console.log("Debug Remark :" + $.Remark);
}
//console.log($.nickName+$.Remark);
}
}
}
console.log("处理完成,开始发送通知...");
if (strAllNotify) {
desp = strAllNotify + "\n" + desp;
}
}
} catch (error) {
console.error(error);
}
if (boolneedUpdate) {
var str = JSON.stringify(TempCK, null, 2);
fs.writeFile(strCKFile, str, function (err) {
if (err) {
console.log(err);
console.log("更新CKName_cache.json失败!");
} else {
console.log("缓存文件CKName_cache.json更新成功!");
}
})
}
//提供6种通知
desp = buildLastDesp(desp, author)
await serverNotify(text, desp); //微信server酱
if (PUSH_PLUS_TOKEN_hxtrip) {
console.log("hxtrip TOKEN :" + PUSH_PLUS_TOKEN_hxtrip);
}
if (PUSH_PLUS_USER_hxtrip) {
console.log("hxtrip USER :" + PUSH_PLUS_USER_hxtrip);
}
PushErrorTime = 0;
await pushPlusNotifyhxtrip(text, desp); //pushplushxtrip(推送加)
if (PushErrorTime > 0) {
console.log("等待1分钟后重试.....");
await $.wait(60000);
await pushPlusNotifyhxtrip(text, desp);
}
if (PUSH_PLUS_TOKEN) {
console.log("PUSH_PLUS TOKEN :" + PUSH_PLUS_TOKEN);
}
if (PUSH_PLUS_USER) {
console.log("PUSH_PLUS USER :" + PUSH_PLUS_USER);
}
PushErrorTime = 0;
await pushPlusNotify(text, desp); //pushplus(推送加)
if (PushErrorTime > 0) {
console.log("等待1分钟后重试.....");
await $.wait(60000);
await pushPlusNotify(text, desp); //pushplus(推送加)
}
if (PushErrorTime > 0) {
console.log("等待1分钟后重试.....");
await $.wait(60000);
await pushPlusNotify(text, desp); //pushplus(推送加)
}
//由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动
text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text;
await Promise.all([
BarkNotify(text, desp, params), //iOS Bark APP
tgBotNotify(text, desp), //telegram 机器人
ddBotNotify(text, desp), //钉钉机器人
qywxBotNotify(text, desp), //企业微信机器人
qywxamNotify(text, desp, strsummary), //企业微信应用消息推送
iGotNotify(text, desp, params), //iGot
gobotNotify(text, desp), //go-cqhttp
gotifyNotify(text, desp), //gotify
wxpusherNotify(text, desp) // wxpusher
]);
}
function getuuid(strRemark, PtPin) {
var strTempuuid = "";
if (strRemark) {
var Tempindex = strRemark.indexOf("@@");
if (Tempindex != -1) {
console.log(PtPin + ": 检测到NVJDC的一对一格式,瑞思拜~!");
var TempRemarkList = strRemark.split("@@");
for (let j = 0; j < TempRemarkList.length; j++) {
if (TempRemarkList[j]) {
if (TempRemarkList[j].length > 4) {
if (TempRemarkList[j].substring(0, 4) == "UID_") {
strTempuuid = TempRemarkList[j];
break;
}
}
}
}
if (!strTempuuid) {
console.log("检索资料失败...");
}
}
}
if (!strTempuuid && TempCKUid) {
console.log("正在从CK_WxPusherUid文件中检索资料...");
for (let j = 0; j < TempCKUid.length; j++) {
if (PtPin == decodeURIComponent(TempCKUid[j].pt_pin)) {
strTempuuid = TempCKUid[j].Uid;
break;
}
}
}
return strTempuuid;
}
function getQLinfo(strCK, intcreated, strTimestamp, strRemark) {
var strCheckCK = strCK.match(/pt_key=([^; ]+)(?=;?)/) && strCK.match(/pt_key=([^; ]+)(?=;?)/)[1];
var strPtPin = decodeURIComponent(strCK.match(/pt_pin=([^; ]+)(?=;?)/) && strCK.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
var strReturn = "";
if (strCheckCK.substring(0, 3) == "AAJ") {
var DateCreated = new Date(intcreated);
var DateTimestamp = new Date(strTimestamp);
var DateToday = new Date();
if (strRemark) {
var Tempindex = strRemark.indexOf("@@");
if (Tempindex != -1) {
//console.log(strPtPin + ": 检测到NVJDC的备注格式,尝试获取登录时间,瑞思拜~!");
var TempRemarkList = strRemark.split("@@");
for (let j = 1; j < TempRemarkList.length; j++) {
if (TempRemarkList[j]) {
if (TempRemarkList[j].length == 13) {
DateTimestamp = new Date(parseInt(TempRemarkList[j]));
//console.log(strPtPin + ": 获取登录时间成功:" + GetDateTime(DateTimestamp));
break;
}
}
}
}
}
//过期时间
var UseDay = Math.ceil((DateToday.getTime() - DateCreated.getTime()) / 86400000);
var LogoutDay = 30 - Math.ceil((DateToday.getTime() - DateTimestamp.getTime()) / 86400000);
if (LogoutDay < 1) {
strReturn = "\n【登录信息】总挂机" + UseDay + "天(账号即将到期,请重登续期)"
} else {
strReturn = "\n【登录信息】总挂机" + UseDay + "天(有效期约剩" + LogoutDay + "天)"
}
}
return strReturn
}
function getRemark(strRemark) {
if (strRemark) {
var Tempindex = strRemark.indexOf("@@");
if (Tempindex != -1) {
var TempRemarkList = strRemark.split("@@");
return TempRemarkList[0].trim();
} else {
//这是为了处理ninjia的remark格式
strRemark = strRemark.replace("remark=", "");
strRemark = strRemark.replace(";", "");
return strRemark.trim();
}
} else {
return "";
}
}
async function sendNotifybyWxPucher(text, desp, PtPin, author = '\n\n本通知 By ccwav Mod', strsummary = "") {
try {
var Uid = "";
var UserRemark = "";
var strTempdesp = [];
var strAllNotify = "";
if (text == "京东资产变动") {
strTempdesp = desp.split('🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏');
if (strTempdesp.length == 2) {
strAllNotify = strTempdesp[0];
desp = strTempdesp[1];
}