@minato-bot/plugin-wxjsxy 2.0.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/README.md +3 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.mjs +785 -0
- package/package.json +29 -0
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Plugin } from "@atri-bot/core";
|
|
2
|
+
import { CronJob } from "cron";
|
|
3
|
+
import { TextSegment } from "node-napcat-ts";
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
//#region src/api.d.ts
|
|
6
|
+
interface LoginToCasReq {
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
}
|
|
10
|
+
interface getDyProcessReq {
|
|
11
|
+
pageNo: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/index.d.ts
|
|
16
|
+
interface WxjsxyPluginConfig {
|
|
17
|
+
accounts: Record<number, {
|
|
18
|
+
username: string;
|
|
19
|
+
password: string;
|
|
20
|
+
}>;
|
|
21
|
+
crons: Record<number, {
|
|
22
|
+
cron: string;
|
|
23
|
+
offset: number;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
declare const AddAccountCommander: yargs.Argv<{
|
|
27
|
+
username: string;
|
|
28
|
+
} & {
|
|
29
|
+
password: string;
|
|
30
|
+
}>;
|
|
31
|
+
declare const startProcessCommander: yargs.Argv<{
|
|
32
|
+
offset: number;
|
|
33
|
+
}>;
|
|
34
|
+
declare const getProcessListCommander: yargs.Argv<{
|
|
35
|
+
page: number;
|
|
36
|
+
} & {
|
|
37
|
+
size: number;
|
|
38
|
+
}>;
|
|
39
|
+
declare const setCronProcessCommander: yargs.Argv<{
|
|
40
|
+
cron: string;
|
|
41
|
+
} & {
|
|
42
|
+
offset: number;
|
|
43
|
+
}>;
|
|
44
|
+
declare function getDyTokenByCas(req: LoginToCasReq): Promise<string | TextSegment[]>;
|
|
45
|
+
declare function startProcess(req: LoginToCasReq, offset?: number): Promise<TextSegment[]>;
|
|
46
|
+
declare function getProcessList(req: LoginToCasReq, data: getDyProcessReq): Promise<TextSegment[]>;
|
|
47
|
+
declare function checkHaveAccount(config: WxjsxyPluginConfig, userId: number): TextSegment[] | null;
|
|
48
|
+
declare const crons: Record<number, CronJob>;
|
|
49
|
+
declare const plugin: Plugin<object, WxjsxyPluginConfig>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { AddAccountCommander, WxjsxyPluginConfig, checkHaveAccount, crons, getDyTokenByCas, getProcessList, getProcessListCommander, plugin, setCronProcessCommander, startProcess, startProcessCommander };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
import { Plugin } from "@atri-bot/core";
|
|
2
|
+
import { CronJob } from "cron";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import { Structs } from "node-napcat-ts";
|
|
5
|
+
import yargs from "yargs";
|
|
6
|
+
import crypto from "node:crypto";
|
|
7
|
+
import ky from "ky";
|
|
8
|
+
//#region package.json
|
|
9
|
+
var name = "@minato-bot/plugin-wxjsxy";
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/lib.js
|
|
12
|
+
var biRadixBits = 16;
|
|
13
|
+
var bitsPerDigit = biRadixBits;
|
|
14
|
+
var biRadix = 65536;
|
|
15
|
+
var biHalfRadix = biRadix >>> 1;
|
|
16
|
+
var biRadixSquared = biRadix * biRadix;
|
|
17
|
+
var maxDigitVal = biRadix - 1;
|
|
18
|
+
var maxDigits;
|
|
19
|
+
var ZERO_ARRAY;
|
|
20
|
+
var bigZero, bigOne;
|
|
21
|
+
function setMaxDigits(value) {
|
|
22
|
+
maxDigits = value;
|
|
23
|
+
ZERO_ARRAY = new Array(maxDigits);
|
|
24
|
+
for (var iza = 0; iza < ZERO_ARRAY.length; iza++) ZERO_ARRAY[iza] = 0;
|
|
25
|
+
bigZero = new BigInt();
|
|
26
|
+
bigOne = new BigInt();
|
|
27
|
+
bigOne.digits[0] = 1;
|
|
28
|
+
}
|
|
29
|
+
setMaxDigits(20);
|
|
30
|
+
biFromNumber(0x38d7ea4c68000);
|
|
31
|
+
function BigInt(flag) {
|
|
32
|
+
if (typeof flag == "boolean" && flag == true) this.digits = null;
|
|
33
|
+
else this.digits = ZERO_ARRAY.slice(0);
|
|
34
|
+
this.isNeg = false;
|
|
35
|
+
}
|
|
36
|
+
function biCopy(bi) {
|
|
37
|
+
var result = new BigInt(true);
|
|
38
|
+
result.digits = bi.digits.slice(0);
|
|
39
|
+
result.isNeg = bi.isNeg;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function biFromNumber(i) {
|
|
43
|
+
var result = new BigInt();
|
|
44
|
+
result.isNeg = i < 0;
|
|
45
|
+
i = Math.abs(i);
|
|
46
|
+
var j = 0;
|
|
47
|
+
while (i > 0) {
|
|
48
|
+
result.digits[j++] = i & maxDigitVal;
|
|
49
|
+
i >>= biRadixBits;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function reverseStr(s) {
|
|
54
|
+
var result = "";
|
|
55
|
+
for (var i = s.length - 1; i > -1; --i) result += s.charAt(i);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
var hexatrigesimalToChar = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
|
|
59
|
+
function biToString(x, radix) {
|
|
60
|
+
var b = new BigInt();
|
|
61
|
+
b.digits[0] = radix;
|
|
62
|
+
var qr = biDivideModulo(x, b);
|
|
63
|
+
var result = hexatrigesimalToChar[qr[1].digits[0]];
|
|
64
|
+
while (biCompare(qr[0], bigZero) == 1) {
|
|
65
|
+
qr = biDivideModulo(qr[0], b);
|
|
66
|
+
digit = qr[1].digits[0];
|
|
67
|
+
result += hexatrigesimalToChar[qr[1].digits[0]];
|
|
68
|
+
}
|
|
69
|
+
return (x.isNeg ? "-" : "") + reverseStr(result);
|
|
70
|
+
}
|
|
71
|
+
var hexToChar = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
|
|
72
|
+
function digitToHex(n) {
|
|
73
|
+
var mask = 15;
|
|
74
|
+
var result = "";
|
|
75
|
+
for (var i = 0; i < 4; ++i) {
|
|
76
|
+
result += hexToChar[n & mask];
|
|
77
|
+
n >>>= 4;
|
|
78
|
+
}
|
|
79
|
+
return reverseStr(result);
|
|
80
|
+
}
|
|
81
|
+
function biToHex(x) {
|
|
82
|
+
var result = "";
|
|
83
|
+
biHighIndex(x);
|
|
84
|
+
for (var i = biHighIndex(x); i > -1; --i) result += digitToHex(x.digits[i]);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function charToHex(c) {
|
|
88
|
+
var ZERO = 48;
|
|
89
|
+
var NINE = ZERO + 9;
|
|
90
|
+
var littleA = 97;
|
|
91
|
+
var littleZ = littleA + 25;
|
|
92
|
+
var bigA = 65;
|
|
93
|
+
var bigZ = 90;
|
|
94
|
+
var result;
|
|
95
|
+
if (c >= ZERO && c <= NINE) result = c - ZERO;
|
|
96
|
+
else if (c >= bigA && c <= bigZ) result = 10 + c - bigA;
|
|
97
|
+
else if (c >= littleA && c <= littleZ) result = 10 + c - littleA;
|
|
98
|
+
else result = 0;
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
function hexToDigit(s) {
|
|
102
|
+
var result = 0;
|
|
103
|
+
var sl = Math.min(s.length, 4);
|
|
104
|
+
for (var i = 0; i < sl; ++i) {
|
|
105
|
+
result <<= 4;
|
|
106
|
+
result |= charToHex(s.charCodeAt(i));
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
function biFromHex(s) {
|
|
111
|
+
var result = new BigInt();
|
|
112
|
+
for (var i = s.length, j = 0; i > 0; i -= 4, ++j) result.digits[j] = hexToDigit(s.substr(Math.max(i - 4, 0), Math.min(i, 4)));
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
function biToBytes(x) {
|
|
116
|
+
var result = "";
|
|
117
|
+
for (var i = biHighIndex(x); i > -1; --i) result += digitToBytes(x.digits[i]);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
function digitToBytes(n) {
|
|
121
|
+
var c1 = String.fromCharCode(n & 255);
|
|
122
|
+
n >>>= 8;
|
|
123
|
+
return String.fromCharCode(n & 255) + c1;
|
|
124
|
+
}
|
|
125
|
+
function biAdd(x, y) {
|
|
126
|
+
var result;
|
|
127
|
+
if (x.isNeg != y.isNeg) {
|
|
128
|
+
y.isNeg = !y.isNeg;
|
|
129
|
+
result = biSubtract(x, y);
|
|
130
|
+
y.isNeg = !y.isNeg;
|
|
131
|
+
} else {
|
|
132
|
+
result = new BigInt();
|
|
133
|
+
var c = 0;
|
|
134
|
+
var n;
|
|
135
|
+
for (var i = 0; i < x.digits.length; ++i) {
|
|
136
|
+
n = x.digits[i] + y.digits[i] + c;
|
|
137
|
+
result.digits[i] = n & 65535;
|
|
138
|
+
c = Number(n >= biRadix);
|
|
139
|
+
}
|
|
140
|
+
result.isNeg = x.isNeg;
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
function biSubtract(x, y) {
|
|
145
|
+
var result;
|
|
146
|
+
if (x.isNeg != y.isNeg) {
|
|
147
|
+
y.isNeg = !y.isNeg;
|
|
148
|
+
result = biAdd(x, y);
|
|
149
|
+
y.isNeg = !y.isNeg;
|
|
150
|
+
} else {
|
|
151
|
+
result = new BigInt();
|
|
152
|
+
var n, c = 0;
|
|
153
|
+
for (var i = 0; i < x.digits.length; ++i) {
|
|
154
|
+
n = x.digits[i] - y.digits[i] + c;
|
|
155
|
+
result.digits[i] = n & 65535;
|
|
156
|
+
if (result.digits[i] < 0) result.digits[i] += biRadix;
|
|
157
|
+
c = 0 - Number(n < 0);
|
|
158
|
+
}
|
|
159
|
+
if (c == -1) {
|
|
160
|
+
c = 0;
|
|
161
|
+
for (var i = 0; i < x.digits.length; ++i) {
|
|
162
|
+
n = 0 - result.digits[i] + c;
|
|
163
|
+
result.digits[i] = n & 65535;
|
|
164
|
+
if (result.digits[i] < 0) result.digits[i] += biRadix;
|
|
165
|
+
c = 0 - Number(n < 0);
|
|
166
|
+
}
|
|
167
|
+
result.isNeg = !x.isNeg;
|
|
168
|
+
} else result.isNeg = x.isNeg;
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
function biHighIndex(x) {
|
|
173
|
+
var result = x.digits.length - 1;
|
|
174
|
+
while (result > 0 && x.digits[result] == 0) --result;
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
function biNumBits(x) {
|
|
178
|
+
var n = biHighIndex(x);
|
|
179
|
+
var d = x.digits[n];
|
|
180
|
+
var m = (n + 1) * bitsPerDigit;
|
|
181
|
+
var result;
|
|
182
|
+
for (result = m; result > m - bitsPerDigit; --result) {
|
|
183
|
+
if ((d & 32768) != 0) break;
|
|
184
|
+
d <<= 1;
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
function biMultiply(x, y) {
|
|
189
|
+
var result = new BigInt();
|
|
190
|
+
var c;
|
|
191
|
+
var n = biHighIndex(x);
|
|
192
|
+
var t = biHighIndex(y), uv, k;
|
|
193
|
+
for (var i = 0; i <= t; ++i) {
|
|
194
|
+
c = 0;
|
|
195
|
+
k = i;
|
|
196
|
+
for (var j = 0; j <= n; ++j, ++k) {
|
|
197
|
+
uv = result.digits[k] + x.digits[j] * y.digits[i] + c;
|
|
198
|
+
result.digits[k] = uv & maxDigitVal;
|
|
199
|
+
c = uv >>> biRadixBits;
|
|
200
|
+
}
|
|
201
|
+
result.digits[i + n + 1] = c;
|
|
202
|
+
}
|
|
203
|
+
result.isNeg = x.isNeg != y.isNeg;
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
function biMultiplyDigit(x, y) {
|
|
207
|
+
var n, c, uv;
|
|
208
|
+
var result = new BigInt();
|
|
209
|
+
n = biHighIndex(x);
|
|
210
|
+
c = 0;
|
|
211
|
+
for (var j = 0; j <= n; ++j) {
|
|
212
|
+
uv = result.digits[j] + x.digits[j] * y + c;
|
|
213
|
+
result.digits[j] = uv & maxDigitVal;
|
|
214
|
+
c = uv >>> biRadixBits;
|
|
215
|
+
}
|
|
216
|
+
result.digits[1 + n] = c;
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
function arrayCopy(src, srcStart, dest, destStart, n) {
|
|
220
|
+
var m = Math.min(srcStart + n, src.length);
|
|
221
|
+
for (var i = srcStart, j = destStart; i < m; ++i, ++j) dest[j] = src[i];
|
|
222
|
+
}
|
|
223
|
+
var highBitMasks = new Array(0, 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535);
|
|
224
|
+
function biShiftLeft(x, n) {
|
|
225
|
+
var digitCount = Math.floor(n / bitsPerDigit);
|
|
226
|
+
var result = new BigInt();
|
|
227
|
+
arrayCopy(x.digits, 0, result.digits, digitCount, result.digits.length - digitCount);
|
|
228
|
+
var bits = n % bitsPerDigit;
|
|
229
|
+
var rightBits = bitsPerDigit - bits;
|
|
230
|
+
for (var i = result.digits.length - 1, i1 = i - 1; i > 0; --i, --i1) result.digits[i] = result.digits[i] << bits & maxDigitVal | (result.digits[i1] & highBitMasks[bits]) >>> rightBits;
|
|
231
|
+
result.digits[0] = result.digits[i] << bits & maxDigitVal;
|
|
232
|
+
result.isNeg = x.isNeg;
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
var lowBitMasks = new Array(0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535);
|
|
236
|
+
function biShiftRight(x, n) {
|
|
237
|
+
var digitCount = Math.floor(n / bitsPerDigit);
|
|
238
|
+
var result = new BigInt();
|
|
239
|
+
arrayCopy(x.digits, digitCount, result.digits, 0, x.digits.length - digitCount);
|
|
240
|
+
var bits = n % bitsPerDigit;
|
|
241
|
+
var leftBits = bitsPerDigit - bits;
|
|
242
|
+
for (var i = 0, i1 = i + 1; i < result.digits.length - 1; ++i, ++i1) result.digits[i] = result.digits[i] >>> bits | (result.digits[i1] & lowBitMasks[bits]) << leftBits;
|
|
243
|
+
result.digits[result.digits.length - 1] >>>= bits;
|
|
244
|
+
result.isNeg = x.isNeg;
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
function biMultiplyByRadixPower(x, n) {
|
|
248
|
+
var result = new BigInt();
|
|
249
|
+
arrayCopy(x.digits, 0, result.digits, n, result.digits.length - n);
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
function biDivideByRadixPower(x, n) {
|
|
253
|
+
var result = new BigInt();
|
|
254
|
+
arrayCopy(x.digits, n, result.digits, 0, result.digits.length - n);
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
function biModuloByRadixPower(x, n) {
|
|
258
|
+
var result = new BigInt();
|
|
259
|
+
arrayCopy(x.digits, 0, result.digits, 0, n);
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
function biCompare(x, y) {
|
|
263
|
+
if (x.isNeg != y.isNeg) return 1 - 2 * Number(x.isNeg);
|
|
264
|
+
for (var i = x.digits.length - 1; i >= 0; --i) if (x.digits[i] != y.digits[i]) if (x.isNeg) return 1 - 2 * Number(x.digits[i] > y.digits[i]);
|
|
265
|
+
else return 1 - 2 * Number(x.digits[i] < y.digits[i]);
|
|
266
|
+
return 0;
|
|
267
|
+
}
|
|
268
|
+
function biDivideModulo(x, y) {
|
|
269
|
+
var nb = biNumBits(x);
|
|
270
|
+
var tb = biNumBits(y);
|
|
271
|
+
var origYIsNeg = y.isNeg;
|
|
272
|
+
var q, r;
|
|
273
|
+
if (nb < tb) {
|
|
274
|
+
if (x.isNeg) {
|
|
275
|
+
q = biCopy(bigOne);
|
|
276
|
+
q.isNeg = !y.isNeg;
|
|
277
|
+
x.isNeg = false;
|
|
278
|
+
y.isNeg = false;
|
|
279
|
+
r = biSubtract(y, x);
|
|
280
|
+
x.isNeg = true;
|
|
281
|
+
y.isNeg = origYIsNeg;
|
|
282
|
+
} else {
|
|
283
|
+
q = new BigInt();
|
|
284
|
+
r = biCopy(x);
|
|
285
|
+
}
|
|
286
|
+
return new Array(q, r);
|
|
287
|
+
}
|
|
288
|
+
q = new BigInt();
|
|
289
|
+
r = x;
|
|
290
|
+
var t = Math.ceil(tb / bitsPerDigit) - 1;
|
|
291
|
+
var lambda = 0;
|
|
292
|
+
while (y.digits[t] < biHalfRadix) {
|
|
293
|
+
y = biShiftLeft(y, 1);
|
|
294
|
+
++lambda;
|
|
295
|
+
++tb;
|
|
296
|
+
t = Math.ceil(tb / bitsPerDigit) - 1;
|
|
297
|
+
}
|
|
298
|
+
r = biShiftLeft(r, lambda);
|
|
299
|
+
nb += lambda;
|
|
300
|
+
var n = Math.ceil(nb / bitsPerDigit) - 1;
|
|
301
|
+
var b = biMultiplyByRadixPower(y, n - t);
|
|
302
|
+
while (biCompare(r, b) != -1) {
|
|
303
|
+
++q.digits[n - t];
|
|
304
|
+
r = biSubtract(r, b);
|
|
305
|
+
}
|
|
306
|
+
for (var i = n; i > t; --i) {
|
|
307
|
+
var ri = i >= r.digits.length ? 0 : r.digits[i];
|
|
308
|
+
var ri1 = i - 1 >= r.digits.length ? 0 : r.digits[i - 1];
|
|
309
|
+
var ri2 = i - 2 >= r.digits.length ? 0 : r.digits[i - 2];
|
|
310
|
+
var yt = t >= y.digits.length ? 0 : y.digits[t];
|
|
311
|
+
var yt1 = t - 1 >= y.digits.length ? 0 : y.digits[t - 1];
|
|
312
|
+
if (ri == yt) q.digits[i - t - 1] = maxDigitVal;
|
|
313
|
+
else q.digits[i - t - 1] = Math.floor((ri * biRadix + ri1) / yt);
|
|
314
|
+
var c1 = q.digits[i - t - 1] * (yt * biRadix + yt1);
|
|
315
|
+
var c2 = ri * biRadixSquared + (ri1 * biRadix + ri2);
|
|
316
|
+
while (c1 > c2) {
|
|
317
|
+
--q.digits[i - t - 1];
|
|
318
|
+
c1 = q.digits[i - t - 1] * (yt * biRadix | yt1);
|
|
319
|
+
c2 = ri * biRadix * biRadix + (ri1 * biRadix + ri2);
|
|
320
|
+
}
|
|
321
|
+
b = biMultiplyByRadixPower(y, i - t - 1);
|
|
322
|
+
r = biSubtract(r, biMultiplyDigit(b, q.digits[i - t - 1]));
|
|
323
|
+
if (r.isNeg) {
|
|
324
|
+
r = biAdd(r, b);
|
|
325
|
+
--q.digits[i - t - 1];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
r = biShiftRight(r, lambda);
|
|
329
|
+
q.isNeg = x.isNeg != origYIsNeg;
|
|
330
|
+
if (x.isNeg) {
|
|
331
|
+
if (origYIsNeg) q = biAdd(q, bigOne);
|
|
332
|
+
else q = biSubtract(q, bigOne);
|
|
333
|
+
y = biShiftRight(y, lambda);
|
|
334
|
+
r = biSubtract(y, r);
|
|
335
|
+
}
|
|
336
|
+
if (r.digits[0] == 0 && biHighIndex(r) == 0) r.isNeg = false;
|
|
337
|
+
return new Array(q, r);
|
|
338
|
+
}
|
|
339
|
+
function biDivide(x, y) {
|
|
340
|
+
return biDivideModulo(x, y)[0];
|
|
341
|
+
}
|
|
342
|
+
function BarrettMu(m) {
|
|
343
|
+
this.modulus = biCopy(m);
|
|
344
|
+
this.k = biHighIndex(this.modulus) + 1;
|
|
345
|
+
var b2k = new BigInt();
|
|
346
|
+
b2k.digits[2 * this.k] = 1;
|
|
347
|
+
this.mu = biDivide(b2k, this.modulus);
|
|
348
|
+
this.bkplus1 = new BigInt();
|
|
349
|
+
this.bkplus1.digits[this.k + 1] = 1;
|
|
350
|
+
this.modulo = BarrettMu_modulo;
|
|
351
|
+
this.multiplyMod = BarrettMu_multiplyMod;
|
|
352
|
+
this.powMod = BarrettMu_powMod;
|
|
353
|
+
}
|
|
354
|
+
function BarrettMu_modulo(x) {
|
|
355
|
+
var q3 = biDivideByRadixPower(biMultiply(biDivideByRadixPower(x, this.k - 1), this.mu), this.k + 1);
|
|
356
|
+
var r = biSubtract(biModuloByRadixPower(x, this.k + 1), biModuloByRadixPower(biMultiply(q3, this.modulus), this.k + 1));
|
|
357
|
+
if (r.isNeg) r = biAdd(r, this.bkplus1);
|
|
358
|
+
var rgtem = biCompare(r, this.modulus) >= 0;
|
|
359
|
+
while (rgtem) {
|
|
360
|
+
r = biSubtract(r, this.modulus);
|
|
361
|
+
rgtem = biCompare(r, this.modulus) >= 0;
|
|
362
|
+
}
|
|
363
|
+
return r;
|
|
364
|
+
}
|
|
365
|
+
function BarrettMu_multiplyMod(x, y) {
|
|
366
|
+
var xy = biMultiply(x, y);
|
|
367
|
+
return this.modulo(xy);
|
|
368
|
+
}
|
|
369
|
+
function BarrettMu_powMod(x, y) {
|
|
370
|
+
var result = new BigInt();
|
|
371
|
+
result.digits[0] = 1;
|
|
372
|
+
var a = x;
|
|
373
|
+
var k = y;
|
|
374
|
+
while (true) {
|
|
375
|
+
if ((k.digits[0] & 1) != 0) result = this.multiplyMod(result, a);
|
|
376
|
+
k = biShiftRight(k, 1);
|
|
377
|
+
if (k.digits[0] == 0 && biHighIndex(k) == 0) break;
|
|
378
|
+
a = this.multiplyMod(a, a);
|
|
379
|
+
}
|
|
380
|
+
return result;
|
|
381
|
+
}
|
|
382
|
+
var RSAAPP = {};
|
|
383
|
+
RSAAPP.NoPadding = "NoPadding";
|
|
384
|
+
RSAAPP.PKCS1Padding = "PKCS1Padding";
|
|
385
|
+
RSAAPP.RawEncoding = "RawEncoding";
|
|
386
|
+
RSAAPP.NumericEncoding = "NumericEncoding";
|
|
387
|
+
function RSAKeyPair(encryptionExponent, decryptionExponent, modulus, keylen) {
|
|
388
|
+
this.e = biFromHex(encryptionExponent);
|
|
389
|
+
this.d = biFromHex(decryptionExponent);
|
|
390
|
+
this.m = biFromHex(modulus);
|
|
391
|
+
if (typeof keylen != "number") this.chunkSize = 2 * biHighIndex(this.m);
|
|
392
|
+
else this.chunkSize = keylen / 8;
|
|
393
|
+
this.radix = 16;
|
|
394
|
+
this.barrett = new BarrettMu(this.m);
|
|
395
|
+
}
|
|
396
|
+
function encryptedString(key, s, pad, encoding) {
|
|
397
|
+
var a = new Array();
|
|
398
|
+
var sl = s.length;
|
|
399
|
+
var i, j, k;
|
|
400
|
+
var padtype;
|
|
401
|
+
var encodingtype;
|
|
402
|
+
var rpad;
|
|
403
|
+
var al;
|
|
404
|
+
var result = "";
|
|
405
|
+
var block;
|
|
406
|
+
var crypt;
|
|
407
|
+
var text;
|
|
408
|
+
if (typeof pad == "string") if (pad == RSAAPP.NoPadding) padtype = 1;
|
|
409
|
+
else if (pad == RSAAPP.PKCS1Padding) padtype = 2;
|
|
410
|
+
else padtype = 0;
|
|
411
|
+
else padtype = 0;
|
|
412
|
+
if (typeof encoding == "string" && encoding == RSAAPP.RawEncoding) encodingtype = 1;
|
|
413
|
+
else encodingtype = 0;
|
|
414
|
+
if (padtype == 1) {
|
|
415
|
+
if (sl > key.chunkSize) sl = key.chunkSize;
|
|
416
|
+
} else if (padtype == 2) {
|
|
417
|
+
if (sl > key.chunkSize - 11) sl = key.chunkSize - 11;
|
|
418
|
+
}
|
|
419
|
+
i = 0;
|
|
420
|
+
if (padtype == 2) j = sl - 1;
|
|
421
|
+
else j = key.chunkSize - 1;
|
|
422
|
+
while (i < sl) {
|
|
423
|
+
if (padtype) a[j] = s.charCodeAt(i);
|
|
424
|
+
else a[i] = s.charCodeAt(i);
|
|
425
|
+
i++;
|
|
426
|
+
j--;
|
|
427
|
+
}
|
|
428
|
+
if (padtype == 1) i = 0;
|
|
429
|
+
j = key.chunkSize - sl % key.chunkSize;
|
|
430
|
+
while (j > 0) {
|
|
431
|
+
if (padtype == 2) {
|
|
432
|
+
rpad = Math.floor(Math.random() * 256);
|
|
433
|
+
while (!rpad) rpad = Math.floor(Math.random() * 256);
|
|
434
|
+
a[i] = rpad;
|
|
435
|
+
} else a[i] = 0;
|
|
436
|
+
i++;
|
|
437
|
+
j--;
|
|
438
|
+
}
|
|
439
|
+
if (padtype == 2) {
|
|
440
|
+
a[sl] = 0;
|
|
441
|
+
a[key.chunkSize - 2] = 2;
|
|
442
|
+
a[key.chunkSize - 1] = 0;
|
|
443
|
+
}
|
|
444
|
+
al = a.length;
|
|
445
|
+
for (i = 0; i < al; i += key.chunkSize) {
|
|
446
|
+
block = new BigInt();
|
|
447
|
+
j = 0;
|
|
448
|
+
for (k = i; k < i + key.chunkSize; ++j) {
|
|
449
|
+
block.digits[j] = a[k++];
|
|
450
|
+
block.digits[j] += a[k++] << 8;
|
|
451
|
+
}
|
|
452
|
+
crypt = key.barrett.powMod(block, key.e);
|
|
453
|
+
if (encodingtype == 1) text = biToBytes(crypt);
|
|
454
|
+
else text = key.radix == 16 ? biToHex(crypt) : biToString(crypt, key.radix);
|
|
455
|
+
result += text;
|
|
456
|
+
}
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/api.ts
|
|
461
|
+
setMaxDigits(131);
|
|
462
|
+
const key = new RSAKeyPair("010001", "", "00b5eeb166e069920e80bebd1fea4829d3d1f3216f2aabe79b6c47a3c18dcee5fd22c2e7ac519cab59198ece036dcf289ea8201e2a0b9ded307f8fb704136eaeb670286f5ad44e691005ba9ea5af04ada5367cd724b5a26fdb5120cc95b6431604bd219c6b7d83a6f8f24b43918ea988a76f93c333aa5a20991493d4eb1117e7b1");
|
|
463
|
+
const api = ky.create({
|
|
464
|
+
throwHttpErrors: false,
|
|
465
|
+
headers: {
|
|
466
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
|
|
467
|
+
"Accept": "application/json, text/plain, */*",
|
|
468
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
469
|
+
"sec-ch-ua-platform": "\"Windows\""
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
async function loginToCas(req) {
|
|
473
|
+
const { username, password } = req;
|
|
474
|
+
return await api.post("https://cas.wxjsxy.com.cn/lyuapServer/v1/tickets", { body: new URLSearchParams({
|
|
475
|
+
username,
|
|
476
|
+
password: encryptedString(key, password),
|
|
477
|
+
service: "https://portal.wxjsxy.com.cn/",
|
|
478
|
+
loginType: "",
|
|
479
|
+
id: "",
|
|
480
|
+
code: "",
|
|
481
|
+
otpcode: ""
|
|
482
|
+
}) }).json();
|
|
483
|
+
}
|
|
484
|
+
async function getCasLoginToken(TGT) {
|
|
485
|
+
const res = await api.post(`https://cas.wxjsxy.com.cn/lyuapServer/v1/tickets/${TGT}`, { body: new URLSearchParams({
|
|
486
|
+
service: "https://dy.wxjsxy.com.cn/prdapi/wxjsxyapp/cas/index",
|
|
487
|
+
loginToken: "loginToken"
|
|
488
|
+
}) }).text();
|
|
489
|
+
return [res.startsWith("ST-"), res];
|
|
490
|
+
}
|
|
491
|
+
async function getDyCookie(CasToken) {
|
|
492
|
+
const setCookie = (await api.get(`https://dy.wxjsxy.com.cn/prdapi/wxjsxyapp/cas/index?ticket=${CasToken}`, { redirect: "manual" })).headers.getSetCookie();
|
|
493
|
+
if (setCookie.length === 0) return null;
|
|
494
|
+
return setCookie.map((cookie) => `${cookie.split(";")[0]};`).join("");
|
|
495
|
+
}
|
|
496
|
+
async function getDyToken(cookie) {
|
|
497
|
+
return await api.get("https://dy.wxjsxy.com.cn/prdapi/wxjsxyapp/cas/indexData", { headers: { cookie } }).json();
|
|
498
|
+
}
|
|
499
|
+
async function setDyProcess(token, req) {
|
|
500
|
+
const data = {
|
|
501
|
+
...req,
|
|
502
|
+
processDefinitionKey: "studentApply"
|
|
503
|
+
};
|
|
504
|
+
const sign = crypto.createHash("md5").update(`myappsecret${JSON.stringify(data)}myappsecret`).digest("hex");
|
|
505
|
+
return await ky.post(`https://dy.wxjsxy.com.cn/prdapi/activiti/processInstance/startProcess?user_info_query_json=${encodeURIComponent(JSON.stringify(data))}&sign=${sign}`, {
|
|
506
|
+
json: data,
|
|
507
|
+
headers: {
|
|
508
|
+
token,
|
|
509
|
+
"mode": "wxa",
|
|
510
|
+
sign,
|
|
511
|
+
"timestamp": Date.now(),
|
|
512
|
+
"Content-Type": "application/json"
|
|
513
|
+
}
|
|
514
|
+
}).json();
|
|
515
|
+
}
|
|
516
|
+
async function getDyProcessList(token, data = {
|
|
517
|
+
pageNo: 1,
|
|
518
|
+
pageSize: 1
|
|
519
|
+
}) {
|
|
520
|
+
const sign = crypto.createHash("md5").update(`myappsecret${JSON.stringify(data)}myappsecret`).digest("hex");
|
|
521
|
+
return await ky.post(`https://dy.wxjsxy.com.cn/prdapi/activiti/task/myapply?user_info_query_json=${encodeURIComponent(JSON.stringify(data))}&sign=${sign}`, {
|
|
522
|
+
json: data,
|
|
523
|
+
headers: {
|
|
524
|
+
token,
|
|
525
|
+
"mode": "wxa",
|
|
526
|
+
sign,
|
|
527
|
+
"timestamp": Date.now(),
|
|
528
|
+
"Content-Type": "application/json"
|
|
529
|
+
}
|
|
530
|
+
}).json();
|
|
531
|
+
}
|
|
532
|
+
async function getDyProcessDetail(token, instanceId) {
|
|
533
|
+
const data = { instanceId };
|
|
534
|
+
const sign = crypto.createHash("md5").update(`myappsecret${JSON.stringify(data)}myappsecret`).digest("hex");
|
|
535
|
+
return await ky.post(`https://dy.wxjsxy.com.cn/prdapi/activiti/task/done/info/byInstanceId?user_info_query_json=${encodeURIComponent(JSON.stringify(data))}&sign=${sign}`, {
|
|
536
|
+
json: data,
|
|
537
|
+
headers: {
|
|
538
|
+
token,
|
|
539
|
+
"mode": "wxa",
|
|
540
|
+
sign,
|
|
541
|
+
"timestamp": Date.now(),
|
|
542
|
+
"Content-Type": "application/json"
|
|
543
|
+
}
|
|
544
|
+
}).json();
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/index.ts
|
|
548
|
+
const AddAccountCommander = yargs().option("username", {
|
|
549
|
+
alias: "u",
|
|
550
|
+
type: "string",
|
|
551
|
+
description: "账号",
|
|
552
|
+
demandOption: true
|
|
553
|
+
}).option("password", {
|
|
554
|
+
alias: "p",
|
|
555
|
+
type: "string",
|
|
556
|
+
description: "密码",
|
|
557
|
+
demandOption: true
|
|
558
|
+
});
|
|
559
|
+
const startProcessCommander = yargs().option("offset", {
|
|
560
|
+
alias: "o",
|
|
561
|
+
type: "number",
|
|
562
|
+
description: "请假日期相对于今天的偏移,默认为0即请假当天",
|
|
563
|
+
default: 0
|
|
564
|
+
});
|
|
565
|
+
const getProcessListCommander = yargs().option("page", {
|
|
566
|
+
alias: "p",
|
|
567
|
+
type: "number",
|
|
568
|
+
description: "页码",
|
|
569
|
+
default: 1
|
|
570
|
+
}).option("size", {
|
|
571
|
+
alias: "s",
|
|
572
|
+
type: "number",
|
|
573
|
+
description: "每页数量",
|
|
574
|
+
default: 1
|
|
575
|
+
});
|
|
576
|
+
const setCronProcessCommander = yargs().option("cron", {
|
|
577
|
+
alias: "c",
|
|
578
|
+
type: "string",
|
|
579
|
+
description: "cron表达式",
|
|
580
|
+
demandOption: true
|
|
581
|
+
}).option("offset", {
|
|
582
|
+
alias: "o",
|
|
583
|
+
type: "number",
|
|
584
|
+
description: "请假日期相对于今天的偏移,默认为0即请假当天",
|
|
585
|
+
default: 0
|
|
586
|
+
});
|
|
587
|
+
async function getDyTokenByCas(req) {
|
|
588
|
+
const loginRes = await loginToCas(req);
|
|
589
|
+
if (!("ticket" in loginRes)) return [Structs.text(`请假失败, 登陆账号失败: ${JSON.stringify(loginRes)}`)];
|
|
590
|
+
const [loginTokenSuccess, loginTokenRes] = await getCasLoginToken(loginRes.tgt);
|
|
591
|
+
if (!loginTokenSuccess) return [Structs.text(`请假失败, 获取CasToken失败: ${loginTokenRes}`)];
|
|
592
|
+
const casCookie = await getDyCookie(loginTokenRes);
|
|
593
|
+
if (!casCookie) return [Structs.text(`请假失败, 获取DyCookie失败`)];
|
|
594
|
+
const dyTokenRes = await getDyToken(casCookie);
|
|
595
|
+
if (!dyTokenRes.token) return [Structs.text(`请假失败, 获取DyToken失败: ${JSON.stringify(dyTokenRes)}`)];
|
|
596
|
+
return dyTokenRes.token;
|
|
597
|
+
}
|
|
598
|
+
async function startProcess(req, offset = 0) {
|
|
599
|
+
const dyTokenRes = await getDyTokenByCas(req);
|
|
600
|
+
if (Array.isArray(dyTokenRes)) return dyTokenRes;
|
|
601
|
+
const dyAction = await setDyProcess(dyTokenRes, {
|
|
602
|
+
beginTime: dayjs().add(offset, "day").hour(6).minute(30).format("YYYY-MM-DD HH:mm"),
|
|
603
|
+
endTime: dayjs().add(offset, "day").hour(20).minute(50).format("YYYY-MM-DD HH:mm"),
|
|
604
|
+
leaveSchool: "是",
|
|
605
|
+
backDormitory: "是",
|
|
606
|
+
askedType: "事假",
|
|
607
|
+
reason: "集训"
|
|
608
|
+
});
|
|
609
|
+
if (dyAction.code !== 200) return [Structs.text(`请假失败, 提交请假申请失败: ${JSON.stringify(dyAction)}`)];
|
|
610
|
+
return [Structs.text(`请假成功, 返回信息: \n ${JSON.stringify(dyAction)}`)];
|
|
611
|
+
}
|
|
612
|
+
async function getProcessList(req, data) {
|
|
613
|
+
const dyTokenRes = await getDyTokenByCas(req);
|
|
614
|
+
if (Array.isArray(dyTokenRes)) return dyTokenRes;
|
|
615
|
+
const processList = await getDyProcessList(dyTokenRes, data);
|
|
616
|
+
if (processList.code !== 200) return [Structs.text(`获取请假情况失败, 错误信息: ${JSON.stringify(processList)}`)];
|
|
617
|
+
const processDetailList = await Promise.all(processList.rows.map((item) => getDyProcessDetail(dyTokenRes, item.instanceId)));
|
|
618
|
+
if (processDetailList.some((item) => item.code !== 200)) return [Structs.text(`获取请假详情失败, 错误信息: ${JSON.stringify(processDetailList)}`)];
|
|
619
|
+
return [Structs.text(`请假情况:\n`), Structs.text(processList.rows.map((item, index) => {
|
|
620
|
+
const strArr = [`- 申请时间: ${item.processStartTime}`, ` 审核状态: ${item.approvaState}`];
|
|
621
|
+
const detail = processDetailList[index];
|
|
622
|
+
if (detail.code !== 200) {
|
|
623
|
+
strArr.push(` 获取详情失败: ${JSON.stringify(detail)}`);
|
|
624
|
+
return strArr.join("\n");
|
|
625
|
+
}
|
|
626
|
+
strArr.push(` 申请时间: ${detail.rows.hisTasks[1].processStartTime}`, ...detail.rows.hisTasks[1].formSchema.formProperties.map((prop) => ` ${prop.name}: ${prop.value}`));
|
|
627
|
+
return strArr.join("\n");
|
|
628
|
+
}).join(""))];
|
|
629
|
+
}
|
|
630
|
+
function checkHaveAccount(config, userId) {
|
|
631
|
+
if (!config.accounts[userId]) return [Structs.text("请先添加账号,使用命令:wxjsxy添加账号 -u <用户名> -p <密码>")];
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
const crons = {};
|
|
635
|
+
const plugin = new Plugin(name).setDefaultConfig({
|
|
636
|
+
accounts: {},
|
|
637
|
+
crons: {}
|
|
638
|
+
}).onInstall(async ({ event, config, bot, saveConfig }) => {
|
|
639
|
+
async function refreshCrons() {
|
|
640
|
+
for (const [userId, cronInfo] of Object.entries(config.crons)) {
|
|
641
|
+
const user_id = Number.parseFloat(userId);
|
|
642
|
+
if (crons[user_id]) crons[user_id].stop();
|
|
643
|
+
crons[user_id] = new CronJob(cronInfo.cron, async () => {
|
|
644
|
+
if (!checkHaveAccount(config, user_id)) {
|
|
645
|
+
delete config.crons[user_id];
|
|
646
|
+
await saveConfig();
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
const msg = await startProcess(config.accounts[user_id], cronInfo.offset);
|
|
650
|
+
await bot.sendMsg({
|
|
651
|
+
message_type: "private",
|
|
652
|
+
user_id
|
|
653
|
+
}, msg);
|
|
654
|
+
}, null, true);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
await refreshCrons();
|
|
658
|
+
event.regCommandEvent({
|
|
659
|
+
trigger: "wxjsxy添加账号",
|
|
660
|
+
commander: AddAccountCommander,
|
|
661
|
+
callback: async ({ context, options }) => {
|
|
662
|
+
if (config.accounts[context.user_id]) {
|
|
663
|
+
await bot.sendMsg(context, [Structs.text("账号已存在,无需重复添加")]);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
const casInfo = await loginToCas({
|
|
667
|
+
username: options.username,
|
|
668
|
+
password: options.password
|
|
669
|
+
});
|
|
670
|
+
if (!("ticket" in casInfo)) {
|
|
671
|
+
await bot.sendMsg(context, [Structs.text(`登录失败,请检查账号密码是否正确: \n ${JSON.stringify(casInfo)}`)]);
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
await bot.sendMsg(context, [Structs.text(`登录成功, 返回信息: \n ${JSON.stringify(casInfo)}`)]);
|
|
675
|
+
config.accounts[context.user_id] = {
|
|
676
|
+
username: options.username,
|
|
677
|
+
password: options.password
|
|
678
|
+
};
|
|
679
|
+
await saveConfig();
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
event.regCommandEvent({
|
|
683
|
+
trigger: "wxjsxy删除账号",
|
|
684
|
+
callback: async ({ context }) => {
|
|
685
|
+
const accountCheck = checkHaveAccount(config, context.user_id);
|
|
686
|
+
if (accountCheck) {
|
|
687
|
+
await bot.sendMsg(context, accountCheck);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
delete config.accounts[context.user_id];
|
|
691
|
+
delete config.crons[context.user_id];
|
|
692
|
+
if (crons[context.user_id]) {
|
|
693
|
+
crons[context.user_id].stop();
|
|
694
|
+
delete crons[context.user_id];
|
|
695
|
+
}
|
|
696
|
+
await saveConfig();
|
|
697
|
+
await bot.sendMsg(context, [Structs.text("账号删除成功")]);
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
event.regCommandEvent({
|
|
701
|
+
trigger: "wxjsxy请假",
|
|
702
|
+
commander: startProcessCommander,
|
|
703
|
+
callback: async ({ context, options }) => {
|
|
704
|
+
const accountCheck = checkHaveAccount(config, context.user_id);
|
|
705
|
+
if (accountCheck) {
|
|
706
|
+
await bot.sendMsg(context, accountCheck);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const msg = await startProcess(config.accounts[context.user_id], options.offset);
|
|
710
|
+
await bot.sendMsg(context, msg);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
event.regCommandEvent({
|
|
714
|
+
trigger: "wxjsxy请假情况",
|
|
715
|
+
commander: getProcessListCommander,
|
|
716
|
+
callback: async ({ context, options }) => {
|
|
717
|
+
const accountCheck = checkHaveAccount(config, context.user_id);
|
|
718
|
+
if (accountCheck) {
|
|
719
|
+
await bot.sendMsg(context, accountCheck);
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
const msg = await getProcessList(config.accounts[context.user_id], {
|
|
723
|
+
pageNo: options.page,
|
|
724
|
+
pageSize: options.size
|
|
725
|
+
});
|
|
726
|
+
await bot.sendMsg(context, msg);
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
event.regCommandEvent({
|
|
730
|
+
trigger: "wxjsxy定时请假",
|
|
731
|
+
commander: setCronProcessCommander,
|
|
732
|
+
callback: async ({ context, options }) => {
|
|
733
|
+
const accountCheck = checkHaveAccount(config, context.user_id);
|
|
734
|
+
if (accountCheck) {
|
|
735
|
+
await bot.sendMsg(context, accountCheck);
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (config.crons[context.user_id]) {
|
|
739
|
+
await bot.sendMsg(context, [Structs.text("已存在定时请假任务,正在覆盖原有任务")]);
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
if (options.cron.split(" ").length !== 5) {
|
|
743
|
+
await bot.sendMsg(context, [Structs.text("cron表达式格式错误,请提供5段表达式, 示例: 0 30 6 * * 表示每天6点30分")]);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
if (!await bot.isFriend({ user_id: context.user_id })) {
|
|
747
|
+
await bot.sendMsg(context, [Structs.text("请先添加好友,才能设置定时请假哦")]);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
config.crons[context.user_id] = {
|
|
751
|
+
cron: options.cron,
|
|
752
|
+
offset: options.offset
|
|
753
|
+
};
|
|
754
|
+
await saveConfig();
|
|
755
|
+
await refreshCrons();
|
|
756
|
+
await bot.sendMsg(context, [Structs.text("定时请假设置成功")]);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
event.regCommandEvent({
|
|
760
|
+
trigger: "wxjsxy取消定时请假",
|
|
761
|
+
callback: async ({ context }) => {
|
|
762
|
+
const accountCheck = checkHaveAccount(config, context.user_id);
|
|
763
|
+
if (accountCheck) {
|
|
764
|
+
await bot.sendMsg(context, accountCheck);
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (!config.crons[context.user_id]) {
|
|
768
|
+
await bot.sendMsg(context, [Structs.text("没有定时请假任务可供取消")]);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
delete config.crons[context.user_id];
|
|
772
|
+
await saveConfig();
|
|
773
|
+
await refreshCrons();
|
|
774
|
+
await bot.sendMsg(context, [Structs.text("定时请假取消成功")]);
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
}).onUninstall(() => {
|
|
778
|
+
const cronsEntries = Object.entries(crons);
|
|
779
|
+
while (cronsEntries.length > 0) {
|
|
780
|
+
const cronJob = cronsEntries.pop();
|
|
781
|
+
if (cronJob && cronJob[1]) cronJob[1].stop();
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
//#endregion
|
|
785
|
+
export { AddAccountCommander, checkHaveAccount, crons, getDyTokenByCas, getProcessList, getProcessListCommander, plugin, setCronProcessCommander, startProcess, startProcessCommander };
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@minato-bot/plugin-wxjsxy",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"description": "wxjsxy for atri framework",
|
|
6
|
+
"author": "huan_kong",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"./dist/**/*"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsdown",
|
|
15
|
+
"lint": "eslint",
|
|
16
|
+
"typecheck": "tsc --noEmit -p tsconfig.json --composite false"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@atri-bot/core": "^2.2.6",
|
|
20
|
+
"cron": "^4.4.0",
|
|
21
|
+
"dayjs": "^1.11.20",
|
|
22
|
+
"ky": "^1.14.3",
|
|
23
|
+
"node-napcat-ts": "^0.4.24",
|
|
24
|
+
"yargs": "^18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/yargs": "^17.0.35"
|
|
28
|
+
}
|
|
29
|
+
}
|