alemonjs 2.1.0-alpha.40 → 2.1.0-alpha.41
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/adapter.js +112 -0
- package/lib/app/define-chidren.d.ts +1 -2
- package/lib/app/define-chidren.js +1 -1
- package/lib/app/event-group.d.ts +1 -2
- package/lib/app/event-middleware.d.ts +1 -2
- package/lib/app/event-middleware.js +1 -1
- package/lib/app/event-processor-cycle.d.ts +1 -2
- package/lib/app/event-processor-cycle.js +12 -6
- package/lib/app/event-processor-event.d.ts +2 -3
- package/lib/app/event-processor-middleware.d.ts +2 -3
- package/lib/app/event-processor-subscribe.d.ts +2 -3
- package/lib/app/event-processor.d.ts +1 -2
- package/lib/app/event-response.d.ts +1 -2
- package/lib/app/hook-use-api.d.ts +3 -4
- package/lib/app/hook-use-api.js +1 -1
- package/lib/app/hook-use-state.js +1 -1
- package/lib/app/hook-use-subscribe.d.ts +3 -4
- package/lib/app/hook-use-subscribe.js +1 -1
- package/lib/app/load.js +5 -6
- package/lib/app/message-api.d.ts +2 -2
- package/lib/app/message-api.js +1 -1
- package/lib/app/message-format.d.ts +7 -8
- package/lib/app/store.d.ts +6 -6
- package/lib/cbp/actions.js +1 -1
- package/lib/cbp/api.js +1 -1
- package/lib/cbp/client.js +1 -1
- package/lib/cbp/connect.js +1 -1
- package/lib/cbp/platform.d.ts +1 -2
- package/lib/cbp/platform.js +3 -3
- package/lib/cbp/server.js +1 -1
- package/lib/cbp/testone.js +1 -1
- package/lib/cbp/typings.d.ts +2 -3
- package/lib/core/config.d.ts +1 -2
- package/lib/core/config.js +1 -2
- package/lib/core/utils.d.ts +1 -1
- package/lib/core/utils.js +2 -3
- package/lib/core/variable.d.ts +16 -0
- package/lib/core/variable.js +19 -6
- package/lib/global.d.ts +5 -5
- package/lib/index.d.ts +29 -29
- package/lib/index.js +3 -3
- package/lib/main.js +14 -28
- package/lib/types/actions.d.ts +93 -0
- package/lib/types/apis.d.ts +18 -0
- package/lib/types/client/index.d.ts +66 -0
- package/lib/types/cycle/index.d.ts +42 -0
- package/lib/types/event/actions.d.ts +37 -0
- package/lib/types/event/actions.js +72 -0
- package/lib/types/event/base/expansion.d.ts +5 -0
- package/lib/types/event/base/guild.d.ts +18 -0
- package/lib/types/event/base/message.d.ts +28 -0
- package/lib/types/event/base/platform.d.ts +16 -0
- package/lib/types/event/base/user.d.ts +34 -0
- package/lib/types/event/channal/index.d.ts +13 -0
- package/lib/types/event/guild/index.d.ts +13 -0
- package/lib/types/event/index.d.ts +94 -0
- package/lib/types/event/interaction/index.d.ts +14 -0
- package/lib/types/event/map.d.ts +36 -0
- package/lib/types/event/member/index.d.ts +14 -0
- package/lib/types/event/message/message.d.ts +23 -0
- package/lib/types/event/message/private.message.d.ts +16 -0
- package/lib/types/event/request/index.d.ts +13 -0
- package/lib/types/logger/index.d.ts +49 -0
- package/lib/types/message/ark.d.ts +46 -0
- package/lib/types/message/button.d.ts +32 -0
- package/lib/types/message/image.d.ts +23 -0
- package/lib/types/message/index.d.ts +16 -0
- package/lib/types/message/link.d.ts +12 -0
- package/lib/types/message/markdown.d.ts +91 -0
- package/lib/types/message/mention.d.ts +16 -0
- package/lib/types/message/text.d.ts +12 -0
- package/lib/types/package/index.d.ts +12 -0
- package/lib/types/state/index.d.ts +5 -0
- package/lib/types/store/res.d.ts +75 -0
- package/lib/types/subscribe/index.d.ts +30 -0
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +3 -8
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
export { ChildrenCycle, EventCycleEnum, Next } from './
|
|
2
|
-
export { Channel, Guild } from './
|
|
3
|
-
export { Message, MessageOpen, MessageText } from './
|
|
4
|
-
export { platform } from './
|
|
5
|
-
export { User } from './
|
|
6
|
-
export { PublicEventChannalCreate, PublicEventChannalDelete } from './
|
|
7
|
-
export { PublicEventGuildExit, PublicEventGuildJoin } from './
|
|
8
|
-
export { PrivateEventInteractionCreate, PublicEventInteractionCreate } from './
|
|
9
|
-
export { PublicEventMemberAdd, PublicEventMemberRemove } from './
|
|
10
|
-
export { PublicEventMessageCreate, PublicEventMessageDelete, PublicEventMessageReactionAdd, PublicEventMessageReactionRemove, PublicEventMessageUpdate } from './
|
|
11
|
-
export { PrivateEventMessageCreate, PrivateEventMessageDelete, PrivateEventMessageUpdate } from './
|
|
12
|
-
export { PrivateEventRequestFriendAdd, PrivateEventRequestGuildAdd } from './
|
|
13
|
-
export { ActionsEventEnum } from './
|
|
14
|
-
export { Current, CurrentResult, CurrentResultValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnDataFormatFunc, OnGroupFunc, OnGroupItem, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseReversalFuncBack, OnResponseValue, OnSelectsFunc } from './
|
|
15
|
-
export { EventKeys, Events, EventsEnum, EventsMessageCreate, EventsMessageCreateEnum, EventsMessageCreateKeys } from './
|
|
16
|
-
export { LoggerUtils } from './
|
|
17
|
-
export { ClientAPI, ClientAPIMessageResult } from './
|
|
18
|
-
export { DataEnums, MessageDataFormat } from './
|
|
19
|
-
export { StoreChildrenApp, StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem } from './
|
|
20
|
-
export { StateSubscribeMap, SubscribeKeysMap, SubscribeMap, SubscribeValue } from './
|
|
1
|
+
export { ChildrenCycle, EventCycleEnum, Next } from './types/cycle/index.js';
|
|
2
|
+
export { Channel, Guild } from './types/event/base/guild.js';
|
|
3
|
+
export { Message, MessageOpen, MessageText } from './types/event/base/message.js';
|
|
4
|
+
export { platform } from './types/event/base/platform.js';
|
|
5
|
+
export { User } from './types/event/base/user.js';
|
|
6
|
+
export { PublicEventChannalCreate, PublicEventChannalDelete } from './types/event/channal/index.js';
|
|
7
|
+
export { PublicEventGuildExit, PublicEventGuildJoin } from './types/event/guild/index.js';
|
|
8
|
+
export { PrivateEventInteractionCreate, PublicEventInteractionCreate } from './types/event/interaction/index.js';
|
|
9
|
+
export { PublicEventMemberAdd, PublicEventMemberRemove } from './types/event/member/index.js';
|
|
10
|
+
export { PublicEventMessageCreate, PublicEventMessageDelete, PublicEventMessageReactionAdd, PublicEventMessageReactionRemove, PublicEventMessageUpdate } from './types/event/message/message.js';
|
|
11
|
+
export { PrivateEventMessageCreate, PrivateEventMessageDelete, PrivateEventMessageUpdate } from './types/event/message/private.message.js';
|
|
12
|
+
export { PrivateEventRequestFriendAdd, PrivateEventRequestGuildAdd } from './types/event/request/index.js';
|
|
13
|
+
export { ActionsEventEnum } from './types/event/actions.js';
|
|
14
|
+
export { Current, CurrentResult, CurrentResultValue, DefineChildrenCallback, DefineChildrenFunc, DefineChildrenValue, DefinePlatformCallback, DefinePlatformFunc, DefinePlatformValue, OnDataFormatFunc, OnGroupFunc, OnGroupItem, OnMiddlewareFunc, OnMiddlewareReversalFunc, OnMiddlewareReversalFuncBack, OnMiddlewareValue, OnResponseFunc, OnResponseReversalFunc, OnResponseReversalFuncBack, OnResponseValue, OnSelectsFunc } from './types/event/index.js';
|
|
15
|
+
export { EventKeys, Events, EventsEnum, EventsMessageCreate, EventsMessageCreateEnum, EventsMessageCreateKeys } from './types/event/map.js';
|
|
16
|
+
export { LoggerUtils } from './types/logger/index.js';
|
|
17
|
+
export { ClientAPI, ClientAPIMessageResult } from './types/client/index.js';
|
|
18
|
+
export { DataEnums, MessageDataFormat } from './types/message/index.js';
|
|
19
|
+
export { StoreChildrenApp, StoreMiddleware, StoreMiddlewareItem, StoreResponse, StoreResponseItem } from './types/store/res.js';
|
|
20
|
+
export { StateSubscribeMap, SubscribeKeysMap, SubscribeMap, SubscribeValue } from './types/subscribe/index.js';
|
|
21
21
|
export { core, logger } from './global.js';
|
|
22
|
-
export { ConfigCore, getConfig, getConfigValue } from './core/config.js';
|
|
23
22
|
export { defineChildren } from './app/define-chidren.js';
|
|
24
23
|
export { onGroup } from './app/event-group.js';
|
|
25
24
|
export { OnMiddleware, onMiddleware } from './app/event-middleware.js';
|
|
@@ -36,16 +35,17 @@ export { loadChildren, loadChildrenFile } from './app/load.js';
|
|
|
36
35
|
export { createDataFormat, createEventValue, format, sendToChannel, sendToUser } from './app/message-api.js';
|
|
37
36
|
export { Ark, BT, Image, ImageFile, ImageURL, Link, MD, Mention, Text } from './app/message-format.js';
|
|
38
37
|
export { ChildrenApp, Core, Logger, Middleware, ProcessorEventAutoClearMap, ProcessorEventUserAudoClearMap, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
38
|
+
export { ResultCode } from './core/variable.js';
|
|
39
|
+
export { ConfigCore, getConfig, getConfigValue } from './core/config.js';
|
|
39
40
|
export { Result, createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './core/utils.js';
|
|
40
41
|
export { cbpClient } from './cbp/client.js';
|
|
41
42
|
export { cbpServer } from './cbp/server.js';
|
|
42
43
|
export { cbpPlatform } from './cbp/platform.js';
|
|
43
44
|
export { run, start } from './main.js';
|
|
44
|
-
export {
|
|
45
|
-
export {
|
|
46
|
-
export {
|
|
47
|
-
export {
|
|
48
|
-
export {
|
|
49
|
-
export {
|
|
50
|
-
export {
|
|
51
|
-
export { DataMarkDown, DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownCode, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle } from './typing/message/markdown.js';
|
|
45
|
+
export { DataText } from './types/message/text.js';
|
|
46
|
+
export { DataLink } from './types/message/link.js';
|
|
47
|
+
export { DataMention } from './types/message/mention.js';
|
|
48
|
+
export { DataImage, DataImageFile, DataImageURL } from './types/message/image.js';
|
|
49
|
+
export { ButtonRow, DataButton, DataButtonGroup, DataButtonTemplate } from './types/message/button.js';
|
|
50
|
+
export { DataArkBigCard, DataArkCard, DataArkList, DataArkListContent, DataArkListItem, DataArkListTip } from './types/message/ark.js';
|
|
51
|
+
export { DataMarkDown, DataMarkdownBlockquote, DataMarkdownBold, DataMarkdownCode, DataMarkdownDivider, DataMarkdownImage, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownLink, DataMarkdownList, DataMarkdownListItem, DataMarkdownNewline, DataMarkdownStrikethrough, DataMarkdownSubtitle, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle } from './types/message/markdown.js';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { ActionsEventEnum } from './
|
|
1
|
+
export { ActionsEventEnum } from './types/event/actions.js';
|
|
2
2
|
export { core, logger } from './global.js';
|
|
3
|
-
export { ConfigCore, getConfig, getConfigValue } from './core/config.js';
|
|
4
3
|
export { defineChildren } from './app/define-chidren.js';
|
|
5
4
|
export { onGroup } from './app/event-group.js';
|
|
6
5
|
export { OnMiddleware, onMiddleware } from './app/event-middleware.js';
|
|
@@ -17,9 +16,10 @@ export { loadChildren, loadChildrenFile } from './app/load.js';
|
|
|
17
16
|
export { createDataFormat, createEventValue, format, sendToChannel, sendToUser } from './app/message-api.js';
|
|
18
17
|
export { Ark, BT, Image, ImageFile, ImageURL, Link, MD, Mention, Text } from './app/message-format.js';
|
|
19
18
|
export { ChildrenApp, Core, Logger, Middleware, ProcessorEventAutoClearMap, ProcessorEventUserAudoClearMap, Response, State, StateSubscribe, SubscribeList } from './app/store.js';
|
|
19
|
+
export { ResultCode } from './core/variable.js';
|
|
20
|
+
export { ConfigCore, getConfig, getConfigValue } from './core/config.js';
|
|
20
21
|
export { createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey } from './core/utils.js';
|
|
21
22
|
export { cbpClient } from './cbp/client.js';
|
|
22
23
|
export { cbpServer } from './cbp/server.js';
|
|
23
24
|
export { cbpPlatform } from './cbp/platform.js';
|
|
24
25
|
export { run, start } from './main.js';
|
|
25
|
-
export { ResultCode } from './core/code.js';
|
package/lib/main.js
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { getConfig, getConfigValue } from './core/config.js';
|
|
2
2
|
import { loadChildren, loadChildrenFile } from './app/load.js';
|
|
3
3
|
import { getInputExportPath } from './core/utils.js';
|
|
4
|
-
import './app/define-chidren.js';
|
|
5
|
-
import './app/event-group.js';
|
|
6
|
-
import './app/event-middleware.js';
|
|
7
|
-
import './app/event-processor.js';
|
|
8
|
-
import './app/event-response.js';
|
|
9
|
-
import { ResultCode } from './core/code.js';
|
|
10
|
-
import 'util/types';
|
|
11
|
-
import { useState } from './app/hook-use-state.js';
|
|
12
|
-
import 'node:fs';
|
|
13
|
-
import 'log4js';
|
|
14
|
-
import './app/hook-use-api.js';
|
|
15
|
-
import { default_port, file_prefix_common, default_platform_common_prefix } from './core/variable.js';
|
|
16
|
-
import './app/message-api.js';
|
|
17
|
-
import './app/message-format.js';
|
|
18
|
-
import { cbpClient } from './cbp/client.js';
|
|
19
|
-
import { cbpServer } from './cbp/server.js';
|
|
20
|
-
import 'ws';
|
|
21
|
-
import './cbp/config.js';
|
|
22
|
-
import 'flatted';
|
|
23
4
|
import { join } from 'path';
|
|
24
5
|
import { existsSync } from 'fs';
|
|
6
|
+
import { cbpServer } from './cbp/server.js';
|
|
7
|
+
import { ResultCode, defaultPort, filePrefixCommon, defaultPlatformCommonPrefix } from './core/variable.js';
|
|
8
|
+
import { cbpClient } from './cbp/client.js';
|
|
9
|
+
import { startAdapterWithFallback } from './adapter.js';
|
|
10
|
+
import { useState } from './app/hook-use-state.js';
|
|
25
11
|
|
|
26
12
|
const loadState = () => {
|
|
27
13
|
const value = getConfigValue() ?? {};
|
|
@@ -69,7 +55,7 @@ const start = (options = {}) => {
|
|
|
69
55
|
// 注入配置。
|
|
70
56
|
loadState();
|
|
71
57
|
const cfg = getConfig();
|
|
72
|
-
const url = options?.url
|
|
58
|
+
const url = options?.url ?? cfg.argv?.url ?? cfg.value?.url;
|
|
73
59
|
// 连接到 CBP 服务器
|
|
74
60
|
if (url) {
|
|
75
61
|
logger.info(`[Connecting to CBP server at ${url}]`);
|
|
@@ -77,7 +63,7 @@ const start = (options = {}) => {
|
|
|
77
63
|
}
|
|
78
64
|
else {
|
|
79
65
|
// 创建 cbp 服务器
|
|
80
|
-
const port = options?.port ?? cfg.argv?.port ?? cfg.value?.port ??
|
|
66
|
+
const port = options?.port ?? cfg.argv?.port ?? cfg.value?.port ?? defaultPort;
|
|
81
67
|
// 设置环境变量
|
|
82
68
|
process.env.port = port;
|
|
83
69
|
cbpServer(port, () => {
|
|
@@ -85,11 +71,11 @@ const start = (options = {}) => {
|
|
|
85
71
|
const wsURL = `ws://127.0.0.1:${port}`;
|
|
86
72
|
logger.info(`[CBP server started at ${httpURL}]`);
|
|
87
73
|
logger.info(`[CBP server started at ${wsURL}]`);
|
|
88
|
-
const isFullReceive = options?.is_full_receive
|
|
74
|
+
const isFullReceive = options?.is_full_receive ?? cfg.argv?.is_full_receive ?? cfg.value?.is_full_receive ?? true;
|
|
89
75
|
cbpClient(httpURL, { isFullReceive });
|
|
90
76
|
// 加载平台服务
|
|
91
|
-
const platform = options?.platform
|
|
92
|
-
const login = options?.login
|
|
77
|
+
const platform = options?.platform ?? cfg.argv?.platform ?? cfg.value?.platform;
|
|
78
|
+
const login = options?.login ?? cfg.argv?.login ?? cfg.value?.login;
|
|
93
79
|
// 不登录平台
|
|
94
80
|
if (!platform && !login) {
|
|
95
81
|
// 没有指定平台和登录名,则启动 sandbox 模式
|
|
@@ -98,7 +84,7 @@ const start = (options = {}) => {
|
|
|
98
84
|
}
|
|
99
85
|
// 如果存在
|
|
100
86
|
if (platform) {
|
|
101
|
-
const reg =
|
|
87
|
+
const reg = filePrefixCommon;
|
|
102
88
|
if (reg.test(platform)) {
|
|
103
89
|
process.env.platform = platform;
|
|
104
90
|
// 剪切
|
|
@@ -112,18 +98,18 @@ const start = (options = {}) => {
|
|
|
112
98
|
}
|
|
113
99
|
else {
|
|
114
100
|
// 如果没有指定平台,则使用登录名作为平台
|
|
115
|
-
process.env.platform = `${
|
|
101
|
+
process.env.platform = `${defaultPlatformCommonPrefix}${login}`;
|
|
116
102
|
process.env.login = login;
|
|
117
103
|
}
|
|
118
104
|
// 设置了 login。强制指定
|
|
119
105
|
if (login) {
|
|
120
106
|
process.env.login = login;
|
|
121
107
|
}
|
|
122
|
-
|
|
108
|
+
startAdapterWithFallback();
|
|
123
109
|
});
|
|
124
110
|
}
|
|
125
111
|
// 获取入口文件
|
|
126
|
-
const input = options.input
|
|
112
|
+
const input = options.input ?? cfg.argv?.input ?? cfg.value?.input ?? getInputExportPath();
|
|
127
113
|
process.env.input = input;
|
|
128
114
|
// 运行本地模块
|
|
129
115
|
run(input);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DataEnums } from './message/index.js';
|
|
2
|
+
|
|
3
|
+
type ActionMessageSend = {
|
|
4
|
+
action: 'message.send';
|
|
5
|
+
payload: {
|
|
6
|
+
event: any;
|
|
7
|
+
params: {
|
|
8
|
+
format?: DataEnums[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type ActionMessageSendChannel = {
|
|
13
|
+
action: 'message.send.channel';
|
|
14
|
+
payload: {
|
|
15
|
+
ChannelId: string;
|
|
16
|
+
params: {
|
|
17
|
+
format?: DataEnums[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type ActionMessageSendUser = {
|
|
22
|
+
action: 'message.send.user';
|
|
23
|
+
payload: {
|
|
24
|
+
UserId: string;
|
|
25
|
+
params: {
|
|
26
|
+
format?: DataEnums[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type ActionMentionGet = {
|
|
31
|
+
action: 'mention.get';
|
|
32
|
+
payload: {
|
|
33
|
+
event: any;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
type ActionMessageDelete = {
|
|
37
|
+
action: 'message.delete';
|
|
38
|
+
payload: {
|
|
39
|
+
MessageId: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type ActionFileSendChannel = {
|
|
43
|
+
action: 'file.send.channel';
|
|
44
|
+
payload: {
|
|
45
|
+
ChannelId: string;
|
|
46
|
+
params: {
|
|
47
|
+
file: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
folder?: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type ActionFileSendUser = {
|
|
54
|
+
action: 'file.send.user';
|
|
55
|
+
payload: {
|
|
56
|
+
UserId: string;
|
|
57
|
+
params: {
|
|
58
|
+
file: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
type ActionMessageForwardUser = {
|
|
64
|
+
action: 'message.forward.user';
|
|
65
|
+
payload: {
|
|
66
|
+
UserId: string;
|
|
67
|
+
params: {
|
|
68
|
+
time?: number;
|
|
69
|
+
content: DataEnums[];
|
|
70
|
+
user_id?: string;
|
|
71
|
+
nickname?: string;
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
type ActionMessageForwardChannel = {
|
|
76
|
+
action: 'message.forward.channel';
|
|
77
|
+
payload: {
|
|
78
|
+
ChannelId: string;
|
|
79
|
+
params: {
|
|
80
|
+
time?: number;
|
|
81
|
+
content: DataEnums[];
|
|
82
|
+
user_id?: string;
|
|
83
|
+
nickname?: string;
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
type base = {
|
|
88
|
+
actionId?: string;
|
|
89
|
+
DeviceId?: string;
|
|
90
|
+
};
|
|
91
|
+
type Actions = (ActionMessageSend | ActionMentionGet | ActionMessageSendChannel | ActionMessageSendUser | ActionMessageDelete | ActionFileSendChannel | ActionFileSendUser | ActionMessageForwardUser | ActionMessageForwardChannel) & base;
|
|
92
|
+
|
|
93
|
+
export type { ActionFileSendChannel, ActionFileSendUser, ActionMentionGet, ActionMessageDelete, ActionMessageForwardChannel, ActionMessageForwardUser, ActionMessageSend, ActionMessageSendChannel, ActionMessageSendUser, Actions };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Result } from '../../core/utils.js';
|
|
2
|
+
import { User } from '../event/base/user.js';
|
|
3
|
+
import { EventKeys, Events } from '../event/map.js';
|
|
4
|
+
import { DataEnums } from '../message/index.js';
|
|
5
|
+
|
|
6
|
+
type ClientAPIMessageResult = Result & {
|
|
7
|
+
data: {
|
|
8
|
+
id: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type ClientAPI = {
|
|
13
|
+
/**
|
|
14
|
+
* alemonjs接口
|
|
15
|
+
*/
|
|
16
|
+
api: {
|
|
17
|
+
/**
|
|
18
|
+
* hook
|
|
19
|
+
*/
|
|
20
|
+
use: {
|
|
21
|
+
/**
|
|
22
|
+
* 发送消息
|
|
23
|
+
* @param event
|
|
24
|
+
* @param val
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
send: <T extends EventKeys>(event: Events[T], val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
28
|
+
/**
|
|
29
|
+
* 获取提及信息
|
|
30
|
+
* @param event
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
mention: <T extends EventKeys>(event: Events[T]) => Promise<User[]>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 主动接口
|
|
37
|
+
*/
|
|
38
|
+
active: {
|
|
39
|
+
/**
|
|
40
|
+
* 发送消息
|
|
41
|
+
*/
|
|
42
|
+
send: {
|
|
43
|
+
/**
|
|
44
|
+
* 向指定频道发送消息
|
|
45
|
+
* @param channel_id
|
|
46
|
+
* @param data
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
channel: (channel_id: string, data: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
50
|
+
/**
|
|
51
|
+
* 向指定用户发送消息
|
|
52
|
+
* @param user_id
|
|
53
|
+
* @param data
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
user: (user_id: string, data: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* 平台
|
|
62
|
+
*/
|
|
63
|
+
platform: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type { ClientAPI, ClientAPIMessageResult };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StoreResponseItem, StoreMiddlewareItem } from '../store/res.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 子模块生命周期
|
|
5
|
+
*/
|
|
6
|
+
type ChildrenCycle = {
|
|
7
|
+
/**
|
|
8
|
+
* 创建时
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
onCreated?: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* 挂载时。得到属于自己的 store
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
onMounted?: (strore: {
|
|
17
|
+
response: StoreResponseItem[];
|
|
18
|
+
middleware: StoreMiddlewareItem[];
|
|
19
|
+
}) => void;
|
|
20
|
+
/**
|
|
21
|
+
* 卸载时
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
unMounted?: (error: any) => void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 控制生命周期
|
|
28
|
+
* ***
|
|
29
|
+
* next() 在同一个周期中继续
|
|
30
|
+
* ***
|
|
31
|
+
* next(true) 在下一个周期中继续
|
|
32
|
+
* ***
|
|
33
|
+
* next(true,true) 在下下个周期中继续
|
|
34
|
+
* 以此类推。。。
|
|
35
|
+
*/
|
|
36
|
+
type Next = (...cns: boolean[]) => void;
|
|
37
|
+
/**
|
|
38
|
+
* 事件周期
|
|
39
|
+
*/
|
|
40
|
+
type EventCycleEnum = 'create' | 'mount' | 'unmount';
|
|
41
|
+
|
|
42
|
+
export type { ChildrenCycle, EventCycleEnum, Next };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare enum ActionsEventEnum {
|
|
2
|
+
MessageRecall = "message.recall",
|
|
3
|
+
MessageDelete = "message.delete",
|
|
4
|
+
MessageCreate = "message.create",
|
|
5
|
+
MessageEdit = "message.edit",
|
|
6
|
+
MessageList = "message.list",
|
|
7
|
+
MessageTop = "message.top",
|
|
8
|
+
MessageUntop = "message.untop",
|
|
9
|
+
MessageLike = "message.like",
|
|
10
|
+
MessageUnlike = "message.unlike",
|
|
11
|
+
GuildCreate = "guild.create",
|
|
12
|
+
GuildDelete = "guild.delete",
|
|
13
|
+
GuildEdit = "guild.edit",
|
|
14
|
+
GuildQuit = "guild.quit",
|
|
15
|
+
GuildJoin = "guild.join",
|
|
16
|
+
MemberList = "member.list",
|
|
17
|
+
MemberAdd = "member.add",
|
|
18
|
+
MemberDelete = "member.delete",
|
|
19
|
+
MemberEdit = "member.edit",
|
|
20
|
+
RoleAdd = "role.add",
|
|
21
|
+
RoleDelete = "role.delete",
|
|
22
|
+
RoleEdit = "role.edit",
|
|
23
|
+
RoleList = "role.list",
|
|
24
|
+
ChannelCreate = "channel.create",
|
|
25
|
+
ChannelDelete = "channel.delete",
|
|
26
|
+
ChannelEdit = "channel.edit",
|
|
27
|
+
ChannelList = "channel.list",
|
|
28
|
+
CategoryCreate = "category.create",
|
|
29
|
+
CategoryDelete = "category.delete",
|
|
30
|
+
CategoryEdit = "category.edit",
|
|
31
|
+
CategoryList = "category.list",
|
|
32
|
+
MemberKickOut = "member.kickOut",
|
|
33
|
+
MemberBan = "member.ban",
|
|
34
|
+
MemberUnban = "member.unban"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { ActionsEventEnum };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// 定义事件枚举
|
|
2
|
+
var ActionsEventEnum;
|
|
3
|
+
(function (ActionsEventEnum) {
|
|
4
|
+
// 消息撤回
|
|
5
|
+
ActionsEventEnum["MessageRecall"] = "message.recall";
|
|
6
|
+
// 消息删除
|
|
7
|
+
ActionsEventEnum["MessageDelete"] = "message.delete";
|
|
8
|
+
// 消息创建(普通、引用、转发)
|
|
9
|
+
ActionsEventEnum["MessageCreate"] = "message.create";
|
|
10
|
+
// 消息编辑
|
|
11
|
+
ActionsEventEnum["MessageEdit"] = "message.edit";
|
|
12
|
+
// 消息列表
|
|
13
|
+
ActionsEventEnum["MessageList"] = "message.list";
|
|
14
|
+
// 消息置顶
|
|
15
|
+
ActionsEventEnum["MessageTop"] = "message.top";
|
|
16
|
+
// 消息取消置顶
|
|
17
|
+
ActionsEventEnum["MessageUntop"] = "message.untop";
|
|
18
|
+
// 消息点赞
|
|
19
|
+
ActionsEventEnum["MessageLike"] = "message.like";
|
|
20
|
+
// 消息取消点赞
|
|
21
|
+
ActionsEventEnum["MessageUnlike"] = "message.unlike";
|
|
22
|
+
// 服务器创建
|
|
23
|
+
ActionsEventEnum["GuildCreate"] = "guild.create";
|
|
24
|
+
// 服务器删除
|
|
25
|
+
ActionsEventEnum["GuildDelete"] = "guild.delete";
|
|
26
|
+
// 服务器编辑
|
|
27
|
+
ActionsEventEnum["GuildEdit"] = "guild.edit";
|
|
28
|
+
// 服务器退出
|
|
29
|
+
ActionsEventEnum["GuildQuit"] = "guild.quit";
|
|
30
|
+
// 服务器加入
|
|
31
|
+
ActionsEventEnum["GuildJoin"] = "guild.join";
|
|
32
|
+
// 成员列表
|
|
33
|
+
ActionsEventEnum["MemberList"] = "member.list";
|
|
34
|
+
// 成员添加
|
|
35
|
+
ActionsEventEnum["MemberAdd"] = "member.add";
|
|
36
|
+
// 成员删除
|
|
37
|
+
ActionsEventEnum["MemberDelete"] = "member.delete";
|
|
38
|
+
// 成员编辑
|
|
39
|
+
ActionsEventEnum["MemberEdit"] = "member.edit";
|
|
40
|
+
// 角色添加
|
|
41
|
+
ActionsEventEnum["RoleAdd"] = "role.add";
|
|
42
|
+
// 角色删除
|
|
43
|
+
ActionsEventEnum["RoleDelete"] = "role.delete";
|
|
44
|
+
// 角色编辑
|
|
45
|
+
ActionsEventEnum["RoleEdit"] = "role.edit";
|
|
46
|
+
// 角色列表
|
|
47
|
+
ActionsEventEnum["RoleList"] = "role.list";
|
|
48
|
+
// 频道创建
|
|
49
|
+
ActionsEventEnum["ChannelCreate"] = "channel.create";
|
|
50
|
+
// 频道删除
|
|
51
|
+
ActionsEventEnum["ChannelDelete"] = "channel.delete";
|
|
52
|
+
// 频道编辑
|
|
53
|
+
ActionsEventEnum["ChannelEdit"] = "channel.edit";
|
|
54
|
+
// 频道列表
|
|
55
|
+
ActionsEventEnum["ChannelList"] = "channel.list";
|
|
56
|
+
// 分类创建
|
|
57
|
+
ActionsEventEnum["CategoryCreate"] = "category.create";
|
|
58
|
+
// 分类删除
|
|
59
|
+
ActionsEventEnum["CategoryDelete"] = "category.delete";
|
|
60
|
+
// 分类编辑
|
|
61
|
+
ActionsEventEnum["CategoryEdit"] = "category.edit";
|
|
62
|
+
// 分类列表
|
|
63
|
+
ActionsEventEnum["CategoryList"] = "category.list";
|
|
64
|
+
// 成员踢出
|
|
65
|
+
ActionsEventEnum["MemberKickOut"] = "member.kickOut";
|
|
66
|
+
// 成员封禁
|
|
67
|
+
ActionsEventEnum["MemberBan"] = "member.ban";
|
|
68
|
+
// 成员解封
|
|
69
|
+
ActionsEventEnum["MemberUnban"] = "member.unban";
|
|
70
|
+
})(ActionsEventEnum || (ActionsEventEnum = {}));
|
|
71
|
+
|
|
72
|
+
export { ActionsEventEnum };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type Message = {
|
|
2
|
+
/**
|
|
3
|
+
* 消息编号
|
|
4
|
+
*/
|
|
5
|
+
MessageId: string;
|
|
6
|
+
/**
|
|
7
|
+
* 创建时间
|
|
8
|
+
*/
|
|
9
|
+
CreateAt: number;
|
|
10
|
+
/**
|
|
11
|
+
* 来源设备编号
|
|
12
|
+
*/
|
|
13
|
+
DeviceId?: string;
|
|
14
|
+
};
|
|
15
|
+
type MessageText = {
|
|
16
|
+
/**
|
|
17
|
+
* 消息文本
|
|
18
|
+
*/
|
|
19
|
+
MessageText: string;
|
|
20
|
+
};
|
|
21
|
+
type MessageOpen = {
|
|
22
|
+
/**
|
|
23
|
+
* 开放编号
|
|
24
|
+
*/
|
|
25
|
+
OpenId: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type { Message, MessageOpen, MessageText };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type User = {
|
|
2
|
+
/**
|
|
3
|
+
* 用户编号
|
|
4
|
+
*/
|
|
5
|
+
UserId: string;
|
|
6
|
+
/**
|
|
7
|
+
* user unique id key
|
|
8
|
+
* 使用`${Platform}:${UserId}`哈希所得
|
|
9
|
+
* 统一长度
|
|
10
|
+
*/
|
|
11
|
+
UserKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* 用户名
|
|
14
|
+
*/
|
|
15
|
+
UserName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 用户头像地址
|
|
18
|
+
* https://
|
|
19
|
+
* http://
|
|
20
|
+
* base64://
|
|
21
|
+
* file://
|
|
22
|
+
*/
|
|
23
|
+
UserAvatar?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 是否是主人
|
|
26
|
+
*/
|
|
27
|
+
IsMaster: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 是否是机器人
|
|
30
|
+
*/
|
|
31
|
+
IsBot: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type { User };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Guild, Channel } from '../base/guild.js';
|
|
2
|
+
import { platform } from '../base/platform.js';
|
|
3
|
+
import { Message } from '../base/message.js';
|
|
4
|
+
import { Expansion } from '../base/expansion.js';
|
|
5
|
+
|
|
6
|
+
type PublicEventChannalCreate = platform & Guild & Channel & Message & {
|
|
7
|
+
name: 'channal.create';
|
|
8
|
+
} & Expansion;
|
|
9
|
+
type PublicEventChannalDelete = platform & Guild & Channel & Message & {
|
|
10
|
+
name: 'channal.delete';
|
|
11
|
+
} & Expansion;
|
|
12
|
+
|
|
13
|
+
export type { PublicEventChannalCreate, PublicEventChannalDelete };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Expansion } from '../base/expansion.js';
|
|
2
|
+
import { Guild } from '../base/guild.js';
|
|
3
|
+
import { Message } from '../base/message.js';
|
|
4
|
+
import { platform } from '../base/platform.js';
|
|
5
|
+
|
|
6
|
+
type PublicEventGuildJoin = platform & Guild & Message & {
|
|
7
|
+
name: 'guild.join';
|
|
8
|
+
} & Expansion;
|
|
9
|
+
type PublicEventGuildExit = platform & Guild & Message & {
|
|
10
|
+
name: 'guild.exit';
|
|
11
|
+
} & Expansion;
|
|
12
|
+
|
|
13
|
+
export type { PublicEventGuildExit, PublicEventGuildJoin };
|