forked from Akali5/jd-depot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jd_ckck3.sh
executable file
·1804 lines (1664 loc) · 81.8 KB
/
jd_ckck3.sh
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
#!/usr/bin/env bash
## 版本号
Ver="Build 20220405-001-Alpha"
## 导入通用变量与函数
[[ -d "/ql/shell" ]] && dir_shell=/ql/shell
[[ -f "$dir_shell/share.sh" ]] && . $dir_shell/share.sh
## emoji 符号及分隔线
emoji_OK="✅"
emoji_NO="🚫"
emoji_UNKNOW="❓"
emoji_MSG="📑"
emoji_ON="🉑"
emoji_OFF="🈲"
emoji_NONE="🈚️"
emoji_DATE="📆"
emoji_SOS="🆘"
emoji_CHART="📊"
emoji_OUTBOX="📤"
emoji_INBOX="📥"
line="————————————————————————————————————————————"
## 获取 token
get_token() {
local api_type=$1
case $api_type in
open)
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "${QL_URL_PORT}/open/auth/token?client_id=${QL_client_id}&client_secret=${QL_client_secret}"
)
if [[ $api =~ \"code\" ]]; then
local code=$(echo $api | jq -r .code)
[[ $api =~ \"msg\" ]] && local msg="($(echo $api | jq -r .msg))"
if [[ $code == 200 ]]; then
token="$(echo $api | jq -r .data.token)"
else
echo -e "# 获取token失败(${msg})"
fi
else
echo -e "# 访问青龙失败,请检查地址、端口、OpenAPI的client_id、client_secret(${msg})"
fi
;;
closure)
token=$(cat $file_auth_user | jq -r .token)
;;
esac
}
## 版本号判断
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
# 读取青龙容器版本号
def_ql_version(){
case $1 in
open)
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "${QL_URL_PORT}/api/system" | jq -r .data.version
;;
closure)
curl -s --noproxy "*" "http://0.0.0.0:5600/api/system" | jq -r .data|jq -r .version
;;
esac
}
# 定义 json 数据查询工具
def_envs_tool(){
local token
get_token $1
if [[ $token ]]; then
case $1 in
open)
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "${QL_URL_PORT}/open/envs?searchValue=$2" -H "Authorization: Bearer $token" | jq .data
;;
closure)
curl -s --noproxy "*" "http://0.0.0.0:5600/api/envs?searchValue=$2" -H "Authorization: Bearer $token" | jq .data
;;
esac
fi
}
def_json_total(){
def_envs_tool $1 $2 | jq .[].$3 | tr -d '[]," '
}
def_json_grep_match(){
def_envs_tool $1 $2 | jq .[] | perl -pe '{s|([^}])\n|\1|g}' | grep "$4" | jq .$3 | tr -d '[]," '
}
def_json(){
def_envs_tool $1 $2 | jq .[$3].$4 | perl -pe '{s|^"\|"$||g}' | grep -v "null"
}
def_json_match(){
if [[ -f $1 ]]; then
if [[ $3 && $(cat "$1" | grep "$3") ]]; then
cat "$1" | perl -pe '{s|^\[\|\]$||g; s|\n||g; s|\},$|\}\n|g}' | grep "$2" | jq -r .$3 | grep -v "null"
else
cat "$1" | perl -pe '{s|^\[\|\]$||g; s|\n||g; s|\},$|\}\n|g}' | grep "$2" | grep -v "null"
fi
fi
}
def_json_value(){
if [[ -f $1 ]]; then
if [[ $(cat "$1" | grep "$2") ]]; then
cat "$1" | perl -pe "{s|^\[\|\]$||g; s|\n||g; s|\},$|\}\n|g}" | grep "$3" | jq -r .$2 | grep -v "null"
fi
fi
}
def_sub(){
local i j
for i in $(def_json_total $1 $2 $3 | awk '/'$4'/{print NR}'); do
j=$((i - 1));
echo $j
done
}
def_sub_value(){
local line=$(($3 + 1))
def_json_total $1 $2 $3 | awk 'NR=='$line''
}
# 时间戳转时间长度
UTC(){
local i=$1
local d h m s ms
if [[ $i -gt 0 ]]; then
d=$[i/86400000]
h=$[(i-d*86400000)/3600000]
m=$[(i-d*86400000-h*3600000)/60000]
s=$[(i-d*86400000-h*3600000-m*60000)/1000]
ms=$[i-d*86400000-h*3600000-m*60000-s*1000]
[[ $d -gt 0 ]] && d="$d天" || d=""
[[ $h -gt 0 ]] && h="$h小时" || h=""
[[ $m -gt 0 ]] && m="$m分" || m=""
[[ $s -gt 0 ]] && s="$s秒" || s=""
[[ $ms -gt 0 ]] && ms="$ms毫秒" || ms=""
if [[ $d || $h || $m || $s || $ms ]]; then
echo "$d$h$m$s$ms"
else
echo "临期"
fi
fi
}
# 区间抽取随机数
random(){
local min=$1
local max=$2
local RAND=`od -t uI -N 4 /dev/urandom | awk '{print $2}'`
RAND=$[RAND%$[max-min+1]+min]
echo $RAND
}
## 生成 json 值数组
gen_basic_value(){
for i in $@; do
eval $i='($(def_json_total $ck_api_type JD_COOKIE $i))'
done
}
## 预备工作
pre_work() {
# 青龙变量 key 识别
#if version_lt $cur_version 2.11.0; then
# tmp_id="_id"
#else
# tmp_id="id"
#fi
remote_id="id"
[[ $(def_json_total $ck_api_type JD_COOKIE $remote_id) =~ null ]] && remote_id="_id"
local_id="id"
[[ $(def_json_total $wskey_api_type JD_WSCK $local_id) =~ null ]] && local_id="_id"
remote_update_timestamp="updatedAt"
[[ $(def_json_total $ck_api_type JD_COOKIE $remote_update_timestamp) =~ null ]] && remote_update_timestamp="timestamp"
# 生成 JD_COOKIE id 面板更新时间 备注数组
gen_basic_value value $remote_id remarks
# 生成序号数组
sn=($(def_json_total $ck_api_type JD_COOKIE value | awk '{print NR}'))
# 生成pin值数组
pin=($(def_json_total $ck_api_type JD_COOKIE value | perl -pe "{s|.*pt_pin=([^;\; ]+)(?=;?).*|\1|}"))
# 生成非转码pin值数组
pt_pin=($(urldecode "${pin[*]}"))
NOTIFY_WxPusher_Condition
Dump_Sign_UA_json
wskey_array=($(def_json_total $wskey_api_type JD_WSCK value))
LOCAL_DIR="$(cd $(dirname ${BASH_SOURCE:-$0});pwd)"
[[ $dir_scripts ]] && json_path="$dir_scripts" || json_path="$LOCAL_DIR"
[[ $dir_log ]] && json_log_path="$dir_log" || json_log_path="$LOCAL_DIR"
UA_cache_array=($(def_json_value "$json_path/CK_Sign_UA.json" UA))
sign_cache_array=($(def_json_value "$json_path/CK_Sign_UA.json" sign))
ori_valid_pin=($(def_json_match "$json_path/CK_WxPusherUid.json" '"status": 0' pin))
[[ ! ${ori_valid_pin[@]} ]] && ori_valid_pin=($(def_json_grep_match $ck_api_type JD_COOKIE value '"status": 0' | perl -pe "{s|.*pt_pin=([^;\; ]+)(?=;?).*|\1|}"))
ori_invalid_pin=($(def_json_match "$json_path/CK_WxPusherUid.json" '"status": 1' pin))
[[ ! ${ori_invalid_pin[@]} ]] && ori_invalid_pin=($(def_json_grep_match $ck_api_type JD_COOKIE value '"status": 1' | perl -pe "{s|.*pt_pin=([^;\; ]+)(?=;?).*|\1|}"))
[[ -n "$(echo $NOTIFY_VALID_DAY | sed -n "/^[0-9]\+$/p")" ]] && notify_valid_period="$((NOTIFY_VALID_DAY * 86400000))" || notify_valid_period=""
[[ -n "$(echo $WSKEY_UPDATE_VALIDITY_HOUR | sed -n "/^[0-9]\+$/p")" ]] && wskey_update_validity_period="$((WSKEY_UPDATE_VALIDITY_HOUR * 3600000))" || wskey_update_validity_period=""
#content_top=$(echo "$ExNotify_Top_Content" | awk '{print $0"\n\n"}')
#content_bot=$(echo "$ExNotify_Bot_Content" | awk '{print "\n\n"$0}')
content_top="$ExNotify_Top_Content\n\n"
content_bot="\n\n$ExNotify_Bot_Content"
[[ $WSKEY_AUTO_ENABLE ]] && process_notify_type_0="生效" || process_notify_type_0="重启"
[[ $WSKEY_AUTO_DISABLE ]] && process_notify_type_1="失效" || process_notify_type_1="禁用"
}
UA_array=(
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017311801,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YtVtZJCzCJPrDtU0ZJS0DK==","od":"YwDrZQCyYJSmCtUnDwG5EK==","ov":"CzO=","ud":"YtVtZJCzCJPrDtU0ZJS0DK=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017332518,"ridx":-1,"cipher":{"sv":"CJS=","ad":"EWTrCJu0ZtTwEWZrEWYmYG==","od":"EJY4YtdsEQDvYJumYzO4ZG==","ov":"CzO=","ud":"EWTrCJu0ZtTwEWZrEWYmYG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017353909,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YtuyZwHrZtG1EWC4CwDrCq==","od":"EJOmYzY4DQPuDJTsDwY3Dq==","ov":"CzO=","ud":"YtuyZwHrZtG1EWC4CwDrCq=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017371843,"ridx":-1,"cipher":{"sv":"CJS=","ad":"EJK5ZJDrZtTuCJTtZWSnCm==","od":"YWG5ZNUyDtvrENc3DWDsZG==","ov":"CzO=","ud":"EJK5ZJDrZtTuCJTtZWSnCm=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017391063,"ridx":-1,"cipher":{"sv":"CJS=","ad":"EWU3CQCzCtdsCWTtYWYnDK==","od":"EJc4YJPuZWC0ZNK1YtumYq==","ov":"CzO=","ud":"EWU3CQCzCtdsCWTtYWYnDK=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017404692,"ridx":-1,"cipher":{"sv":"CJS=","ad":"ENK2CQGmDNqzYzczZtcyDK==","od":"YtY2DJUyDtG2YwU2EQY3YG==","ov":"CzO=","ud":"ENK2CQGmDNqzYzczZtcyDK=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017422249,"ridx":-1,"cipher":{"sv":"CJS=","ad":"EWO0YwHwEJU2ZtVtZNC5Dm==","od":"EQTwDQS1Yzq2ZJY3C2G1Ym==","ov":"CzO=","ud":"EWO0YwHwEJU2ZtVtZNC5Dm=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017438445,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YJY4DzumZtqmZtCzY2Y1ZK==","od":"ENK5ENKzYJG1ZwS0DtLtDG==","ov":"CzO=","ud":"YJY4DzumZtqmZtCzY2Y1ZK=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017462999,"ridx":-1,"cipher":{"sv":"CJS=","ad":"Ytu5DzvsCtOmEQC4YwDuCG==","od":"Ytc4DQDtDJvvCWSzDtTvYG==","ov":"CzO=","ud":"Ytu5DzvsCtOmEQC4YwDuCG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017508723,"ridx":-1,"cipher":{"sv":"CJS=","ad":"ENu2Y2ZrDWTwYwO5DtTrDG==","od":"YJcyCzO0ENPvDwY3EJC2Dm==","ov":"CzO=","ud":"ENu2Y2ZrDWTwYwO5DtTrDG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017524153,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YtVtCtLsZNK5C2U5CQY3Cm==","od":"YJK2ZtrsZWUyCNc2ZWG1Yq==","ov":"CzO=","ud":"YtVtCtLsZNK5C2U5CQY3Cm=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017540904,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YwY0DwO2YWVuDzPuZJczYm==","od":"YJDuZWVwCzvwYtq3YtDvCm==","ov":"CzO=","ud":"YwY0DwO2YWVuDzPuZJczYm=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017554598,"ridx":-1,"cipher":{"sv":"CJS=","ad":"EJq4ZJDsCzVrCzS4CQOmDm==","od":"EJTsY2GmEWHtCJPuDzY3DG==","ov":"CzO=","ud":"EJq4ZJDsCzVrCzS4CQOmDm=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017568630,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YtvwCtrtDwY2YJG3ENumYG==","od":"EJrvEQTsENKzCNOmY2Y4ZG==","ov":"CzO=","ud":"YtvwCtrtDwY2YJG3ENumYG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017582006,"ridx":-1,"cipher":{"sv":"CJS=","ad":"ENC5YzPrYtduYWS1CJvuYG==","od":"YWDuCNLvDJdvYWVsY2HwZq==","ov":"CzO=","ud":"ENC5YzPrYtduYWS1CJvuYG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017595384,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YtZtC2TrDQU4CzY5DQS2DG==","od":"YtK2CQZvDJq1C2S3ZNrrEG==","ov":"CzO=","ud":"YtZtC2TrDQU4CzY5DQS2DG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017608189,"ridx":-1,"cipher":{"sv":"CJS=","ad":"ENrsYzDrDtHwYzLrYtTwZG==","od":"YJOmZQG3CwVsENcmEJTwCK==","ov":"CzO=","ud":"ENrsYzDrDtHwYzLrYtTwZG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017621253,"ridx":-1,"cipher":{"sv":"CJS=","ad":"EJdvDJc1ZNUyY2PtZQHwCG==","od":"YtC3DQO3Y2OyENc5EQU1Dq==","ov":"CzO=","ud":"EJdvDJc1ZNUyY2PtZQHwCG=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017633805,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YwG1CwOzDQCmDWZrDWDrCq==","od":"YJKnENY0CQGnDQPtCzC5DK==","ov":"CzO=","ud":"YwG1CwOzDQCmDWZrDWDrCq=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
'jdapp;android;10.3.5;;;appBuild/92468;ef/1;ep/{"hdid":"JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=","ts":1647017647337,"ridx":-1,"cipher":{"sv":"CJS=","ad":"YJZwENKnDNDrCtu3ENUyDq==","od":"YtY4DtdtYtumCzDrCtU4Zq==","ov":"CzO=","ud":"YJZwENKnDNDrCtu3ENUyDq=="},"ciphertype":5,"version":"1.2.0","appname":"com.jingdong.app.mall"};Mozilla/5.0'
)
# 生成一对一通知的时间条件
NOTIFY_WxPusher_Condition(){
local current_H hour
current_H=`date +%H`
local NOTIFY_WxPusher_TIME=$(eval echo $(echo $NOTIFY_WxPusher_TIME | perl -pe "{s|~\|-|_|g; s|\W+\|[A-Za-z]+| |g; s|(\d+)_(\d+)|{\1..\2}|g;}"))
NOTIFY_WxPusher_Schedule=""
for hour in $NOTIFY_WxPusher_TIME; do
[[ $hour = $current_H ]] && NOTIFY_WxPusher_Schedule="on" && break
done
}
#青龙启用/禁用环境变量API
ql_process_env_api() {
local token
local currentTimeStamp=$(date +%s)
local api_type=$1
local name=$2
local id=$3
local status_code=$4
local process_chinese=$5
local emoji
[[ $status_code = 0 ]] && process=enable && emoji=${emoji_ON}
[[ $status_code = 1 ]] && process=disable && emoji=${emoji_OFF}
case $api_type in
open)
local url="${QL_URL_PORT}/open/envs/$process"
;;
closure)
local url="http://0.0.0.0:5600/api/envs/$process"
;;
esac
get_token $api_type
if [[ $token ]]; then
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url?t=$currentTimeStamp" \
-X 'PUT' \
-H "Accept: application/json" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json;charset=UTF-8" \
--data-raw "[\"$id\"]"
)
code=$(echo $api | jq -r .code)
message=$(echo $api | jq -r .message)
if [[ $code == 200 ]]; then
[[ $notify = on ]] && echo -n "${emoji} $name$process_chinese"
else
[[ $notify = on ]] && echo -n "${emoji} $name$process_chinese失败(${message})"
fi
fi
}
#青龙添加环境变量API
ql_add_env_api() {
local token
local currentTimeStamp=$(date +%s)
local api_type=$1
local name=$2
local value=$3
local remarks=$4
case $api_type in
open)
local url="${QL_URL_PORT}/open/envs"
;;
closure)
local url="http://0.0.0.0:5600/api/envs"
;;
esac
get_token $api_type
if [[ $token ]]; then
if [[ $remarks ]]; then
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url?t=$currentTimeStamp" \
-X 'POST' \
-H "Accept: application/json" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json;charset=UTF-8" \
--data-raw "[{\"name\":\"$name\",\"value\":\"$value\",\"remarks\":\"$remarks\"}]"
)
else
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url?t=$currentTimeStamp" \
-X 'POST' \
-H "Accept: application/json" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json;charset=UTF-8" \
--data-raw "[{\"name\":\"$name\",\"value\":\"$value\"}]"
)
fi
code=$(echo $api | jq -r .code)
message=$(echo $api | jq -r .message)
if [[ $code == 200 ]]; then
[[ $notify = on ]] && echo -n "${emoji_OK} $name -> 添加成功"
else
[[ $notify = on ]] && echo -n "${emoji_NO} $name -> 添加失败(${message})"
fi
fi
}
#青龙更新环境变量API
ql_update_env_api() {
local token id_type
local currentTimeStamp=$(date +%s)
local api_type=$1
local name=$2
local value=$3
local id=$4
local remarks=$5
local message=$6
case $api_type in
open)
id_type=$remote_id
local url="${QL_URL_PORT}/open/envs"
;;
closure)
id_type=$local_id
local url="http://0.0.0.0:5600/api/envs"
;;
esac
get_token $api_type
if [[ $token ]]; then
if [[ $remarks ]]; then
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url?t=$currentTimeStamp" \
-X 'PUT' \
-H "Accept: application/json" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json;charset=UTF-8" \
--data-raw "{\"name\":\"$name\",\"value\":\"$value\",\"$id_type\":\"$id\",\"remarks\":\"$remarks\"}"
)
else
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url?t=$currentTimeStamp" \
-X 'PUT' \
-H "Accept: application/json" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json;charset=UTF-8" \
--data-raw "{\"name\":\"$name\",\"value\":\"$value\",\"$id_type\":\"$id\"}"
)
fi
code=$(echo $api | jq -r .code)
if [[ $code == 200 ]]; then
[[ $notify = on ]] && echo -n "${emoji_OK} $name -> 更新成功(${message})"
else
message=$(echo $api | jq -r .message)
[[ $notify = on ]] && echo -n "${emoji_NO} $name -> 更新失败(${message})"
fi
fi
}
# 查询 WxPusher 应用用户 APT
check_WxPusher_User(){
local appToken=$1
local page=$2
local pageSize=$3
local isBlock$4
local host="http://wxpusher.zjiecode.com/api/fun/wxuser/v2"
local url="http://wxpusher.zjiecode.com/api/fun/wxuser/v2?appToken=${appToken}&page=${page}&pageSize=${pageSize}"
local api=$(
curl -s -k --connect-timeout 20 --retry 3 --noproxy "*" "${url}"
)
}
## WxPusher 通知 API
WxPusher_notify_api() {
local appToken=$1
local uids=$2
local title=$3
local summary=$4
local content=$5
local frontcontent=$6
local summary=$(echo -e "$title\n\n$summary" | perl -pe '{s|(\")|'\\'\\1|g; s|\n|<br>|g}')
[[ ${#summary} -ge 100 ]] && local summary="${summary:0:88} ……"
local content=$(echo -e "$title\n\n$content" | perl -pe '{s|(\")|'\\'\\1|g; s|\n|<br>|g}')
local url="http://wxpusher.zjiecode.com/api/send/message"
local api=$(
curl -s --noproxy "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"appToken\":\"${appToken}\",\"content\":\"${content}\",\"summary\":\"${summary}\",\"contentType\":\"2\",\"uids\":[$uids]}"
)
code=$(echo $api | jq -r .code)
msg=$(echo $api | jq -r .msg)
if [[ $code == 1000 ]]; then
echo -e "${emoji_OUTBOX}$frontcontent WxPusher 消息发送成功(${uids})"
else
[[ ! $msg ]] && msg="访问 API 超时"
echo -e "${emoji_INBOX}$frontcontent WxPusher 消息发送处理失败(${msg})"
fi
}
## 企业微信机器人通知 API
QYWX_Bot_notify_api() {
local bot_key=$1
local title=$2
local content=$3
local frontcontent=$4
local content="$title\n\n$content"
local content=$(echo -e "$content" | perl -pe '{s|(\")|'\\'\\1|g}')
local url="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${bot_key}"
local api=$(
curl -s --noproxy "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"msgtype\":\"text\",\"text\":{\"content\":\"$content\"}}"
)
code=$(echo $api | jq -r .errcode)
msg=$(echo $api | jq -r .errmsg)
if [[ $code == 0 ]]; then
echo -e "${emoji_OUTBOX}$frontcontent 企业微信机器人消息发送成功"
else
[[ ! $msg ]] && msg="访问 API 超时"
echo -e "${emoji_INBOX}$frontcontent 企业微信机器人消息发送处理失败(${msg})"
fi
}
## 企业微信应用通知 API
QYWX_notify_api() {
local corpid="$(echo $1 | awk -F ',' '{print $1}')"
local corpsecret="$(echo $1 | awk -F ',' '{print $2}')"
local userId="$(echo $1 | awk -F ',' '{print $3}')"
local agentid="$(echo $1 | awk -F ',' '{print $4}')"
local thumb_media_id="$(echo $1 | awk -F ',' '{print $5}')"
local author=$2
local title=$3
local digest=$4
local content=$5
local frontcontent=$6
local ACCESS_TOKEN
local digest=$(echo -e "$digest" | perl -pe '{s|(\")|'\\'\\1|g}')
local content=$(echo -e "$content" | perl -pe '{s|(\")|'\\'\\1|g; s|\n|<br>|g}')
local url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${corpid}&corpsecret=${corpsecret}"
local api=$(
curl -s --noproxy "*" "$url"
)
local code=$(echo $api | jq -r .errcode)
local msg=$(echo $api | jq -r .errmsg)
if [[ $code == 0 ]]; then
ACCESS_TOKEN=$(echo $api | jq -r .access_token)
local url="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${ACCESS_TOKEN}"
if [[ $thumb_media_id ]]; then
local api=$(
curl -s --noproxy "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"touser\":\"$userId\",\"msgtype\":\"mpnews\",\"agentid\":\"$agentid\",\"mpnews\":{\"articles\":[{\"title\":\"$title\",\"thumb_media_id\":\"$thumb_media_id\",\"author\":\"$author\",\"content\":\"$content\",\"digest\":\"$digest\"}]}}"
)
else
local api=$(
curl -s --noproxy "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"touser\":\"$userId\",\"msgtype\":\"mpnews\",\"agentid\":\"$agentid\",\"mpnews\":{\"articles\":[{\"title\":\"$title\",\"thumb_media_id\":\"$thumb_media_id\",\"author\":\"$author\",\"content\":\"$content\",\"digest\":\"$digest\"}]}}"
)
fi
code=$(echo $api | jq -r .errcode)
msg=$(echo $api | jq -r .errmsg)
if [[ $code == 0 ]]; then
echo -e "${emoji_OUTBOX}$frontcontent 企业微信应用消息发送成功"
else
[[ ! $msg ]] && msg="访问 API 超时"
echo -e "${emoji_INBOX}$frontcontent 企业微信应用消息发送处理失败(${msg})"
fi
fi
}
## pushplus 通知 API
pushplus_notify_api() {
local token=$1
local topic=$2
local title=$3
local content=$4
local frontcontent=$5
local content=$(echo -e "$content" | perl -pe '{s|(\")|'\\'\\1|g; s|\n|<br>|g}')
local url="http://www.pushplus.plus/send"
local api=$(
curl -s --noproxy "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"token\":\"$token\",\"title\":\"$title\",\"content\":\"$content\"}"
)
code=$(echo $api | jq -r .code)
msg=$(echo $api | jq -r .msg)
if [[ $code == 200 ]]; then
echo -e "${emoji_OUTBOX}$frontcontent pushplus 消息发送成功"
else
if [[ $code == 500 ]]; then
msg="服务器宕机"
fi
[[ ! $msg ]] && msg="访问 API 超时"
echo -e "${emoji_INBOX}$frontcontent pushplus 消息发送处理失败(${msg})"
fi
}
## hxtrip pushplus 通知 API
hxtrip_pushplus_notify_api() {
local token=$1
local topic=$2
local title=$3
local content=$4
local frontcontent=$5
local content=$(echo -e "$content" | perl -pe '{s|(\")|'\\'\\1|g; s|\n|<br>|g}')
local url="http://pushplus.hxtrip.com/send"
local api=$(
curl -s --noproxy "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"token\":\"$token\",\"title\":\"$title\",\"content\":\"$content\"}"
)
code=$(echo $api | perl -pe '{s|.*<code>([\d]+)</code>.*|\1|g}')
msg=$(echo $api | perl -pe '{s|.*<msg>([\S]+)</msg>.*|\1|g}')
if [[ $code == 200 ]]; then
echo -e "${emoji_OUTBOX}$frontcontent hxtrip pushplus 消息发送成功"
else
if [[ $code == 500 ]]; then
msg="服务器宕机"
fi
[[ ! $msg ]] && msg="访问 API 超时"
echo -e "${emoji_INBOX}$frontcontent hxtrip pushplus 消息发送处理失败(${msg})"
fi
}
## Telegram 通知 API
Telegram_notify_api() {
local token=$1
local chat_id=$2
local title=$3
local content=$4
local frontcontent=$5
local content=$(echo -e "$content" | perl -pe '{s|(\")|'\\'\\1|g; s|\n|\\n|g}')
[[ ! $TG_API_HOST ]] && TG_API_HOST="api.telegram.org"
local url="https://${TG_API_HOST}/bot${token}/sendMessage"
if [[ $TG_PROXY_HOST && $TG_PROXY_PORT && $TG_PROXY_AUTH ]]; then
local https_proxy=http://$TG_PROXY_AUTH@$TG_PROXY_HOST:$TG_PROXY_PORT/
elif [[ $TG_PROXY_HOST && $TG_PROXY_PORT ]]; then
local https_proxy=http://$TG_PROXY_HOST:$TG_PROXY_PORT/
else
local https_proxy=""
fi
local api=$(
curl -s --connect-timeout 20 --retry 3 "*" "$url" \
-X 'POST' \
-H "Content-Type: application/json" \
--data-raw "{\"chat_id\":\"${chat_id}\",\"text\":\"${title}\n\n${content}\",disable_web_page_preview:true}"
)
code=$(echo $api | jq -r .ok)
msg=$(echo $api | jq -r .description)
if [[ $code == true ]]; then
echo -e "${emoji_OUTBOX}$frontcontent Telegram 消息发送成功"
else
[[ ! $msg ]] && msg="访问 API 超时"
echo -e "${emoji_INBOX}$frontcontent Telegram 消息发送处理失败(${msg})"
fi
}
# JSON 字符串特殊符号处理
spc_sym_tr(){
#echo $1 | perl -pe '{s|(\"\|'\''\|\[\|\]\|{\|}\|\\\|\/\|`)|'\\'\\1|g}'
echo $1 | perl -pe '{s|(\")|'\\'\\1|g}'
}
# 字符串 urlencode 加密
urlencode() {
local LANG=C
for ((i=0;i<${#1};i++)); do
if [[ ${1:$i:1} =~ ^[a-zA-Z0-9\.\~\_\-]$ ]]; then
printf "${1:$i:1}"
else
printf '%%%02X' "'${1:$i:1}"
fi
done
}
# 字符串 urldecode 解密
urldecode() {
local url_encoded="${1//+/ }"
printf '%b' "${url_encoded//%/\\x}"
}
# 数组的汇总处理
print_array(){
local array=$1
echo ${array[@]}|perl -pe '{s|\\n[\s]+|\\n|g}'
}
## 获取用户信息 API 1
Get_CK_Status_1(){
local url="https://me-api.jd.com/user_new/info/GetJDUserInfoUnion"
local UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62"
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url" \
-H "Host: me-api.jd.com" \
-H "Accept: */*" \
-H "Connection: keep-alive" \
-H "Cookie: $cookie" \
-H "User-Agent: $UA" \
-H "Accept-Language: zh-cn" \
-H "Referer: https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&" \
-H "Accept-Encoding: deflate, br"
)
if [[ $api =~ \"retcode\" ]]; then
local retcode=$(echo $api | jq -r .retcode)
[[ $api =~ \"msg\" ]] && local msg="($(echo $api | jq -r .msg))"
if [[ $retcode == 0 ]]; then
ckck_code="0" && ckck_msg="Cookie 状态正常" && nickname="$(echo $api | jq -r .data | jq -r .userInfo | jq -r .baseInfo | jq -r .nickname)"
elif [[ $retcode == 1000 ]]; then
ckck_code="$retcode" && ckck_msg="${msg}"
elif [[ $retcode == 1001 ]]; then
ckck_code="1" && ckck_msg="Cookie 状态失效(${msg})"
else
ckck_code="$retcode" && ckck_msg="未知错误(${msg})"
fi
else
ckck_code="2" && ckck_msg="API 访问失败"
fi
}
## 获取用户信息 API 2
Get_CK_Status_2(){
local currentTimeStamp=$(date +%s)
local url="https://wxapp.m.jd.com/kwxhome/myJd/home.json?&useGuideModule=0&bizId=&brandId=&fromType=wxapp×tamp=$currentTimeStamp"
local UA="Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.10(0x18000a2a) NetType/WIFI Language/zh_CN"
local api=$(
curl -s --connect-timeout 20 --retry 3 --noproxy "*" "$url" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Host: wxapp.m.jd.com" \
-H "Connection: keep-alive" \
-H "Cookie: $cookie" \
-H "User-Agent: $UA" \
-H "Referer: https://servicewechat.com/wxa5bf5ee667d91626/161/page-frame.html" \
-H "Accept-Encoding: compress,deflate, br"
)
if [[ $api ]]; then
if [[ $api =~ \"petName\" ]]; then
ckck_code="0" && ckck_msg="Cookie 状态正常" && nickname="$(echo $api | jq -r .user | jq -r .petName)"
elif [[ $api =~ \"code\" ]]; then
local code=$(echo $api | jq -r .code)
[[ $api =~ \"msg\" ]] && local msg="($(echo $api | jq -r .msg))"
if [[ $code == 999 ]]; then
ckck_code="1" && ckck_msg="Cookie 状态失效${msg}"
else
ckck_code="3" && ckck_msg="未知错误${api}"
fi
else
ckck_code="3" && ckck_msg="未知错误${api}"
fi
else
ckck_code="2" && ckck_msg="API 访问失败"
fi
}
## 获取用户昵称 API
Get_NickName() {
local cookie=$1
Get_CK_Status_1
[[ $ckck_code = 2 ]] && Get_CK_Status_2
}
# 名称处理
Get_Full_Name(){
local i=$1
local j=${pin[i]}
local remarks_ori_id tmp_NickName_1 tmp_NickName_2 UserName nickname tmp_remarks_id_1 tmp_remarks_id_2 tmp_remarks_id_3 wskey_pin_sub
# 获取原始备注
remarks_ori[$j]="${remarks[i]}"
[[ ${remarks_ori[$j]} = null ]] && remarks_ori[$j]=""
# JD_COOKIE 相关值
value[i]="$(echo ${value[i]} | grep -Eo 'pt_key=[^;\; ]+' | head -1);pt_pin=$j;"
# wskey 相关值
wskey_value[$j]="$(def_json_grep_match $wskey_api_type JD_WSCK value "pin=$j;" | head -1)"
[[ ${wskey_value[$j]} =~ "wskey=" ]] && wskey_value[$j]="pin=$j;$(echo ${wskey_value[$j]} | grep -Eo 'wskey=[^;\; ]+' | head -1);"
wskey_id[$j]="$(def_json_grep_match $wskey_api_type JD_WSCK $local_id "pin=$j;" | head -1)"
wskey_remarks[$j]="$(def_json_grep_match $wskey_api_type JD_WSCK remarks "pin=$j;" | grep -v "null" | head -1)"
# 昵称及用户名处理
Get_NickName "${value[i]}"
tmp_NickName_1=${nickname}
tmp_NickName_2="$(def_json_value "$json_path/CK_WxPusherUid.json" NickName "pin=$j;")"
if [[ ${tmp_NickName_1} ]]; then
NickName[$j]="${tmp_NickName_1}"
elif [[ ${tmp_NickName_2} ]]; then
NickName[$j]="${tmp_NickName_2}"
else
NickName[$j]=""
fi
[[ ! ${NickName[$j]} ]] && UserName=${pt_pin[i]} || UserName=${NickName[$j]}
# 备注名处理
[[ ${remarks_ori[$j]} ]] && tmp_remarks_id_1="$(echo ${remarks_ori[$j]} | perl -pe '{s|(^((?!@@(([\d]{13}\|UID_[\w]{28}))).)*).*|\1|}')"
[[ ${wskey_remarks[$j]} ]] && tmp_remarks_id_2="${wskey_remarks[$j]}"
tmp_remarks_id_3="$(def_json_value "$json_path/CK_WxPusherUid.json" remarks "pin=$j;")"
if [[ $tmp_remarks_id_1 ]]; then
remarks_id[$j]="$tmp_remarks_id_1"
remarks_name[$j]="(${remarks_id[$j]})"
elif [[ $tmp_remarks_id_2 ]]; then
remarks_id[$j]="$tmp_remarks_id_2"
remarks_name[$j]="(${remarks_id[$j]})"
elif [[ $tmp_remarks_id_3 ]]; then
remarks_id[$j]="$tmp_remarks_id_3"
remarks_name[$j]="(${remarks_id[$j]})"
else
remarks_id[$j]=""
remarks_name[$j]="(未备注)"
fi
full_name[$j]="【${sn[i]}】${UserName}${remarks_name[$j]}"
# WxPusherUid 相关值
tmp_Uid_1[$j]="$(echo ${remarks_ori[$j]} | grep -Eo 'UID_\w{28}' | head -1)"
tmp_Uid_2[$j]="$(def_json_value "$json_path/CK_WxPusherUid.json" Uid "pin=$j;" | grep -Eo 'UID_\w{28}' | head -1)"
if [[ ${tmp_Uid_1[$j]} ]]; then
Uid[$j]="${tmp_Uid_1[$j]}"
elif [[ ${tmp_Uid_2[$j]} ]]; then
Uid[$j]="${tmp_Uid_2[$j]}"
else
Uid[$j]=""
fi
}
# 批量检查 Cookie 有效性
verify_ck(){
# JD_COOKIE 有效性检查
check_ck(){
local i=$1
local notify=$2
local j=${pin[i]}
local jd_cookie emoji timestamp_ms tmp_up_timestamp_1 tmp_up_timestamp_2 timestamp_d_value
status_ori[$j]="$(def_json $ck_api_type JD_COOKIE $i status)"
status_json[$j]="$(def_json_value "$json_path/CK_WxPusherUid.json" status "pin=$j;")"
status_last[$j]="${status_json[$j]}"
value_json[$j]="$(def_json_value "$json_path/CK_WxPusherUid.json" JD_COOKIE "pin=$j;")"
[[ ! ${status_last[$j]} ]] && status_last[$j]=${status_ori[$j]}
ck_status[$j]="$ckck_code"
if [[ $ckck_code = 0 ]]; then
ck_valid[i]="${full_name[$j]}\n"
if [[ ${status_last[$j]} = 1 ]]; then
ck_status_chinese="生效"
ck_process_chinese="重启"
else
ck_status_chinese="正常"
ck_process_chinese="启用"
fi
emoji=$emoji_OK
elif [[ $ckck_code = 1 ]]; then
ck_invalid[i]="${full_name[$j]}\n"
ck_status_chinese="失效"
ck_process_chinese="禁用"
emoji=$emoji_NO
else
ck_unknown_state[i]="${full_name[$j]}\n"
ck_status_chinese="因$ckck_msg跳过检测"
emoji=$emoji_MSG
fi
echo -n "${emoji} JD_COOKIE$ck_status_chinese"
if [[ ${ck_status[$j]} = 0 ]]; then
tmp_up_timestamp_1="$(echo $(def_json $ck_api_type JD_COOKIE $i remarks) | grep -Eo '@@\d{13}' | grep -Eo '\d{13}' | head -1)"
tmp_up_timestamp_2="$[$(date -d "$(def_json $ck_api_type JD_COOKIE $i $remote_update_timestamp)" +%s%N)/1000000]"
timestamp_d_value=$[tmp_up_timestamp_1-tmp_up_timestamp_2]
if [[ ${status_json[$j]} = 1 ]] || [[ ${value_json[$j]} && ${value[i]} != ${value_json[$j]} && ${timestamp_d_value#-} -ge 60000 ]]; then
timestamp_ms=$tmp_up_timestamp_2
if [[ ${Uid[$j]} ]]; then
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms@@${Uid[$j]}"
else
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms"
fi
echo -e ""
ql_update_env_api $ck_api_type JD_COOKIE "${value[i]}" $(eval echo \${$remote_id[i]}) "${remarks_new[$j]}" "更新备注时间戳"
fi
fi
}
wskey_analysis(){
local i=$1
local j=${pin[i]}
local notify=$2
local timestamp_ms emoji
wskey_status_ori[$j]="$(def_json_grep_match $wskey_api_type JD_WSCK status "pin=$j;" | head -1)"
wskey_status_json[$j]="$(def_json_value "$json_path/CK_WxPusherUid.json" wskey_status "pin=$j;")"
wskey_status_last[$j]="${wskey_status_json[$j]}"
[[ ! ${wskey_status_last[$j]} ]] && wskey_status_last[$j]=${wskey_status_ori[$j]}
if [[ $wsck_to_ck_code = 0 ]]; then
wskey_status[$j]="0"
if [[ ${wskey_status_last[$j]} = 1 ]]; then
wskey_status_chinese="生效"
wskey_process_chinese="重启"
else
wskey_status_chinese="正常"
wskey_process_chinese="启用"
fi
emoji=$emoji_OK
if [[ ${ck_status[$j]} = 1 ]] || [[ ! ${ck_status[$j]} ]]; then
value[i]=${jd_cookie}
if [[ ${ck_status[$j]} = 1 ]]; then
ck_status[$j]="0"
unset ck_invalid[i]
ck_valid[i]="${full_name[$j]}\n"
if [[ ${status_last[$j]} = 1 ]]; then
ck_status_chinese="生效"
ck_process_chinese="重启"
else
ck_status_chinese="正常"
ck_process_chinese="启用"
fi
[[ $notify = on ]] && echo -e "" && echo -n "${emoji} $wsck_to_ck_msg"
timestamp_ms="$[$(date +%s%N)/1000000]"
if [[ ${Uid[$j]} ]]; then
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms@@${Uid[$j]}"
else
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms"
fi
echo -e ""
ql_update_env_api $ck_api_type JD_COOKIE "${value[i]}" $(eval echo \${$remote_id[i]}) "${remarks_new[$j]}" "更新环境变量值"
elif [[ ! ${ck_status[$j]} ]]; then
ck_status[$j]="0"
Get_Full_Name $i
ck_valid[i]="${full_name[$j]}\n"
ck_added[i]="${full_name[$j]}\n"
ck_status_chinese="生效"
ck_process_chinese="添加"
timestamp_ms="$[$(date +%s%N)/1000000]"
if [[ ${Uid[$j]} ]]; then
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms@@${Uid[$j]}"
else
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms"
fi
echo -e "🧑🌾${full_name[$j]}"
echo -e "${emoji} $wsck_to_ck_msg"
ql_add_env_api $ck_api_type JD_COOKIE "${value[i]}" "${remarks_new[$j]}"
fi
fi
else
if [[ $wsck_to_ck_code = 4 ]]; then
wskey_status[$j]="1"
wskey_status_chinese="失效"
wskey_process_chinese="禁用"
wskey_invalid[i]="${full_name[$j]}\n"
emoji=$emoji_NO
else
wskey_status[$j]="2"
wskey_status_chinese="因$wsck_to_ck_msg跳过检测"
emoji=$emoji_MSG
fi
[[ ! ${ck_status[$j]} ]] && echo -n "🧑🌾${full_name[$j]}"
[[ $notify = on ]] && [[ ${ck_status[$j]} = 1 ]] || [[ ! ${ck_status[$j]} ]] && echo -e "" && echo -n "${emoji} 因$wsck_to_ck_msg,转换JD_COOKIE失败"
fi
[[ $notify = on ]] && echo -e "" && echo -n "${emoji} JD_WSCK(wskey)$wskey_status_chinese"
if [[ ${wskey_status[$j]} = 0 || ${wskey_status[$j]} = 1 ]]; then
if [[ ${wskey_status[$j]} != ${wskey_status_ori[$j]} && ${wskey_status_ori[$j]} ]] || [[ ${wskey_status[$j]} = 1 && ! ${wskey_status_ori[$j]} ]]; then
echo -e ""
ql_process_env_api $wskey_api_type JD_WSCK ${wskey_id[$j]} ${wskey_status[$j]} $wskey_process_chinese
fi
fi
}
# JD_WSCK(wskey) 录入情况检查
check_wskey(){
local i=$1
local j=${pin[i]}
local notify=$2
if [[ ! ${wskey_value[$j]} ]]; then
wskey_status[$j]="3"
if [[ $NOTIFY_WSKEY_NO_EXIST = 1 || $NOTIFY_WSKEY_NO_EXIST = 2 ]]; then
ck_none_wskey[i]="${full_name[$j]}\n"
[[ $notify = on ]] && echo -e "" && echo -n "${emoji_NONE} 未录入JD_WSCK(wskey)"
fi
else
wsck_to_ck ${wskey_value[$j]}
wskey_analysis $i on
fi
if [[ ${ck_status[$j]} != ${status_ori[$j]} ]]; then
if [[ ${ck_status[$j]} = 0 && ! $WSKEY_AUTO_ENABLE ]] || [[ ${ck_status[$j]} = 1 && ! $WSKEY_AUTO_DISABLE ]]; then
echo -e ""
ql_process_env_api $ck_api_type JD_COOKIE "$(eval echo \${$remote_id[i]})" "${ck_status[$j]}" "$ck_process_chinese"
echo -e ""
fi
else
echo -e ""
fi
}
# 账号有效期检查
check_validity(){
local i=$1
local notify=$2
local j=${pin[i]}
local tmp_up_timestamp_1 tmp_up_timestamp_2 total_validity_period timestamp_ms remain_validity_period last_validity_period valid_time
if [[ ${ck_status[$j]} = 0 ]]; then
[[ ${value[i]} == *app_open* ]] && total_validity_period=$[24*3600*1000] || total_validity_period=$[30*24*3600*1000]
tmp_up_timestamp_1="$(echo $(def_json $ck_api_type JD_COOKIE $i remarks) | grep -Eo '@@\d{13}' | grep -Eo '\d{13}' | head -1)"
tmp_up_timestamp_2="$[$(date -d "$(def_json $ck_api_type JD_COOKIE $i $remote_update_timestamp)" +%s%N)/1000000]"
timestamp_ms="$[$(date +%s%N)/1000000]"
remain_validity_period=$[total_validity_period-timestamp_ms+tmp_up_timestamp_1]
if [[ $remain_validity_period -lt 0 ]]; then
timestamp_ms="$[$(date +%s%N)/1000000]"
remain_validity_period=$[total_validity_period-timestamp_ms+tmp_up_timestamp_2]
fi
valid_time=$(UTC $remain_validity_period)
[[ ! ${value[i]} =~ app_open ]] && [[ $remain_validity_period -lt 86400000 ]] && ck_validity_lt_1day[i]="${full_name[$j]}\n"
if [[ $NOTIFY_VALID_TIME = 1 || $NOTIFY_VALID_TIME = 2 ]]; then
ck_validity[i]="${full_name[$j]} $(echo $valid_time | perl -pe '{s|([\d]*[^\d]+).*|\1|}')\n"
[[ $notify = on ]] && echo -e "${emoji_DATE} 账号有效期$valid_time"
fi
validity_day[$j]=$[remain_validity_period/86400000]
validity_less_then_day[$j]=$[(remain_validity_period+86400000)/86400000]
last_validity_day[$j]="$(def_json_value "$json_path/CK_WxPusherUid.json" validity_day "pin=$j;" | head -1)"
if [[ $notify_valid_period ]]; then
last_validity_period=$[last_validity_day[$j]*86400000]
if [[ $remain_validity_period -lt $last_validity_period ]] && [[ $remain_validity_period -le $notify_valid_period ]] && [[ ! ${value[i]} =~ app_open ]]; then
[[ $notify = on ]] && [[ $NOTIFY_VALID_TIME = 1 || $NOTIFY_VALID_TIME = 2 ]] && echo -e "${emoji_SOS} 账号有效期不足${validity_less_then_day[$j]}天"
log_one_to_one_validity_day $i " ${full_name[$j]}"
fi
fi
if [[ $remain_validity_period -lt $wskey_update_validity_period ]] && [[ ${wskey_status[$j]} = 0 ]]; then
[[ $notify = on ]] && echo -e "${emoji_SOS} 账号有效期不足$WSKEY_UPDATE_VALIDITY_HOUR小时,触发强制JD_WSCK转换"
value[i]=${jd_cookie}
ck_validity[i]="${full_name[$j]} 账号有效期1天\n"
validity_day[$j]="0"
timestamp_ms="$[$(date +%s%N)/1000000]"
if [[ ${Uid[$j]} ]]; then
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms@@${Uid[$j]}"
else
remarks_new[$j]="${remarks_id[$j]}@@$timestamp_ms"
fi
ql_update_env_api $ck_api_type JD_COOKIE "${value[i]}" $(eval echo \${$remote_id[i]}) "${remarks_new[$j]}" "更新环境变量值"
echo -e ""
fi
else
validity_day[$j]="0"
unset ck_validity_lt_1day[i]
unset ck_validity[i]