alemonjs 2.1.56 → 2.1.58
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/lib/app/api/schedule.d.ts +17 -0
- package/lib/app/api/schedule.js +12 -0
- package/lib/app/hook-use/client.js +0 -1
- package/lib/app/hook-use/me.d.ts +1 -0
- package/lib/app/hook-use/me.js +9 -1
- package/lib/app/hook-use/request.js +0 -1
- package/lib/app/hook-use/user.js +0 -1
- package/lib/app/index.d.ts +2 -0
- package/lib/app/index.js +3 -2
- package/lib/app/load_modules/loadChild.js +4 -0
- package/lib/app/message-format-old.d.ts +2 -0
- package/lib/app/message-format-old.js +35 -136
- package/lib/app/message-format.d.ts +59 -32
- package/lib/app/message-format.js +288 -66
- package/lib/app/schedule-store.d.ts +20 -0
- package/lib/app/schedule-store.js +230 -0
- package/lib/cbp/connects/client.js +1 -1
- package/lib/client.js +1 -1
- package/lib/index.js +3 -2
- package/lib/server/routers/router.js +1 -3
- package/lib/types/index.d.ts +1 -0
- package/lib/types/message/embed.d.ts +29 -0
- package/lib/types/message/embed.js +1 -0
- package/lib/types/message/index.d.ts +7 -1
- package/lib/types/message/modal.d.ts +21 -0
- package/lib/types/message/modal.js +1 -0
- package/lib/types/message/select.d.ts +19 -0
- package/lib/types/message/select.js +1 -0
- package/lib/types/schedule/index.d.ts +23 -0
- package/lib/types/schedule/index.js +1 -0
- package/package.json +2 -1
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { Text, Image, Mention, BT, MD, MarkdownOriginal, Attachment, Audio, Video, Link, ImageFile, ImageURL } from './message-format-old.js';
|
|
2
|
-
export { Button, Markdown } from './message-format-old.js';
|
|
3
|
-
|
|
4
1
|
class FormatButtonGroup {
|
|
5
2
|
#rows = [];
|
|
6
3
|
#currentRow = null;
|
|
7
4
|
get value() {
|
|
8
5
|
this.#flush();
|
|
9
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
type: 'BT.group',
|
|
8
|
+
value: this.#rows
|
|
9
|
+
};
|
|
10
10
|
}
|
|
11
11
|
#flush() {
|
|
12
12
|
if (this.#currentRow && this.#currentRow.length > 0) {
|
|
13
|
-
this.#rows.push(
|
|
13
|
+
this.#rows.push({
|
|
14
|
+
type: 'BT.row',
|
|
15
|
+
value: this.#currentRow
|
|
16
|
+
});
|
|
14
17
|
this.#currentRow = null;
|
|
15
18
|
}
|
|
16
19
|
}
|
|
@@ -26,11 +29,18 @@ class FormatButtonGroup {
|
|
|
26
29
|
this.#currentRow = [];
|
|
27
30
|
return this;
|
|
28
31
|
}
|
|
29
|
-
addButton(
|
|
32
|
+
addButton(title, data, options) {
|
|
30
33
|
if (!this.#currentRow) {
|
|
31
34
|
this.#currentRow = [];
|
|
32
35
|
}
|
|
33
|
-
this.#currentRow.push(
|
|
36
|
+
this.#currentRow.push({
|
|
37
|
+
type: 'Button',
|
|
38
|
+
value: title,
|
|
39
|
+
options: {
|
|
40
|
+
data,
|
|
41
|
+
...options
|
|
42
|
+
}
|
|
43
|
+
});
|
|
34
44
|
return this;
|
|
35
45
|
}
|
|
36
46
|
clear() {
|
|
@@ -42,82 +52,138 @@ class FormatButtonGroup {
|
|
|
42
52
|
class FormatMarkDown {
|
|
43
53
|
#data = [];
|
|
44
54
|
get value() {
|
|
45
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
type: 'Markdown',
|
|
57
|
+
value: this.#data
|
|
58
|
+
};
|
|
46
59
|
}
|
|
47
60
|
absorb(md) {
|
|
48
61
|
this.#data.push(...md.value.value);
|
|
49
62
|
return this;
|
|
50
63
|
}
|
|
51
|
-
addContent(
|
|
52
|
-
this.#data.push(
|
|
64
|
+
addContent(text) {
|
|
65
|
+
this.#data.push({
|
|
66
|
+
type: 'MD.content',
|
|
67
|
+
value: text
|
|
68
|
+
});
|
|
53
69
|
return this;
|
|
54
70
|
}
|
|
55
|
-
addText(
|
|
56
|
-
this.#data.push(
|
|
71
|
+
addText(text) {
|
|
72
|
+
this.#data.push({
|
|
73
|
+
type: 'MD.text',
|
|
74
|
+
value: text
|
|
75
|
+
});
|
|
57
76
|
return this;
|
|
58
77
|
}
|
|
59
|
-
addTitle(
|
|
60
|
-
this.#data.push(
|
|
78
|
+
addTitle(text) {
|
|
79
|
+
this.#data.push({
|
|
80
|
+
type: 'MD.title',
|
|
81
|
+
value: text
|
|
82
|
+
});
|
|
61
83
|
return this;
|
|
62
84
|
}
|
|
63
|
-
addSubtitle(
|
|
64
|
-
this.#data.push(
|
|
85
|
+
addSubtitle(text) {
|
|
86
|
+
this.#data.push({
|
|
87
|
+
type: 'MD.subtitle',
|
|
88
|
+
value: text
|
|
89
|
+
});
|
|
65
90
|
return this;
|
|
66
91
|
}
|
|
67
|
-
addBold(
|
|
68
|
-
this.#data.push(
|
|
92
|
+
addBold(text) {
|
|
93
|
+
this.#data.push({
|
|
94
|
+
type: 'MD.bold',
|
|
95
|
+
value: text
|
|
96
|
+
});
|
|
69
97
|
return this;
|
|
70
98
|
}
|
|
71
|
-
addItalic(
|
|
72
|
-
this.#data.push(
|
|
99
|
+
addItalic(text) {
|
|
100
|
+
this.#data.push({
|
|
101
|
+
type: 'MD.italic',
|
|
102
|
+
value: text
|
|
103
|
+
});
|
|
73
104
|
return this;
|
|
74
105
|
}
|
|
75
|
-
addItalicStar(
|
|
76
|
-
this.#data.push(
|
|
106
|
+
addItalicStar(text) {
|
|
107
|
+
this.#data.push({
|
|
108
|
+
type: 'MD.italicStar',
|
|
109
|
+
value: text
|
|
110
|
+
});
|
|
77
111
|
return this;
|
|
78
112
|
}
|
|
79
|
-
addStrikethrough(
|
|
80
|
-
this.#data.push(
|
|
113
|
+
addStrikethrough(text) {
|
|
114
|
+
this.#data.push({
|
|
115
|
+
type: 'MD.strikethrough',
|
|
116
|
+
value: text
|
|
117
|
+
});
|
|
81
118
|
return this;
|
|
82
119
|
}
|
|
83
|
-
addLink(
|
|
84
|
-
this.#data.push(
|
|
120
|
+
addLink(text, url) {
|
|
121
|
+
this.#data.push({
|
|
122
|
+
type: 'MD.link',
|
|
123
|
+
value: { text, url }
|
|
124
|
+
});
|
|
85
125
|
return this;
|
|
86
126
|
}
|
|
87
|
-
addImage(
|
|
88
|
-
this.#data.push(
|
|
127
|
+
addImage(url, options) {
|
|
128
|
+
this.#data.push({
|
|
129
|
+
type: 'MD.image',
|
|
130
|
+
value: url,
|
|
131
|
+
options
|
|
132
|
+
});
|
|
89
133
|
return this;
|
|
90
134
|
}
|
|
91
|
-
addList(...
|
|
92
|
-
this.#data.push(
|
|
135
|
+
addList(...items) {
|
|
136
|
+
this.#data.push({
|
|
137
|
+
type: 'MD.list',
|
|
138
|
+
value: items
|
|
139
|
+
});
|
|
93
140
|
return this;
|
|
94
141
|
}
|
|
95
|
-
addBlockquote(
|
|
96
|
-
this.#data.push(
|
|
142
|
+
addBlockquote(text) {
|
|
143
|
+
this.#data.push({
|
|
144
|
+
type: 'MD.blockquote',
|
|
145
|
+
value: text
|
|
146
|
+
});
|
|
97
147
|
return this;
|
|
98
148
|
}
|
|
99
149
|
addDivider() {
|
|
100
|
-
this.#data.push(
|
|
150
|
+
this.#data.push({
|
|
151
|
+
type: 'MD.divider'
|
|
152
|
+
});
|
|
101
153
|
return this;
|
|
102
154
|
}
|
|
103
|
-
addNewline(
|
|
104
|
-
this.#data.push(
|
|
155
|
+
addNewline(value = false) {
|
|
156
|
+
this.#data.push({
|
|
157
|
+
type: 'MD.newline',
|
|
158
|
+
value
|
|
159
|
+
});
|
|
105
160
|
return this;
|
|
106
161
|
}
|
|
107
|
-
addCode(
|
|
108
|
-
this.#data.push(
|
|
162
|
+
addCode(value, options) {
|
|
163
|
+
this.#data.push({
|
|
164
|
+
type: 'MD.code',
|
|
165
|
+
value,
|
|
166
|
+
options
|
|
167
|
+
});
|
|
109
168
|
return this;
|
|
110
169
|
}
|
|
111
170
|
addBreak() {
|
|
112
|
-
this
|
|
113
|
-
return this;
|
|
171
|
+
return this.addNewline();
|
|
114
172
|
}
|
|
115
|
-
addMention(
|
|
116
|
-
this.#data.push(
|
|
173
|
+
addMention(uid, options) {
|
|
174
|
+
this.#data.push({
|
|
175
|
+
type: 'MD.mention',
|
|
176
|
+
value: uid || 'everyone',
|
|
177
|
+
options: options ?? { belong: 'user' }
|
|
178
|
+
});
|
|
117
179
|
return this;
|
|
118
180
|
}
|
|
119
|
-
addButton(
|
|
120
|
-
this.#data.push(
|
|
181
|
+
addButton(title, data) {
|
|
182
|
+
this.#data.push({
|
|
183
|
+
type: 'MD.button',
|
|
184
|
+
value: title,
|
|
185
|
+
options: data
|
|
186
|
+
});
|
|
121
187
|
return this;
|
|
122
188
|
}
|
|
123
189
|
clear() {
|
|
@@ -125,6 +191,83 @@ class FormatMarkDown {
|
|
|
125
191
|
return this;
|
|
126
192
|
}
|
|
127
193
|
}
|
|
194
|
+
class FormatSelect {
|
|
195
|
+
#options = [];
|
|
196
|
+
#meta = {};
|
|
197
|
+
get value() {
|
|
198
|
+
return {
|
|
199
|
+
type: 'Select',
|
|
200
|
+
value: this.#options,
|
|
201
|
+
options: this.#meta
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
setCustomId(customId) {
|
|
205
|
+
this.#meta.customId = customId;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
setPlaceholder(placeholder) {
|
|
209
|
+
this.#meta.placeholder = placeholder;
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
setRange(min, max) {
|
|
213
|
+
if (min !== undefined) {
|
|
214
|
+
this.#meta.minValues = min;
|
|
215
|
+
}
|
|
216
|
+
if (max !== undefined) {
|
|
217
|
+
this.#meta.maxValues = max;
|
|
218
|
+
}
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
setKind(kind) {
|
|
222
|
+
this.#meta.kind = kind;
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
setDisabled(disabled = true) {
|
|
226
|
+
this.#meta.disabled = disabled;
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
addOption(label, value, extra) {
|
|
230
|
+
this.#options.push({ label, value, ...extra });
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
clear() {
|
|
234
|
+
this.#options = [];
|
|
235
|
+
this.#meta = {};
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class FormatModal {
|
|
240
|
+
#inputs = [];
|
|
241
|
+
#meta = { customId: '', title: '' };
|
|
242
|
+
get value() {
|
|
243
|
+
return {
|
|
244
|
+
type: 'Modal',
|
|
245
|
+
value: this.#inputs,
|
|
246
|
+
options: this.#meta
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
setCustomId(customId) {
|
|
250
|
+
this.#meta.customId = customId;
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
setTitle(title) {
|
|
254
|
+
this.#meta.title = title;
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
addInput(label, options) {
|
|
258
|
+
this.#inputs.push({
|
|
259
|
+
type: 'TextInput',
|
|
260
|
+
value: label,
|
|
261
|
+
options
|
|
262
|
+
});
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
clear() {
|
|
266
|
+
this.#inputs = [];
|
|
267
|
+
this.#meta = { customId: '', title: '' };
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
128
271
|
class Format {
|
|
129
272
|
#data = [];
|
|
130
273
|
static create() {
|
|
@@ -136,6 +279,12 @@ class Format {
|
|
|
136
279
|
static createButtonGroup() {
|
|
137
280
|
return new FormatButtonGroup();
|
|
138
281
|
}
|
|
282
|
+
static createSelect() {
|
|
283
|
+
return new FormatSelect();
|
|
284
|
+
}
|
|
285
|
+
static createModal() {
|
|
286
|
+
return new FormatModal();
|
|
287
|
+
}
|
|
139
288
|
get value() {
|
|
140
289
|
return this.#data;
|
|
141
290
|
}
|
|
@@ -143,16 +292,27 @@ class Format {
|
|
|
143
292
|
this.#data.push(...format.value);
|
|
144
293
|
return this;
|
|
145
294
|
}
|
|
146
|
-
addText(
|
|
147
|
-
this.#data.push(
|
|
295
|
+
addText(val, options) {
|
|
296
|
+
this.#data.push({
|
|
297
|
+
type: 'Text',
|
|
298
|
+
value: val,
|
|
299
|
+
options
|
|
300
|
+
});
|
|
148
301
|
return this;
|
|
149
302
|
}
|
|
150
|
-
addImage(
|
|
151
|
-
this.#data.push(
|
|
303
|
+
addImage(val) {
|
|
304
|
+
this.#data.push({
|
|
305
|
+
type: 'Image',
|
|
306
|
+
value: typeof val === 'string' ? val : `base64://${val.toString('base64')}`
|
|
307
|
+
});
|
|
152
308
|
return this;
|
|
153
309
|
}
|
|
154
|
-
addMention(
|
|
155
|
-
this.#data.push(
|
|
310
|
+
addMention(UserId, options) {
|
|
311
|
+
this.#data.push({
|
|
312
|
+
type: 'Mention',
|
|
313
|
+
value: UserId,
|
|
314
|
+
options: options ?? { belong: 'user' }
|
|
315
|
+
});
|
|
156
316
|
return this;
|
|
157
317
|
}
|
|
158
318
|
addButtonGroup(...args) {
|
|
@@ -160,7 +320,10 @@ class Format {
|
|
|
160
320
|
this.#data.push(args[0].value);
|
|
161
321
|
}
|
|
162
322
|
else {
|
|
163
|
-
this.#data.push(
|
|
323
|
+
this.#data.push({
|
|
324
|
+
type: 'BT.group',
|
|
325
|
+
value: args
|
|
326
|
+
});
|
|
164
327
|
}
|
|
165
328
|
return this;
|
|
166
329
|
}
|
|
@@ -169,36 +332,95 @@ class Format {
|
|
|
169
332
|
this.#data.push(args[0].value);
|
|
170
333
|
}
|
|
171
334
|
else {
|
|
172
|
-
this.#data.push(
|
|
335
|
+
this.#data.push({
|
|
336
|
+
type: 'Markdown',
|
|
337
|
+
value: args
|
|
338
|
+
});
|
|
173
339
|
}
|
|
174
340
|
return this;
|
|
175
341
|
}
|
|
176
|
-
addMarkdownOriginal(
|
|
177
|
-
this.#data.push(
|
|
342
|
+
addMarkdownOriginal(val) {
|
|
343
|
+
this.#data.push({
|
|
344
|
+
type: 'MarkdownOriginal',
|
|
345
|
+
value: val
|
|
346
|
+
});
|
|
347
|
+
return this;
|
|
348
|
+
}
|
|
349
|
+
addAttachment(val, options) {
|
|
350
|
+
this.#data.push({
|
|
351
|
+
type: 'Attachment',
|
|
352
|
+
value: val,
|
|
353
|
+
options
|
|
354
|
+
});
|
|
178
355
|
return this;
|
|
179
356
|
}
|
|
180
|
-
|
|
181
|
-
this.#data.push(
|
|
357
|
+
addAudio(val) {
|
|
358
|
+
this.#data.push({
|
|
359
|
+
type: 'Audio',
|
|
360
|
+
value: val
|
|
361
|
+
});
|
|
182
362
|
return this;
|
|
183
363
|
}
|
|
184
|
-
|
|
185
|
-
this.#data.push(
|
|
364
|
+
addVideo(val) {
|
|
365
|
+
this.#data.push({
|
|
366
|
+
type: 'Video',
|
|
367
|
+
value: val
|
|
368
|
+
});
|
|
186
369
|
return this;
|
|
187
370
|
}
|
|
188
|
-
|
|
189
|
-
this.#data.push(
|
|
371
|
+
addLink(val, options) {
|
|
372
|
+
this.#data.push({
|
|
373
|
+
type: 'Text',
|
|
374
|
+
value: val,
|
|
375
|
+
options
|
|
376
|
+
});
|
|
190
377
|
return this;
|
|
191
378
|
}
|
|
192
|
-
|
|
193
|
-
this.#data.push(
|
|
379
|
+
addImageFile(val) {
|
|
380
|
+
this.#data.push({
|
|
381
|
+
type: 'ImageFile',
|
|
382
|
+
value: val
|
|
383
|
+
});
|
|
194
384
|
return this;
|
|
195
385
|
}
|
|
196
|
-
|
|
197
|
-
this.#data.push(
|
|
386
|
+
addImageURL(val) {
|
|
387
|
+
this.#data.push({
|
|
388
|
+
type: 'ImageURL',
|
|
389
|
+
value: val
|
|
390
|
+
});
|
|
391
|
+
return this;
|
|
392
|
+
}
|
|
393
|
+
addSelect(...args) {
|
|
394
|
+
if (args[0] instanceof FormatSelect) {
|
|
395
|
+
this.#data.push(args[0].value);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
this.#data.push({
|
|
399
|
+
type: 'Select',
|
|
400
|
+
value: args[0],
|
|
401
|
+
options: (args[1] ?? {})
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
return this;
|
|
405
|
+
}
|
|
406
|
+
addModal(...args) {
|
|
407
|
+
if (args[0] instanceof FormatModal) {
|
|
408
|
+
this.#data.push(args[0].value);
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
this.#data.push({
|
|
412
|
+
type: 'Modal',
|
|
413
|
+
value: args[0],
|
|
414
|
+
options: args[1]
|
|
415
|
+
});
|
|
416
|
+
}
|
|
198
417
|
return this;
|
|
199
418
|
}
|
|
200
|
-
|
|
201
|
-
this.#data.push(
|
|
419
|
+
addEmbed(embed) {
|
|
420
|
+
this.#data.push({
|
|
421
|
+
type: 'Embed',
|
|
422
|
+
value: embed
|
|
423
|
+
});
|
|
202
424
|
return this;
|
|
203
425
|
}
|
|
204
426
|
clear() {
|
|
@@ -207,4 +429,4 @@ class Format {
|
|
|
207
429
|
}
|
|
208
430
|
}
|
|
209
431
|
|
|
210
|
-
export {
|
|
432
|
+
export { Format, FormatButtonGroup, FormatMarkDown, FormatModal, FormatSelect };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ScheduleId, ScheduleItem, ScheduleStatus, ScheduleCallback, CronExpression } from '../types/schedule';
|
|
2
|
+
export declare const registerAppDir: (appName: string, mainDir: string) => void;
|
|
3
|
+
export declare const unregisterAppDir: (appName: string) => void;
|
|
4
|
+
export declare const scheduleInterval: (callback: ScheduleCallback, ms: number, appName?: string) => ScheduleId;
|
|
5
|
+
export declare const scheduleTimeout: (callback: ScheduleCallback, ms: number, appName?: string) => ScheduleId;
|
|
6
|
+
export declare const scheduleCron: (expression: CronExpression, callback: ScheduleCallback, appName?: string) => ScheduleId;
|
|
7
|
+
export declare const schedulePause: (id: ScheduleId) => boolean;
|
|
8
|
+
export declare const scheduleResume: (id: ScheduleId) => boolean;
|
|
9
|
+
export declare const scheduleCancel: (id: ScheduleId) => boolean;
|
|
10
|
+
export declare const scheduleCancelByApp: (appName: string) => number;
|
|
11
|
+
export declare const scheduleCancelAll: () => number;
|
|
12
|
+
export declare const scheduleList: (appName?: string) => Array<{
|
|
13
|
+
id: ScheduleId;
|
|
14
|
+
type: ScheduleItem["type"];
|
|
15
|
+
status: ScheduleStatus;
|
|
16
|
+
ms?: number;
|
|
17
|
+
cron?: string;
|
|
18
|
+
appName?: string;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
}>;
|