alemonjs 2.1.0-alpha.2 → 2.1.0-alpha.21
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 +85 -25
- package/lib/app/event-group.d.ts +11 -0
- package/lib/app/event-group.js +28 -0
- package/lib/app/event-middleware.d.ts +10 -2
- package/lib/app/event-middleware.js +11 -1
- package/lib/app/event-processor-event.js +1 -1
- package/lib/app/event-processor-middleware.js +1 -1
- package/lib/app/event-processor.js +1 -1
- package/lib/app/event-response.d.ts +10 -2
- package/lib/app/event-response.js +12 -1
- package/lib/app/hook-use-api.d.ts +19 -24
- package/lib/app/hook-use-api.js +136 -117
- package/lib/app/hook-use-subscribe.d.ts +20 -3
- package/lib/app/hook-use-subscribe.js +13 -1
- package/lib/app/load.js +10 -14
- package/lib/app/message-api.d.ts +28 -8
- package/lib/app/message-api.js +31 -14
- package/lib/app/message-format.d.ts +5 -12
- package/lib/app/message-format.js +16 -7
- package/lib/app/store.js +4 -3
- package/lib/cbp/actions.js +11 -7
- package/lib/cbp/api.js +37 -0
- package/lib/cbp/config.js +8 -2
- package/lib/cbp/connect.d.ts +6 -2
- package/lib/cbp/connect.js +213 -30
- package/lib/cbp/index.js +53 -6
- package/lib/{app → core}/utils.d.ts +2 -3
- package/lib/{app → core}/utils.js +3 -4
- package/lib/core/variable.js +7 -1
- package/lib/global.d.ts +18 -1
- package/lib/index.d.ts +11 -10
- package/lib/index.js +7 -7
- package/lib/main.js +6 -5
- package/lib/typing/actions.d.ts +1 -1
- package/lib/typing/apis.d.ts +18 -0
- package/lib/typing/client/index.d.ts +1 -1
- package/lib/typing/event/base/expansion.d.ts +5 -0
- package/lib/typing/event/base/guild.d.ts +4 -0
- package/lib/typing/event/base/user.d.ts +4 -0
- package/lib/typing/event/channal/index.d.ts +3 -2
- package/lib/typing/event/guild/index.d.ts +3 -2
- package/lib/typing/event/index.d.ts +13 -1
- package/lib/typing/event/interaction/index.d.ts +3 -2
- package/lib/typing/event/map.d.ts +0 -2
- package/lib/typing/event/member/index.d.ts +3 -2
- package/lib/typing/event/message/message.d.ts +6 -5
- package/lib/typing/event/message/private.message.d.ts +4 -3
- package/lib/typing/event/request/index.d.ts +3 -2
- package/lib/typing/message/button.d.ts +6 -5
- package/lib/typing/message/index.d.ts +4 -4
- package/lib/typing/message/markdown.d.ts +13 -3
- package/lib/utils.d.ts +80 -0
- package/lib/utils.js +203 -0
- package/package.json +12 -3
- package/lib/app/define-bot.d.ts +0 -17
- package/lib/app/define-bot.js +0 -39
- package/lib/cbp/index.d.ts +0 -32
- package/lib/cbp/message.js +0 -9
- package/lib/jsx.d.ts +0 -142
- package/lib/jsx.js +0 -234
package/lib/core/variable.js
CHANGED
|
@@ -7,6 +7,12 @@ const processor_repeated_clear_size = 37;
|
|
|
7
7
|
const file_suffix_middleware = /^mw(\.|\..*\.)(js|ts|jsx|tsx)$/;
|
|
8
8
|
// 相应文件后缀正则
|
|
9
9
|
const file_suffix_response = /^res(\.|\..*\.)(js|ts|jsx|tsx)$/;
|
|
10
|
+
// 通用框架前缀正则
|
|
11
|
+
const file_prefix_common = /^(@alemonjs\/|alemonjs-)/;
|
|
12
|
+
// 默认端口
|
|
13
|
+
const default_port = 17117;
|
|
14
|
+
// 默认平台通用前缀
|
|
15
|
+
const default_platform_common_prefix = '@alemonjs/';
|
|
10
16
|
/**
|
|
11
17
|
* 结果反馈码
|
|
12
18
|
*/
|
|
@@ -29,4 +35,4 @@ const EventMessageText = [
|
|
|
29
35
|
'private.interaction.create'
|
|
30
36
|
];
|
|
31
37
|
|
|
32
|
-
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, Warn, file_suffix_middleware, file_suffix_response, processor_repeated_clear_size, processor_repeated_clear_time_max, processor_repeated_clear_time_min, processor_repeated_event_time, processor_repeated_user_time };
|
|
38
|
+
export { EventMessageText, Fail, FailAuth, FailInternal, FailParams, Ok, Warn, default_platform_common_prefix, default_port, file_prefix_common, file_suffix_middleware, file_suffix_response, processor_repeated_clear_size, processor_repeated_clear_time_max, processor_repeated_clear_time_min, processor_repeated_event_time, processor_repeated_user_time };
|
package/lib/global.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OnResponseReversalFunc, OnMiddlewareReversalFunc, DefineChildrenFunc, OnSelectsFunc, OnDataFormatFunc } from './typing/event/index.js';
|
|
1
|
+
import { OnResponseReversalFunc, OnResponseReversalFuncBack, OnMiddlewareReversalFunc, DefineChildrenFunc, OnSelectsFunc, OnDataFormatFunc, OnGroupFunc } from './typing/event/index.js';
|
|
2
2
|
import { StoreChildrenApp } from './typing/store/res.js';
|
|
3
3
|
import { StateSubscribeMap, SubscribeKeysMap } from './typing/subscribe/index.js';
|
|
4
4
|
import { LoggerUtils } from './typing/logger/index.js';
|
|
@@ -44,6 +44,11 @@ declare global {
|
|
|
44
44
|
* 定义响应体
|
|
45
45
|
*/
|
|
46
46
|
var onResponse: OnResponseReversalFunc;
|
|
47
|
+
/**
|
|
48
|
+
* 废弃,请使用 onResponse
|
|
49
|
+
* @deprecated
|
|
50
|
+
*/
|
|
51
|
+
var OnResponse: OnResponseReversalFuncBack;
|
|
47
52
|
/**
|
|
48
53
|
* 定义中间件
|
|
49
54
|
*/
|
|
@@ -60,6 +65,18 @@ declare global {
|
|
|
60
65
|
* 定义数据格式
|
|
61
66
|
*/
|
|
62
67
|
var format: OnDataFormatFunc;
|
|
68
|
+
/**
|
|
69
|
+
* 定义一组标准执行
|
|
70
|
+
*/
|
|
71
|
+
var onGroup: OnGroupFunc;
|
|
72
|
+
namespace NodeJS {
|
|
73
|
+
interface ProcessEnv {
|
|
74
|
+
login?: string;
|
|
75
|
+
platform?: string;
|
|
76
|
+
port?: string;
|
|
77
|
+
NODE_ENV?: 'development' | 'production';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
63
80
|
}
|
|
64
81
|
declare const logger: any;
|
|
65
82
|
declare const core: {
|
package/lib/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export { PublicEventMessageCreate, PublicEventMessageDelete, PublicEventMessageR
|
|
|
11
11
|
export { PrivateEventMessageCreate, PrivateEventMessageDelete, PrivateEventMessageUpdate } from './typing/event/message/private.message.js';
|
|
12
12
|
export { PrivateEventRequestFriendAdd, PrivateEventRequestGuildAdd } from './typing/event/request/index.js';
|
|
13
13
|
export { ActionsEventEnum } from './typing/event/actions.js';
|
|
14
|
-
export { Current, CurrentResult, CurrentResultValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnDataFormatFunc, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseValue, OnSelectsFunc } from './typing/event/index.js';
|
|
15
|
-
export { EventKeys, Events, EventsEnum,
|
|
14
|
+
export { Current, CurrentResult, CurrentResultValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnDataFormatFunc, OnGroupFunc, OnGroupItem, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseReversalFuncBack, OnResponseValue, OnSelectsFunc } from './typing/event/index.js';
|
|
15
|
+
export { EventKeys, Events, EventsEnum, EventsMessageCreate, EventsMessageCreateEnum, EventsMessageCreateKeys } from './typing/event/map.js';
|
|
16
16
|
export { LoggerUtils } from './typing/logger/index.js';
|
|
17
17
|
export { ClientAPI, ClientAPIMessageResult } from './typing/client/index.js';
|
|
18
18
|
export { DataEnums, MessageDataFormat } from './typing/message/index.js';
|
|
@@ -21,17 +21,18 @@ export { StateSubscribeMap, SubscribeKeysMap, SubscribeMap, SubscribeValue } fro
|
|
|
21
21
|
export { core, logger } from './global.js';
|
|
22
22
|
export { ConfigCore, getConfig, getConfigValue } from './core/config.js';
|
|
23
23
|
export { defineChildren } from './app/define-chidren.js';
|
|
24
|
-
export {
|
|
24
|
+
export { onGroup } from './app/event-group.js';
|
|
25
|
+
export { OnMiddleware, onMiddleware } from './app/event-middleware.js';
|
|
25
26
|
export { OnProcessor, onProcessor } from './app/event-processor.js';
|
|
26
|
-
export { onResponse } from './app/event-response.js';
|
|
27
|
-
export { createSelects, onSelects, unChildren, useChannel, useMenber, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
27
|
+
export { OnResponse, onResponse } from './app/event-response.js';
|
|
28
|
+
export { createSelects, onSelects, unChildren, useChannel, useClient, useMenber, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
28
29
|
export { onState, unState, useState } from './app/hook-use-state.js';
|
|
29
|
-
export { useSubscribe } from './app/hook-use-subscribe.js';
|
|
30
|
+
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
30
31
|
export { loadChildren, loadChildrenFile } from './app/load.js';
|
|
31
|
-
export { format, sendToChannel, sendToUser } from './app/message-api.js';
|
|
32
|
+
export { createDataFormat, createEventValue, format, sendToChannel, sendToUser } from './app/message-api.js';
|
|
32
33
|
export { Ark, BT, Image, ImageFile, ImageURL, Link, MD, Mention, Text } from './app/message-format.js';
|
|
33
34
|
export { ChildrenApp, Core, Logger, Middleware, ProcessorEventAutoClearMap, ProcessorEventUserAudoClearMap, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
34
|
-
export { Result, createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './
|
|
35
|
+
export { Result, createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './core/utils.js';
|
|
35
36
|
export { cbpClient, cbpPlatform } from './cbp/connect.js';
|
|
36
37
|
export { run, start } from './main.js';
|
|
37
38
|
export { ResultCode } from './core/code.js';
|
|
@@ -39,6 +40,6 @@ export { DataText } from './typing/message/text.js';
|
|
|
39
40
|
export { DataLink } from './typing/message/link.js';
|
|
40
41
|
export { DataMention } from './typing/message/mention.js';
|
|
41
42
|
export { DataImage, DataImageFile, DataImageURL } from './typing/message/image.js';
|
|
42
|
-
export { ButtonRow, DataButton, DataButtonGroup } from './typing/message/button.js';
|
|
43
|
+
export { ButtonRow, DataButton, DataButtonGroup, DataButtonTemplate } from './typing/message/button.js';
|
|
43
44
|
export { DataArkBigCard, DataArkCard, DataArkList, DataArkListContent, DataArkListItem, DataArkListTip } from './typing/message/ark.js';
|
|
44
|
-
export { DataMarkDown, DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle } from './typing/message/markdown.js';
|
|
45
|
+
export { DataMarkDown, DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownCode, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle } from './typing/message/markdown.js';
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export { ActionsEventEnum } from './typing/event/actions.js';
|
|
2
|
-
export { EventsKeyEnum } from './typing/event/map.js';
|
|
3
2
|
export { core, logger } from './global.js';
|
|
4
3
|
export { ConfigCore, getConfig, getConfigValue } from './core/config.js';
|
|
5
4
|
export { defineChildren } from './app/define-chidren.js';
|
|
6
|
-
export {
|
|
5
|
+
export { onGroup } from './app/event-group.js';
|
|
6
|
+
export { OnMiddleware, onMiddleware } from './app/event-middleware.js';
|
|
7
7
|
export { OnProcessor, onProcessor } from './app/event-processor.js';
|
|
8
|
-
export { onResponse } from './app/event-response.js';
|
|
9
|
-
export { createSelects, onSelects, unChildren, useChannel, useMenber, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
8
|
+
export { OnResponse, onResponse } from './app/event-response.js';
|
|
9
|
+
export { createSelects, onSelects, unChildren, useChannel, useClient, useMenber, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
10
10
|
export { onState, unState, useState } from './app/hook-use-state.js';
|
|
11
|
-
export { useSubscribe } from './app/hook-use-subscribe.js';
|
|
11
|
+
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
12
12
|
export { loadChildren, loadChildrenFile } from './app/load.js';
|
|
13
|
-
export { format, sendToChannel, sendToUser } from './app/message-api.js';
|
|
13
|
+
export { createDataFormat, createEventValue, format, sendToChannel, sendToUser } from './app/message-api.js';
|
|
14
14
|
export { Ark, BT, Image, ImageFile, ImageURL, Link, MD, Mention, Text } from './app/message-format.js';
|
|
15
15
|
export { ChildrenApp, Core, Logger, Middleware, ProcessorEventAutoClearMap, ProcessorEventUserAudoClearMap, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
16
|
-
export { createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './
|
|
16
|
+
export { createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './core/utils.js';
|
|
17
17
|
export { cbpClient, cbpPlatform } from './cbp/connect.js';
|
|
18
18
|
export { run, start } from './main.js';
|
|
19
19
|
export { ResultCode } from './core/code.js';
|
package/lib/main.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getConfig, getConfigValue } from './core/config.js';
|
|
2
2
|
import { loadChildren, loadChildrenFile } from './app/load.js';
|
|
3
|
-
import { getInputExportPath } from './
|
|
3
|
+
import { getInputExportPath } from './core/utils.js';
|
|
4
4
|
import './app/define-chidren.js';
|
|
5
|
+
import './app/event-group.js';
|
|
5
6
|
import './app/event-middleware.js';
|
|
6
7
|
import './app/event-processor.js';
|
|
7
8
|
import './app/event-response.js';
|
|
@@ -16,8 +17,8 @@ import { cbpClient } from './cbp/connect.js';
|
|
|
16
17
|
import { join } from 'path';
|
|
17
18
|
import { existsSync } from 'fs';
|
|
18
19
|
import { cbpServer } from './cbp/index.js';
|
|
20
|
+
import { default_port, file_prefix_common, default_platform_common_prefix } from './core/variable.js';
|
|
19
21
|
|
|
20
|
-
const defaultPort = 17117;
|
|
21
22
|
const loadState = () => {
|
|
22
23
|
const value = getConfigValue() ?? {};
|
|
23
24
|
const state = value?.core?.state ?? [];
|
|
@@ -72,7 +73,7 @@ const start = async (options = {}) => {
|
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
75
|
// 创建 cbp 服务器
|
|
75
|
-
const port = options?.port || cfg.argv?.port || cfg.value?.port ||
|
|
76
|
+
const port = options?.port || cfg.argv?.port || cfg.value?.port || default_port;
|
|
76
77
|
// 设置环境变量
|
|
77
78
|
process.env.port = port;
|
|
78
79
|
cbpServer(port, async () => {
|
|
@@ -89,7 +90,7 @@ const start = async (options = {}) => {
|
|
|
89
90
|
}
|
|
90
91
|
// 如果存在
|
|
91
92
|
if (platform) {
|
|
92
|
-
const reg =
|
|
93
|
+
const reg = file_prefix_common;
|
|
93
94
|
if (reg.test(platform)) {
|
|
94
95
|
process.env.platform = platform;
|
|
95
96
|
// 剪切
|
|
@@ -103,7 +104,7 @@ const start = async (options = {}) => {
|
|
|
103
104
|
}
|
|
104
105
|
else {
|
|
105
106
|
// 如果没有指定平台,则使用登录名作为平台
|
|
106
|
-
process.env.platform =
|
|
107
|
+
process.env.platform = `${default_platform_common_prefix}${login}`;
|
|
107
108
|
process.env.login = login;
|
|
108
109
|
}
|
|
109
110
|
// 设置了 login。强制指定
|
package/lib/typing/actions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventKeys, Events } from '../event/map.js';
|
|
2
2
|
import { User } from '../event/base/user.js';
|
|
3
3
|
import { DataEnums } from '../message/index.js';
|
|
4
|
-
import { Result } from '../../
|
|
4
|
+
import { Result } from '../../core/utils.js';
|
|
5
5
|
import '../../global.js';
|
|
6
6
|
|
|
7
7
|
type ClientAPIMessageResult = Result & {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Guild, Channel } from '../base/guild.js';
|
|
2
2
|
import { platform } from '../base/platform.js';
|
|
3
3
|
import { Message } from '../base/message.js';
|
|
4
|
+
import { Expansion } from '../base/expansion.js';
|
|
4
5
|
|
|
5
6
|
type PublicEventChannalCreate = platform & Guild & Channel & Message & {
|
|
6
7
|
name: 'channal.create';
|
|
7
|
-
};
|
|
8
|
+
} & Expansion;
|
|
8
9
|
type PublicEventChannalDelete = platform & Guild & Channel & Message & {
|
|
9
10
|
name: 'channal.delete';
|
|
10
|
-
};
|
|
11
|
+
} & Expansion;
|
|
11
12
|
|
|
12
13
|
export type { PublicEventChannalCreate, PublicEventChannalDelete };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Expansion } from '../base/expansion.js';
|
|
1
2
|
import { Guild } from '../base/guild.js';
|
|
2
3
|
import { Message } from '../base/message.js';
|
|
3
4
|
import { platform } from '../base/platform.js';
|
|
4
5
|
|
|
5
6
|
type PublicEventGuildJoin = platform & Guild & Message & {
|
|
6
7
|
name: 'guild.join';
|
|
7
|
-
};
|
|
8
|
+
} & Expansion;
|
|
8
9
|
type PublicEventGuildExit = platform & Guild & Message & {
|
|
9
10
|
name: 'guild.exit';
|
|
10
|
-
};
|
|
11
|
+
} & Expansion;
|
|
11
12
|
|
|
12
13
|
export type { PublicEventGuildExit, PublicEventGuildJoin };
|
|
@@ -25,6 +25,11 @@ type OnResponseValue<C, T extends EventKeys> = {
|
|
|
25
25
|
*/
|
|
26
26
|
type OnResponseFunc = <T extends EventKeys, C extends Current<T> | Current<T>[]>(callback: C, select: T | T[]) => OnResponseValue<C, T>;
|
|
27
27
|
type OnResponseReversalFunc = <T extends EventKeys, C extends Current<T> | Current<T>[]>(select: T | T[], callback: C) => OnResponseValue<C, T>;
|
|
28
|
+
/**
|
|
29
|
+
* 废弃
|
|
30
|
+
* @deprecated
|
|
31
|
+
*/
|
|
32
|
+
type OnResponseReversalFuncBack = <T extends EventKeys, C extends Current<T> | Current<T>[]>(callback: C, select: T | T[]) => OnResponseValue<C, T>;
|
|
28
33
|
/**
|
|
29
34
|
* 定义一个中间件
|
|
30
35
|
*/
|
|
@@ -33,6 +38,11 @@ type OnMiddlewareFunc = <T extends EventKeys, C extends Current<T> | Current<T>[
|
|
|
33
38
|
*
|
|
34
39
|
*/
|
|
35
40
|
type OnMiddlewareReversalFunc = <T extends EventKeys, C extends Current<T> | Current<T>[]>(select: T | T[], callback: C) => OnMiddlewareValue<C, T>;
|
|
41
|
+
/**
|
|
42
|
+
* 废弃
|
|
43
|
+
* @deprecated
|
|
44
|
+
*/
|
|
45
|
+
type OnMiddlewareReversalFuncBack = <T extends EventKeys, C extends Current<T> | Current<T>[]>(callback: C, select: T | T[]) => OnMiddlewareValue<C, T>;
|
|
36
46
|
/**
|
|
37
47
|
*
|
|
38
48
|
*/
|
|
@@ -78,5 +88,7 @@ type OnSelectsFunc = <T extends EventKeys[] | EventKeys>(values: T) => T;
|
|
|
78
88
|
* 定义数据格式
|
|
79
89
|
*/
|
|
80
90
|
type OnDataFormatFunc = (...data: DataEnums[]) => DataEnums[];
|
|
91
|
+
type OnGroupItem<C = any, T extends EventKeys = EventKeys> = OnResponseValue<C, T> | OnMiddlewareValue<C, T>;
|
|
92
|
+
type OnGroupFunc = <C, T extends EventKeys, TFirst extends OnGroupItem<C, T>>(...calls: [TFirst, ...Array<TFirst>]) => TFirst;
|
|
81
93
|
|
|
82
|
-
export type { Current, CurrentResult, CurrentResultValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnDataFormatFunc, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseValue, OnSelectsFunc };
|
|
94
|
+
export type { Current, CurrentResult, CurrentResultValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnDataFormatFunc, OnGroupFunc, OnGroupItem, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseReversalFuncBack, OnResponseValue, OnSelectsFunc };
|
|
@@ -2,12 +2,13 @@ import { Guild, Channel } from '../base/guild.js';
|
|
|
2
2
|
import { MessageText, MessageOpen, Message } from '../base/message.js';
|
|
3
3
|
import { User } from '../base/user.js';
|
|
4
4
|
import { platform } from '../base/platform.js';
|
|
5
|
+
import { Expansion } from '../base/expansion.js';
|
|
5
6
|
|
|
6
7
|
type PrivateEventInteractionCreate = MessageText & MessageOpen & platform & Message & User & {
|
|
7
8
|
name: 'private.interaction.create';
|
|
8
|
-
};
|
|
9
|
+
} & Expansion;
|
|
9
10
|
type PublicEventInteractionCreate = MessageText & MessageOpen & platform & Guild & Channel & Message & User & {
|
|
10
11
|
name: 'interaction.create';
|
|
11
|
-
};
|
|
12
|
+
} & Expansion;
|
|
12
13
|
|
|
13
14
|
export type { PrivateEventInteractionCreate, PublicEventInteractionCreate };
|
|
@@ -32,7 +32,5 @@ type Events = {
|
|
|
32
32
|
} & EventsMessageCreate;
|
|
33
33
|
type EventKeys = keyof Events;
|
|
34
34
|
type EventsEnum = Events[EventKeys];
|
|
35
|
-
declare const EventsKeyEnum: EventKeys[];
|
|
36
35
|
|
|
37
|
-
export { EventsKeyEnum };
|
|
38
36
|
export type { EventKeys, Events, EventsEnum, EventsMessageCreate, EventsMessageCreateEnum, EventsMessageCreateKeys };
|
|
@@ -2,12 +2,13 @@ import { Guild, Channel } from '../base/guild.js';
|
|
|
2
2
|
import { Message } from '../base/message.js';
|
|
3
3
|
import { User } from '../base/user.js';
|
|
4
4
|
import { platform } from '../base/platform.js';
|
|
5
|
+
import { Expansion } from '../base/expansion.js';
|
|
5
6
|
|
|
6
7
|
type PublicEventMemberAdd = platform & Guild & Channel & Message & User & {
|
|
7
8
|
naem: 'member.add';
|
|
8
|
-
};
|
|
9
|
+
} & Expansion;
|
|
9
10
|
type PublicEventMemberRemove = platform & Guild & Channel & Message & User & {
|
|
10
11
|
name: 'member.remove';
|
|
11
|
-
};
|
|
12
|
+
} & Expansion;
|
|
12
13
|
|
|
13
14
|
export type { PublicEventMemberAdd, PublicEventMemberRemove };
|
|
@@ -2,21 +2,22 @@ import { Guild, Channel } from '../base/guild.js';
|
|
|
2
2
|
import { Message, MessageText, MessageOpen } from '../base/message.js';
|
|
3
3
|
import { User } from '../base/user.js';
|
|
4
4
|
import { platform } from '../base/platform.js';
|
|
5
|
+
import { Expansion } from '../base/expansion.js';
|
|
5
6
|
|
|
6
7
|
type PublicEventMessageCreate = MessageText & MessageOpen & platform & Guild & Channel & Message & User & {
|
|
7
8
|
name: 'message.create';
|
|
8
|
-
};
|
|
9
|
+
} & Expansion;
|
|
9
10
|
type PublicEventMessageUpdate = platform & Guild & Channel & Message & User & {
|
|
10
11
|
name: 'message.update';
|
|
11
|
-
};
|
|
12
|
+
} & Expansion;
|
|
12
13
|
type PublicEventMessageDelete = platform & Guild & Channel & Message & {
|
|
13
14
|
name: 'message.delete';
|
|
14
|
-
};
|
|
15
|
+
} & Expansion;
|
|
15
16
|
type PublicEventMessageReactionAdd = platform & Guild & Channel & Message & {
|
|
16
17
|
name: 'message.reaction.add';
|
|
17
|
-
};
|
|
18
|
+
} & Expansion;
|
|
18
19
|
type PublicEventMessageReactionRemove = platform & Guild & Channel & Message & {
|
|
19
20
|
name: 'message.reaction.remove';
|
|
20
|
-
};
|
|
21
|
+
} & Expansion;
|
|
21
22
|
|
|
22
23
|
export type { PublicEventMessageCreate, PublicEventMessageDelete, PublicEventMessageReactionAdd, PublicEventMessageReactionRemove, PublicEventMessageUpdate };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { Expansion } from '../base/expansion.js';
|
|
1
2
|
import { Message, MessageText, MessageOpen } from '../base/message.js';
|
|
2
3
|
import { platform } from '../base/platform.js';
|
|
3
4
|
import { User } from '../base/user.js';
|
|
4
5
|
|
|
5
6
|
type PrivateEventMessageCreate = MessageText & MessageOpen & platform & Message & User & {
|
|
6
7
|
name: 'private.message.create';
|
|
7
|
-
};
|
|
8
|
+
} & Expansion;
|
|
8
9
|
type PrivateEventMessageUpdate = platform & Message & User & {
|
|
9
10
|
name: 'private.message.update';
|
|
10
|
-
};
|
|
11
|
+
} & Expansion;
|
|
11
12
|
type PrivateEventMessageDelete = platform & Message & {
|
|
12
13
|
name: 'private.message.delete';
|
|
13
|
-
};
|
|
14
|
+
} & Expansion;
|
|
14
15
|
|
|
15
16
|
export type { PrivateEventMessageCreate, PrivateEventMessageDelete, PrivateEventMessageUpdate };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Expansion } from '../base/expansion.js';
|
|
1
2
|
import { Message } from '../base/message.js';
|
|
2
3
|
import { platform } from '../base/platform.js';
|
|
3
4
|
import { User } from '../base/user.js';
|
|
4
5
|
|
|
5
6
|
type PrivateEventRequestFriendAdd = platform & Message & User & {
|
|
6
7
|
name: 'private.request.friend.add';
|
|
7
|
-
};
|
|
8
|
+
} & Expansion;
|
|
8
9
|
type PrivateEventRequestGuildAdd = platform & Message & User & {
|
|
9
10
|
name: 'private.request.guild.add';
|
|
10
|
-
};
|
|
11
|
+
} & Expansion;
|
|
11
12
|
|
|
12
13
|
export type { PrivateEventRequestFriendAdd, PrivateEventRequestGuildAdd };
|
|
@@ -13,7 +13,7 @@ type DataButton = {
|
|
|
13
13
|
confirm: string;
|
|
14
14
|
cancel: string;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type?: 'command' | 'link' | 'call';
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
type ButtonRow = {
|
|
@@ -23,9 +23,10 @@ type ButtonRow = {
|
|
|
23
23
|
type DataButtonGroup = {
|
|
24
24
|
type: 'BT.group';
|
|
25
25
|
value: ButtonRow[];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
};
|
|
27
|
+
type DataButtonTemplate = {
|
|
28
|
+
type: 'ButtonTemplate';
|
|
29
|
+
value: string;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export type { ButtonRow, DataButton, DataButtonGroup };
|
|
32
|
+
export type { ButtonRow, DataButton, DataButtonGroup, DataButtonTemplate };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { DataButtonGroup } from './button.js';
|
|
1
|
+
import { DataButtonGroup, DataButtonTemplate } from './button.js';
|
|
2
2
|
export { ButtonRow, DataButton } from './button.js';
|
|
3
3
|
import { DataArkList, DataArkCard, DataArkBigCard } from './ark.js';
|
|
4
4
|
export { DataArkListContent, DataArkListItem, DataArkListTip } from './ark.js';
|
|
5
5
|
import { DataMarkDown, DataMarkdownTemplate } from './markdown.js';
|
|
6
|
-
export { DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownText, DataMarkdownTitle } from './markdown.js';
|
|
6
|
+
export { DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownCode, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownText, DataMarkdownTitle } from './markdown.js';
|
|
7
7
|
import { DataImage, DataImageURL, DataImageFile } from './image.js';
|
|
8
8
|
import { DataText } from './text.js';
|
|
9
9
|
import { DataMention } from './mention.js';
|
|
10
10
|
import { DataLink } from './link.js';
|
|
11
11
|
|
|
12
|
-
type DataEnums = DataText | DataLink | DataImage | DataImageURL | DataImageFile | DataMention | DataButtonGroup | DataArkList | DataArkCard | DataArkBigCard | DataMarkDown | DataMarkdownTemplate;
|
|
12
|
+
type DataEnums = DataText | DataLink | DataImage | DataImageURL | DataImageFile | DataMention | DataButtonGroup | DataButtonTemplate | DataArkList | DataArkCard | DataArkBigCard | DataMarkDown | DataMarkdownTemplate;
|
|
13
13
|
type MessageDataFormat = DataEnums[];
|
|
14
14
|
|
|
15
|
-
export { DataArkBigCard, DataArkCard, DataArkList, DataButtonGroup, DataImage, DataImageFile, DataImageURL, DataLink, DataMarkDown, DataMarkdownTemplate, DataMention, DataText };
|
|
15
|
+
export { DataArkBigCard, DataArkCard, DataArkList, DataButtonGroup, DataButtonTemplate, DataImage, DataImageFile, DataImageURL, DataLink, DataMarkDown, DataMarkdownTemplate, DataMention, DataText };
|
|
16
16
|
export type { DataEnums, MessageDataFormat };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*/
|
|
1
4
|
type DataMarkdownTemplate = {
|
|
2
|
-
type: '
|
|
5
|
+
type: 'MarkdownTemplate';
|
|
3
6
|
value: string;
|
|
4
7
|
options: {
|
|
5
8
|
params: {
|
|
@@ -72,10 +75,17 @@ type DataMarkdownNewline = {
|
|
|
72
75
|
type: 'MD.newline';
|
|
73
76
|
value: boolean;
|
|
74
77
|
};
|
|
75
|
-
type
|
|
78
|
+
type DataMarkdownCode = {
|
|
79
|
+
type: 'MD.code';
|
|
80
|
+
value: string;
|
|
81
|
+
options?: {
|
|
82
|
+
language?: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
type DataMarkDownBalue = DataMarkdownText | DataMarkdownTitle | DataMarkdownSubtitle | DataMarkdownBold | DataMarkdownItalic | DataMarkdownItalicStar | DataMarkdownStrikethrough | DataMarkdownLink | DataMarkdownImage | DataMarkdownList | DataMarkdownBlockquote | DataMarkdownDivider | DataMarkdownNewline | DataMarkdownCode;
|
|
76
86
|
type DataMarkDown = {
|
|
77
87
|
type: 'Markdown';
|
|
78
88
|
value: DataMarkDownBalue[];
|
|
79
89
|
};
|
|
80
90
|
|
|
81
|
-
export type { DataMarkDown, DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle };
|
|
91
|
+
export type { DataMarkDown, DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownCode, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle };
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { PathLike } from 'fs';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { Options } from 'public-ip';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 通过URL获取Buffer
|
|
7
|
+
* @param url
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
declare const getBufferByURL: (url: string) => Promise<Buffer>;
|
|
11
|
+
/**
|
|
12
|
+
* 生成二维码
|
|
13
|
+
* @param text
|
|
14
|
+
* @param targetPath
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
declare const createQRCode: (text: string, targetPath?: string) => Promise<Buffer | false>;
|
|
18
|
+
declare class Counter {
|
|
19
|
+
#private;
|
|
20
|
+
/**
|
|
21
|
+
* 计数器
|
|
22
|
+
* @param initialValue
|
|
23
|
+
*/
|
|
24
|
+
constructor(initialValue: number);
|
|
25
|
+
/**
|
|
26
|
+
* 获取当前计数值
|
|
27
|
+
*/
|
|
28
|
+
get value(): number;
|
|
29
|
+
/**
|
|
30
|
+
* 获取下一个计数值
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
next(): number;
|
|
34
|
+
/**
|
|
35
|
+
* 重置计数器
|
|
36
|
+
* @param initialValue
|
|
37
|
+
*/
|
|
38
|
+
reStart(initialValue?: number): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 创建form
|
|
42
|
+
* @param options.url
|
|
43
|
+
* @param options.image
|
|
44
|
+
* @param options.name
|
|
45
|
+
* @description 支持以下几种方式创建图片数据:
|
|
46
|
+
* 1. 通过url获取图片数据
|
|
47
|
+
* 2. 通过图片路径获取图片数据
|
|
48
|
+
* 3. 通过base64字符串获取图片数据
|
|
49
|
+
* 4. 通过Buffer获取图片数据
|
|
50
|
+
* 5. 通过Readable流获取图片数据
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
declare function createPicFrom(options: {
|
|
54
|
+
url?: PathLike;
|
|
55
|
+
image?: string | Buffer | Readable;
|
|
56
|
+
name?: string;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
picData: Readable;
|
|
59
|
+
name: string;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param options
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
declare const getPublicIP: (options?: Options & {
|
|
67
|
+
force?: boolean;
|
|
68
|
+
}) => Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* 正则表达式工具类
|
|
71
|
+
*/
|
|
72
|
+
declare class Regular extends RegExp {
|
|
73
|
+
constructor(pattern: string, flags?: string);
|
|
74
|
+
static or(...regs: RegExp[]): Regular;
|
|
75
|
+
static and(...regs: RegExp[]): Regular;
|
|
76
|
+
or(...regs: RegExp[]): Regular;
|
|
77
|
+
and(...regs: RegExp[]): Regular;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { Counter, Regular, createPicFrom, createQRCode, getBufferByURL, getPublicIP };
|