alemonjs 2.0.8 → 2.0.10
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 +16 -16
- package/lib/app/config.js +8 -0
- package/lib/app/event-middleware.js +1 -1
- package/lib/app/event-processor-cycle.js +1 -1
- package/lib/app/event-processor-event.js +2 -1
- package/lib/app/event-processor-middleware.js +2 -1
- package/lib/app/message-format.d.ts +1 -1
- package/lib/app/utils.d.ts +2 -1
- package/lib/code.d.ts +1 -1
- package/lib/jsx.d.ts +2 -2
- package/lib/typing/event/interaction/index.d.ts +13 -0
- package/lib/typing/event/map.d.ts +7 -3
- package/lib/typing/event/message/message.d.ts +1 -1
- package/lib/typing/event/message/private.message.d.ts +1 -1
- package/lib/typing/message/index.d.ts +2 -1
- package/package.json +1 -1
- package/lib/app/code.d.ts +0 -22
- package/lib/app/code.js +0 -32
- package/tsconfig.json +0 -7
package/README.md
CHANGED
|
@@ -8,26 +8,26 @@ yarn add alemonjs @alemonjs/gui -W
|
|
|
8
8
|
|
|
9
9
|
- 启动
|
|
10
10
|
|
|
11
|
-
> src/index.
|
|
11
|
+
> src/index.js
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```js
|
|
14
14
|
import { start } from 'alemonjs'
|
|
15
|
-
start('src/index.
|
|
15
|
+
start('src/index.js')
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
- 响应
|
|
19
19
|
|
|
20
|
-
> src/
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
import { Text, useSend } from 'alemonjs'
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
> src/response/res.js
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { createSelects, onResponse, Text, useSend } from 'alemonjs'
|
|
24
|
+
// 创建事件类型
|
|
25
|
+
export const selects = createSelects(['message.create'])
|
|
26
|
+
// 导出响应
|
|
27
|
+
export default onResponse(selects, event => {
|
|
28
|
+
// 使用发送函数
|
|
29
|
+
const send = useSend(event)
|
|
30
|
+
// 发送文本
|
|
31
|
+
send(Text('Hello Word!'))
|
|
32
|
+
})
|
|
31
33
|
```
|
|
32
|
-
|
|
33
|
-
[配置编辑器](./bin/README.md)
|
|
@@ -39,7 +39,7 @@ const OnMiddleware = (callback, select) => {
|
|
|
39
39
|
message: 'OnMiddleware is deprecated, please use onMiddleware',
|
|
40
40
|
data: null
|
|
41
41
|
});
|
|
42
|
-
return
|
|
42
|
+
return { select, current: callback };
|
|
43
43
|
};
|
|
44
44
|
global.OnMiddleware = OnMiddleware;
|
|
45
45
|
|
|
@@ -10,7 +10,7 @@ import { expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } f
|
|
|
10
10
|
*/
|
|
11
11
|
const showLog = (event, select) => {
|
|
12
12
|
const log = {
|
|
13
|
-
|
|
13
|
+
Name: select
|
|
14
14
|
};
|
|
15
15
|
if (typeof event['ChannelId'] == 'string' && event['ChannelId'] != '') {
|
|
16
16
|
log['ChannelId'] = event['ChannelId'];
|
|
@@ -3,6 +3,7 @@ import { useState } from './hook-use-state.js';
|
|
|
3
3
|
import { showErrorModule } from './utils.js';
|
|
4
4
|
import { Response } from './store.js';
|
|
5
5
|
import { useSend } from './hook-use-api.js';
|
|
6
|
+
import { EventMessageText } from './config.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @fileoverview 消息处理快
|
|
@@ -98,7 +99,7 @@ const expendEvent = async (valueEvent, select, next) => {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
// 消息类型数据
|
|
101
|
-
if (
|
|
102
|
+
if (EventMessageText.includes(select)) {
|
|
102
103
|
if (app?.regular) {
|
|
103
104
|
const reg = new RegExp(app.regular);
|
|
104
105
|
if (!reg.test(valueEvent['MessageText'])) {
|
|
@@ -3,6 +3,7 @@ import { useState } from './hook-use-state.js';
|
|
|
3
3
|
import { showErrorModule } from './utils.js';
|
|
4
4
|
import { Middleware } from './store.js';
|
|
5
5
|
import { useSend } from './hook-use-api.js';
|
|
6
|
+
import { EventMessageText } from './config.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @fileoverview 消息处理快
|
|
@@ -79,7 +80,7 @@ const expendMiddleware = async (valueEvent, select, next) => {
|
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
if (
|
|
83
|
+
if (EventMessageText.includes(select)) {
|
|
83
84
|
if (app?.regular) {
|
|
84
85
|
const reg = new RegExp(app.regular);
|
|
85
86
|
if (!reg.test(valueEvent['MessageText'])) {
|
|
@@ -2,7 +2,7 @@ import '../global.js';
|
|
|
2
2
|
import { DataButton, ButtonRow, DataButtonGroup } from '../typing/message/button.js';
|
|
3
3
|
import { DataArkListTip, DataArkListContent, DataArkList, DataArkListItem, DataArkCard, DataArkBigCard } from '../typing/message/ark.js';
|
|
4
4
|
import { DataMarkDown, DataMarkdownTemplate, DataMarkdownText, DataMarkdownTitle, DataMarkdownSubtitle, DataMarkdownBold, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownStrikethrough, DataMarkdownLink, DataMarkdownImage, DataMarkdownList, DataMarkdownListItem, DataMarkdownBlockquote, DataMarkdownDivider, DataMarkdownNewline } from '../typing/message/markdown.js';
|
|
5
|
-
import { DataImageURL, DataImageFile
|
|
5
|
+
import { DataImage, DataImageURL, DataImageFile } from '../typing/message/image.js';
|
|
6
6
|
import { DataText } from '../typing/message/text.js';
|
|
7
7
|
import { DataMention } from '../typing/message/mention.js';
|
|
8
8
|
import { DataLink } from '../typing/message/link.js';
|
package/lib/app/utils.d.ts
CHANGED
|
@@ -78,4 +78,5 @@ type Result = {
|
|
|
78
78
|
*/
|
|
79
79
|
declare const createResult: (code: ResultCode, message: string | Object, data?: any) => Result;
|
|
80
80
|
|
|
81
|
-
export { ErrorModule,
|
|
81
|
+
export { ErrorModule, createEventName, createHash, createResult, getInputExportPath, getRecursiveDirFiles, showErrorModule, stringToNumber, useUserHashKey };
|
|
82
|
+
export type { Result };
|
package/lib/code.d.ts
CHANGED
package/lib/jsx.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { ClientAPIMessageResult } from './typing/client/index.js';
|
|
|
3
3
|
import { DataEnums } from './typing/message/index.js';
|
|
4
4
|
import { Result } from './app/utils.js';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { DataText } from './typing/message/text.js';
|
|
7
6
|
import { DataImage, DataImageURL, DataImageFile } from './typing/message/image.js';
|
|
8
|
-
import { DataMention } from './typing/message/mention.js';
|
|
9
7
|
import { DataButton } from './typing/message/button.js';
|
|
8
|
+
import { DataText } from './typing/message/text.js';
|
|
9
|
+
import { DataMention } from './typing/message/mention.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Guild, Channel } from '../base/guild.js';
|
|
2
|
+
import { MessageText, MessageOpen, Message } from '../base/message.js';
|
|
3
|
+
import { User } from '../base/user.js';
|
|
4
|
+
import { platform } from '../base/platform.js';
|
|
5
|
+
|
|
6
|
+
type PrivateEventInteractionCreate = MessageText & MessageOpen & platform & Message & User & {
|
|
7
|
+
name: 'private.interaction.create';
|
|
8
|
+
};
|
|
9
|
+
type PublicEventInteractionCreate = MessageText & MessageOpen & platform & Guild & Channel & Message & User & {
|
|
10
|
+
name: 'interaction.create';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type { PrivateEventInteractionCreate, PublicEventInteractionCreate };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { PublicEventChannalCreate, PublicEventChannalDelete } from './channal/index.js';
|
|
2
2
|
import { PublicEventGuildJoin, PublicEventGuildExit } from './guild/index.js';
|
|
3
|
+
import { PublicEventInteractionCreate, PrivateEventInteractionCreate } from './interaction/index.js';
|
|
3
4
|
import { PublicEventMemberAdd, PublicEventMemberRemove } from './member/index.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { PublicEventMessageUpdate, PublicEventMessageDelete, PublicEventMessageReactionAdd, PublicEventMessageReactionRemove, PublicEventMessageCreate } from './message/message.js';
|
|
6
|
+
import { PrivateEventMessageUpdate, PrivateEventMessageDelete, PrivateEventMessageCreate } from './message/private.message.js';
|
|
6
7
|
import { PrivateEventRequestFriendAdd, PrivateEventRequestGuildAdd } from './request/index.js';
|
|
7
8
|
|
|
8
9
|
type EventsMessageCreate = {
|
|
9
10
|
'message.create': PublicEventMessageCreate;
|
|
10
11
|
'private.message.create': PrivateEventMessageCreate;
|
|
12
|
+
'interaction.create': PublicEventInteractionCreate;
|
|
13
|
+
'private.interaction.create': PrivateEventInteractionCreate;
|
|
11
14
|
};
|
|
12
15
|
type EventsMessageCreateKeys = keyof EventsMessageCreate;
|
|
13
16
|
type EventsMessageCreateEnum = Events[EventsMessageCreateKeys];
|
|
@@ -31,4 +34,5 @@ type EventKeys = keyof Events;
|
|
|
31
34
|
type EventsEnum = Events[EventKeys];
|
|
32
35
|
declare const EventsKeyEnum: EventKeys[];
|
|
33
36
|
|
|
34
|
-
export {
|
|
37
|
+
export { EventsKeyEnum };
|
|
38
|
+
export type { EventKeys, Events, EventsEnum, EventsMessageCreate, EventsMessageCreateEnum, EventsMessageCreateKeys };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Guild, Channel } from '../base/guild.js';
|
|
2
|
-
import { MessageText, MessageOpen
|
|
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
5
|
|
|
@@ -12,4 +12,5 @@ import { DataLink } from './link.js';
|
|
|
12
12
|
type DataEnums = DataText | DataLink | DataImage | DataImageURL | DataImageFile | DataMention | DataButtonGroup | DataArkList | DataArkCard | DataArkBigCard | DataMarkDown | DataMarkdownTemplate;
|
|
13
13
|
type MessageDataFormat = DataEnums[];
|
|
14
14
|
|
|
15
|
-
export { DataArkBigCard, DataArkCard, DataArkList, DataButtonGroup,
|
|
15
|
+
export { DataArkBigCard, DataArkCard, DataArkList, DataButtonGroup, DataImage, DataImageFile, DataImageURL, DataLink, DataMarkDown, DataMarkdownTemplate, DataMention, DataText };
|
|
16
|
+
export type { DataEnums, MessageDataFormat };
|
package/package.json
CHANGED
package/lib/app/code.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 结果反馈码
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* 结果反馈码
|
|
6
|
-
* @description
|
|
7
|
-
* - 2000: 成功
|
|
8
|
-
* - 4000: 未知错误
|
|
9
|
-
* - 4001: 参数错误
|
|
10
|
-
* - 4002: 权限不足
|
|
11
|
-
*/
|
|
12
|
-
declare const ResultCode: {
|
|
13
|
-
readonly Ok: 2000;
|
|
14
|
-
readonly Fail: 4000;
|
|
15
|
-
readonly FailParams: 4001;
|
|
16
|
-
readonly Warn: 2100;
|
|
17
|
-
readonly FailAuth: 4002;
|
|
18
|
-
readonly FailInternal: 5000;
|
|
19
|
-
};
|
|
20
|
-
type ResultCode = typeof ResultCode[keyof typeof ResultCode];
|
|
21
|
-
|
|
22
|
-
export { ResultCode };
|
package/lib/app/code.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 结果反馈码
|
|
3
|
-
*/
|
|
4
|
-
// 成功码
|
|
5
|
-
const Ok = 2000; // 成功
|
|
6
|
-
// 警惕码
|
|
7
|
-
const Warn = 2100; // 任意警告
|
|
8
|
-
// 失败码
|
|
9
|
-
const Fail = 4000; // 未知错误
|
|
10
|
-
const FailParams = 4001; // 参数错误
|
|
11
|
-
// 权限错误
|
|
12
|
-
const FailAuth = 4002; // 权限不足
|
|
13
|
-
// 内部错误
|
|
14
|
-
const FailInternal = 5000; // 内部错误
|
|
15
|
-
/**
|
|
16
|
-
* 结果反馈码
|
|
17
|
-
* @description
|
|
18
|
-
* - 2000: 成功
|
|
19
|
-
* - 4000: 未知错误
|
|
20
|
-
* - 4001: 参数错误
|
|
21
|
-
* - 4002: 权限不足
|
|
22
|
-
*/
|
|
23
|
-
const ResultCode = {
|
|
24
|
-
Ok,
|
|
25
|
-
Fail,
|
|
26
|
-
FailParams,
|
|
27
|
-
Warn,
|
|
28
|
-
FailAuth,
|
|
29
|
-
FailInternal
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { ResultCode };
|