alemonjs 2.1.53 → 2.1.55

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.
Files changed (98) hide show
  1. package/lib/app/define-router.d.ts +1 -0
  2. package/lib/app/define-router.js +6 -1
  3. package/lib/app/event-format.js +1 -1
  4. package/lib/app/event-processor-cycleFiles.js +2 -6
  5. package/lib/app/expose.d.ts +16 -0
  6. package/lib/app/expose.js +190 -0
  7. package/lib/app/index.d.ts +1 -0
  8. package/lib/app/index.js +2 -1
  9. package/lib/app/load_modules/loadChild.js +4 -0
  10. package/lib/app/store.d.ts +9 -9
  11. package/lib/app/store.js +2 -0
  12. package/lib/index.js +2 -1
  13. package/lib/types/event/index.d.ts +2 -0
  14. package/lib/types/expose/index.d.ts +41 -0
  15. package/lib/types/expose/index.js +1 -0
  16. package/lib/types/index.d.ts +1 -0
  17. package/package.json +1 -1
  18. package/lib/app/define/define-children.d.ts +0 -8
  19. package/lib/app/define/define-children.js +0 -25
  20. package/lib/app/define/define-middleware.d.ts +0 -2
  21. package/lib/app/define/define-middleware.js +0 -8
  22. package/lib/app/define/define-platform.d.ts +0 -13
  23. package/lib/app/define/define-platform.js +0 -40
  24. package/lib/app/define/define-response.d.ts +0 -2
  25. package/lib/app/define/define-response.js +0 -8
  26. package/lib/app/define/define-router.d.ts +0 -17
  27. package/lib/app/define/define-router.js +0 -34
  28. package/lib/app/event/event-group.d.ts +0 -9
  29. package/lib/app/event/event-group.js +0 -29
  30. package/lib/app/event/event-middleware.d.ts +0 -23
  31. package/lib/app/event/event-middleware.js +0 -44
  32. package/lib/app/event/event-response.d.ts +0 -16
  33. package/lib/app/event/event-response.js +0 -23
  34. package/lib/app/event/event-selects.d.ts +0 -13
  35. package/lib/app/event/event-selects.js +0 -15
  36. package/lib/app/event-processor/event-processor-callHandler.d.ts +0 -1
  37. package/lib/app/event-processor/event-processor-callHandler.js +0 -43
  38. package/lib/app/event-processor/event-processor-cycle.d.ts +0 -14
  39. package/lib/app/event-processor/event-processor-cycle.js +0 -97
  40. package/lib/app/event-processor/event-processor-cycleFiles.d.ts +0 -11
  41. package/lib/app/event-processor/event-processor-cycleFiles.js +0 -147
  42. package/lib/app/event-processor/event-processor-cycleRoute.d.ts +0 -10
  43. package/lib/app/event-processor/event-processor-cycleRoute.js +0 -133
  44. package/lib/app/event-processor/event-processor-event.d.ts +0 -24
  45. package/lib/app/event-processor/event-processor-event.js +0 -41
  46. package/lib/app/event-processor/event-processor-middleware.d.ts +0 -14
  47. package/lib/app/event-processor/event-processor-middleware.js +0 -31
  48. package/lib/app/event-processor/event-processor-subscribe.d.ts +0 -35
  49. package/lib/app/event-processor/event-processor-subscribe.js +0 -115
  50. package/lib/app/event-processor/event-processor.d.ts +0 -17
  51. package/lib/app/event-processor/event-processor.js +0 -207
  52. package/lib/app/hook-use/hook-use-api.d.ts +0 -6
  53. package/lib/app/hook-use/hook-use-api.js +0 -22
  54. package/lib/app/hook-use/hook-use-channel.d.ts +0 -8
  55. package/lib/app/hook-use/hook-use-channel.js +0 -33
  56. package/lib/app/hook-use/hook-use-client.d.ts +0 -7
  57. package/lib/app/hook-use/hook-use-client.js +0 -27
  58. package/lib/app/hook-use/hook-use-me.d.ts +0 -8
  59. package/lib/app/hook-use/hook-use-me.js +0 -45
  60. package/lib/app/hook-use/hook-use-menber.d.ts +0 -8
  61. package/lib/app/hook-use/hook-use-menber.js +0 -59
  62. package/lib/app/hook-use/hook-use-mention.d.ts +0 -23
  63. package/lib/app/hook-use/hook-use-mention.js +0 -105
  64. package/lib/app/hook-use/hook-use-message.d.ts +0 -29
  65. package/lib/app/hook-use/hook-use-message.js +0 -88
  66. package/lib/app/hook-use/hook-use-state.d.ts +0 -30
  67. package/lib/app/hook-use/hook-use-state.js +0 -101
  68. package/lib/app/hook-use/hook-use-subscribe.d.ts +0 -46
  69. package/lib/app/hook-use/hook-use-subscribe.js +0 -143
  70. package/lib/app/hook-use-api.d.ts +0 -268
  71. package/lib/app/hook-use-api.js +0 -1213
  72. package/lib/app/hook-use-state.d.ts +0 -3
  73. package/lib/app/hook-use-state.js +0 -68
  74. package/lib/app/hook-use-subscribe.d.ts +0 -73
  75. package/lib/app/hook-use-subscribe.js +0 -112
  76. package/lib/app/message/message-api.d.ts +0 -69
  77. package/lib/app/message/message-api.js +0 -105
  78. package/lib/app/message/message-format-old.d.ts +0 -143
  79. package/lib/app/message/message-format-old.js +0 -359
  80. package/lib/app/message/message-format.d.ts +0 -215
  81. package/lib/app/message/message-format.js +0 -382
  82. package/lib/app/message-controller.d.ts +0 -25
  83. package/lib/app/message-controller.js +0 -66
  84. package/lib/app/message-format.old.d.ts +0 -50
  85. package/lib/app/message-format.old.js +0 -217
  86. package/lib/cbp/processor/handle.d.ts +0 -3
  87. package/lib/cbp/processor/handle.js +0 -32
  88. package/lib/jsx/index.d.ts +0 -105
  89. package/lib/jsx/index.js +0 -211
  90. package/lib/jsx/jsx-dev-runtime.d.ts +0 -2
  91. package/lib/jsx/jsx-dev-runtime.js +0 -1
  92. package/lib/jsx/jsx-runtime.d.ts +0 -18
  93. package/lib/jsx/jsx-runtime.js +0 -24
  94. package/lib/process/client.js +0 -109
  95. package/lib/store/SinglyLinkedList.d.ts +0 -22
  96. package/lib/store/SinglyLinkedList.js +0 -97
  97. package/lib/store/store.d.ts +0 -127
  98. package/lib/store/store.js +0 -443
@@ -1,31 +0,0 @@
1
- import { Middleware, MiddlewareRouter } from '../../store/store.js';
2
- import { createCallHandler } from './event-processor-callHandler.js';
3
- import { createNextStep } from './event-processor-cycleFiles.js';
4
- import { createRouteProcessChildren } from './event-processor-cycleRoute.js';
5
-
6
- // 单例,避免每次事件处理都创建新对象
7
- const middlewareSingleton = new Middleware();
8
- const middlewareRouterSingleton = new MiddlewareRouter();
9
- /**
10
- * 处理中间件
11
- * @param event
12
- * @param select
13
- */
14
- const expendMiddleware = (valueEvent, select, next) => {
15
- // 所有中间件(文件)
16
- const mwFiles = middlewareSingleton.value;
17
- // 创建处理函数(文件)
18
- const callHandler = createCallHandler(valueEvent);
19
- // 创建 next 处理函数(文件)
20
- const nextMiddleware = createNextStep(valueEvent, select, next, mwFiles, callHandler);
21
- // 所有中间件(路由)
22
- const routes = middlewareRouterSingleton.value;
23
- // 创建处理函数(路由)
24
- const callRouteHandler = createCallHandler(valueEvent);
25
- // 创建 children 处理函数(路由)
26
- const processChildren = createRouteProcessChildren(valueEvent, select, nextMiddleware, callRouteHandler);
27
- // 优先route系统。再到files系统
28
- void processChildren(routes, [], nextMiddleware);
29
- };
30
-
31
- export { expendMiddleware };
@@ -1,35 +0,0 @@
1
- /**
2
- * @fileoverview 观察者
3
- * @module processor
4
- * @author ningmengchongshui
5
- */
6
- import { Next, Events, EventCycleEnum, EventKeys } from '../../types';
7
- /**
8
- * 处理订阅
9
- * @param valueEvent
10
- * @param select
11
- * @param next
12
- * @param choose
13
- */
14
- export declare const expendSubscribe: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next, choose: EventCycleEnum) => void;
15
- /**
16
- *
17
- * @param valueEvent
18
- * @param select
19
- * @param next
20
- */
21
- export declare const expendSubscribeCreate: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
22
- /**
23
- *
24
- * @param valueEvent
25
- * @param select
26
- * @param next
27
- */
28
- export declare const expendSubscribeMount: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
29
- /**
30
- *
31
- * @param valueEvent
32
- * @param select
33
- * @param next
34
- */
35
- export declare const expendSubscribeUnmount: <T extends EventKeys>(valueEvent: Events[T], select: T, next: Next) => void;
@@ -1,115 +0,0 @@
1
- import { getSubscribeList } from '../../store/store.js';
2
- import { SubscribeStatus } from '../config.js';
3
-
4
- /**
5
- * 处理订阅
6
- * @param valueEvent
7
- * @param select
8
- * @param next
9
- * @param choose
10
- */
11
- const expendSubscribe = (valueEvent, select, next, choose) => {
12
- const subListValue = getSubscribeList(choose, select);
13
- subListValue.resetCursor();
14
- /**
15
- * 观察者下一步
16
- * @returns
17
- */
18
- const nextObserver = (cn, ...cns) => {
19
- if (cn) {
20
- next(...cns);
21
- return;
22
- }
23
- const item = subListValue.popNext(); // 弹出下一个节点
24
- // 这里代表没有 下一个节点,应该进入下一个周期
25
- if (!item) {
26
- // 下一个节点
27
- nextObserver(true);
28
- return;
29
- }
30
- const selects = item.data.selects; // 订阅的 selects
31
- const ID = item.data.id; // 订阅的 ID
32
- // 查看是否激活,如果不激活,移除并继续下一个
33
- if (item.data.status === SubscribeStatus.paused) {
34
- subListValue.removeCurrent(); // 移除当前节点
35
- // 下一个节点
36
- nextObserver();
37
- return;
38
- }
39
- // 检查 keys
40
- for (const key in item.data.keys) {
41
- // 只要发现不符合的,就继续
42
- if (item.data.keys[key] !== valueEvent[key]) {
43
- // 下一个节点
44
- nextObserver();
45
- return;
46
- }
47
- }
48
- // 恢复(循环替代递归 — 避免深链表栈溢出风险)
49
- const onActive = () => {
50
- for (const select of selects) {
51
- const subListVal = getSubscribeList(choose, select);
52
- subListVal.forEach(node => {
53
- if (node.data.id === ID) {
54
- node.data.status = SubscribeStatus.active;
55
- return true; // break
56
- }
57
- });
58
- }
59
- };
60
- const onPaused = () => {
61
- for (const select of selects) {
62
- const subListVal = getSubscribeList(choose, select);
63
- subListVal.forEach(node => {
64
- if (node.data.id === ID) {
65
- node.data.status = SubscribeStatus.paused;
66
- return true; // break
67
- }
68
- });
69
- }
70
- };
71
- // 订阅是执行则销毁
72
- onPaused();
73
- const Continue = (cn, ...cns) => {
74
- // 重新注册。
75
- onActive();
76
- // true
77
- if (cn) {
78
- // 下一个节点 next(true)
79
- nextObserver(...cns);
80
- }
81
- };
82
- item.data.current(valueEvent, Continue);
83
- };
84
- // 先从观察者开始
85
- nextObserver();
86
- };
87
- /**
88
- *
89
- * @param valueEvent
90
- * @param select
91
- * @param next
92
- */
93
- const expendSubscribeCreate = (valueEvent, select, next) => {
94
- expendSubscribe(valueEvent, select, next, 'create');
95
- };
96
- /**
97
- *
98
- * @param valueEvent
99
- * @param select
100
- * @param next
101
- */
102
- const expendSubscribeMount = (valueEvent, select, next) => {
103
- expendSubscribe(valueEvent, select, next, 'mount');
104
- };
105
- /**
106
- *
107
- * @param valueEvent
108
- * @param select
109
- * @param next
110
- */
111
- const expendSubscribeUnmount = (valueEvent, select, next) => {
112
- expendSubscribe(valueEvent, select, next, 'unmount');
113
- };
114
-
115
- export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount };
@@ -1,17 +0,0 @@
1
- import { EventKeys, Events } from '../../types';
2
- /**
3
- * 消息处理器
4
- * @param name
5
- * @param event
6
- * @param data
7
- * @returns
8
- */
9
- export declare const onProcessor: <T extends EventKeys>(name: T, event: Events[T], data?: any) => void;
10
- /**
11
- * 消息处理器
12
- * @param event
13
- * @param name
14
- * @deprecated 该方法已被弃用,请使用 onProcessor() 替代。
15
- * @returns
16
- */
17
- export declare const OnProcessor: <T extends EventKeys>(event: Events[T], name: T) => void;
@@ -1,207 +0,0 @@
1
- import { getConfigValue } from '../../core/config.js';
2
- import { processorRepeatedClearTimeMin, processorRepeatedClearTimeMax, processorRepeatedEventTime, processorRepeatedUserTime, processorRepeatedClearSize, processorMaxMapSize } from '../../core/variable.js';
3
- import { expendCycle } from './event-processor-cycle.js';
4
- import { ProcessorEventAutoClearMap, ProcessorEventUserAutoClearMap } from '../../store/store.js';
5
- import { getCachedRegExp, fastHash } from '../../core/utils.js';
6
-
7
- /**
8
- * 过滤掉重复消息
9
- * @param param0
10
- * @param MessageId
11
- * @returns
12
- */
13
- const filter = ({ Now, store, INTERVAL }, MessageId) => {
14
- if (store.has(MessageId)) {
15
- const time = store.get(MessageId);
16
- if (Now - time < INTERVAL) {
17
- // 1s内重复消息
18
- store.set(MessageId, Date.now());
19
- return true;
20
- }
21
- }
22
- // 防止 Map 无限增长导致内存泄漏
23
- if (store.size >= processorMaxMapSize) {
24
- cleanupStore({ Now, store, INTERVAL });
25
- // 清理后仍然超限,删除最早的条目
26
- if (store.size >= processorMaxMapSize) {
27
- const firstKey = store.keys().next().value;
28
- if (firstKey !== undefined) {
29
- store.delete(firstKey);
30
- }
31
- }
32
- }
33
- store.set(MessageId, Date.now());
34
- };
35
- /**
36
- * 清理旧消息(带预算限制,避免大 Map 阻塞 Event Loop)
37
- * @returns 是否全部清理完毕
38
- */
39
- const CLEANUP_BUDGET = 1000;
40
- const cleanupStore = ({ Now, store, INTERVAL }) => {
41
- let cleaned = 0;
42
- for (const [ID, timestamp] of store.entries()) {
43
- if (cleaned >= CLEANUP_BUDGET) {
44
- return false; // 预算用尽,下次继续
45
- }
46
- // 超过时间间隔
47
- if (Now - timestamp > INTERVAL) {
48
- store.delete(ID);
49
- cleaned++;
50
- }
51
- }
52
- return true;
53
- };
54
- /**
55
- * 清理所有消息
56
- */
57
- const cleanupStoreAll = () => {
58
- const Now = Date.now();
59
- const value = getConfigValue();
60
- const EVENT_INTERVAL = value?.event?.repeated_event_time ?? value?.processor?.repeated_event_time ?? processorRepeatedEventTime;
61
- const USER_INTERVAL = value?.event?.repeated_user_time ?? value?.processor?.repeated_user_time ?? processorRepeatedUserTime;
62
- const a = cleanupStore({ Now, INTERVAL: EVENT_INTERVAL, store: ProcessorEventAutoClearMap });
63
- const b = cleanupStore({ Now, INTERVAL: USER_INTERVAL, store: ProcessorEventUserAutoClearMap });
64
- return a && b;
65
- };
66
- // 清理消息
67
- const callback = () => {
68
- const allDone = cleanupStoreAll();
69
- // 如果预算用尽未清完,立即调度下一轮
70
- if (!allDone) {
71
- setImmediate(callback);
72
- return;
73
- }
74
- // 下一次清理的时间,应该随着长度的增加而减少
75
- const length = ProcessorEventAutoClearMap.size + ProcessorEventUserAutoClearMap.size;
76
- // 长度控制在37个以内
77
- const time = length > processorRepeatedClearSize ? processorRepeatedClearTimeMin : processorRepeatedClearTimeMax;
78
- setTimeout(callback, time);
79
- };
80
- setTimeout(callback, processorRepeatedClearTimeMin);
81
- /**
82
- * 消息处理器
83
- * @param name
84
- * @param event
85
- * @param data
86
- * @returns
87
- */
88
- const onProcessor = (name, event, data) => {
89
- // 禁用规则设置
90
- const value = getConfigValue();
91
- const disabledTextRegular = value?.event?.disabled?.text_regular ?? value?.disabled_text_regular;
92
- // 检查文本禁用规则
93
- if (disabledTextRegular && event['MessageText']) {
94
- if (getCachedRegExp(disabledTextRegular).test(event['MessageText'])) {
95
- return;
96
- }
97
- }
98
- const disabledSelects = value?.event?.disabled?.selects ?? value?.disabled_selects ?? {};
99
- // 检查事件禁用规则
100
- if (disabledSelects[name]) {
101
- return;
102
- }
103
- const disabledUserId = value?.event?.disabled?.user_id ?? value?.disabled_user_id ?? {};
104
- // 检查用户禁用规则
105
- if (event['UserId'] && disabledUserId[event['UserId']]) {
106
- return;
107
- }
108
- const disabledUserKey = value?.event?.disabled?.user_key ?? value?.disabled_user_key ?? {};
109
- // 检查用户禁用规则
110
- if (event['UserKey'] && disabledUserKey[event['UserKey']]) {
111
- return;
112
- }
113
- // 文本转换规则(合并 event.transforms + 旧的 redirect + mapping_text)
114
- if (event['MessageText']) {
115
- const transforms = value?.event?.transforms;
116
- if (transforms && transforms.length > 0) {
117
- // 新格式:event.transforms 数组
118
- for (const rule of transforms) {
119
- const { pattern, target } = rule ?? {};
120
- if (!pattern) {
121
- continue;
122
- }
123
- const cachedReg = getCachedRegExp(pattern);
124
- if (cachedReg.test(event['MessageText'])) {
125
- event['MessageText'] = event['MessageText'].replace(cachedReg, target);
126
- }
127
- }
128
- }
129
- else {
130
- // 旧格式兼容:redirect_* + mapping_text
131
- const redirectRegular = value?.redirect_regular ?? value?.redirect_text_regular;
132
- const redirectTarget = value?.redirect_target ?? value?.redirect_text_target;
133
- if (redirectRegular && redirectTarget) {
134
- const cachedReg = getCachedRegExp(redirectRegular);
135
- if (cachedReg.test(event['MessageText'])) {
136
- event['MessageText'] = event['MessageText'].replace(cachedReg, redirectTarget);
137
- }
138
- }
139
- const mappingText = value?.mapping_text ?? [];
140
- for (const mapping of mappingText) {
141
- const { regular, target } = mapping ?? {};
142
- if (!regular) {
143
- continue;
144
- }
145
- const cachedReg = getCachedRegExp(regular);
146
- if (cachedReg.test(event['MessageText'])) {
147
- event['MessageText'] = event['MessageText'].replace(cachedReg, target);
148
- }
149
- }
150
- }
151
- }
152
- const masterId = value?.auth?.master?.id ?? value?.master_id ?? {};
153
- const masterKey = value?.auth?.master?.key ?? value?.master_key ?? {};
154
- // 检查是否是 master
155
- if (event['UserId'] && masterId[event['UserId']]) {
156
- event['isMaster'] = true;
157
- }
158
- else if (event['UserKey'] && masterKey[event['UserKey']]) {
159
- event['isMaster'] = true;
160
- }
161
- const botId = value?.auth?.bot?.id ?? value?.bot_id ?? {};
162
- const botKey = value?.auth?.bot?.key ?? value?.bot_key ?? {};
163
- // 检查是否是 bot
164
- if (event['UserId'] && botId[event['UserId']]) {
165
- event['isBot'] = true;
166
- }
167
- else if (event['UserKey'] && botKey[event['UserKey']]) {
168
- event['isBot'] = true;
169
- }
170
- const Now = Date.now();
171
- const EVENT_INTERVAL = value?.event?.repeated_event_time ?? value?.processor?.repeated_event_time ?? processorRepeatedEventTime;
172
- if (event['MessageId']) {
173
- // FNV-1a 快速哈希 — 比 SHA-256 快 ~30-50x
174
- const MessageId = fastHash(event['MessageId']);
175
- // 重复消息
176
- if (filter({ Now, INTERVAL: EVENT_INTERVAL, store: ProcessorEventAutoClearMap }, MessageId)) {
177
- return;
178
- }
179
- }
180
- const USER_INTERVAL = value?.event?.repeated_user_time ?? value?.processor?.repeated_user_time ?? processorRepeatedUserTime;
181
- if (event['UserId']) {
182
- // FNV-1a 快速哈希
183
- const UserId = fastHash(event['UserId']);
184
- // 频繁操作
185
- if (filter({ Now, INTERVAL: USER_INTERVAL, store: ProcessorEventUserAutoClearMap }, UserId)) {
186
- return;
187
- }
188
- }
189
- if (data) {
190
- // 直接赋值 — 避免 defineProperty 破坏 V8 Hidden Class 优化
191
- event['value'] = data;
192
- }
193
- event['name'] = name;
194
- expendCycle(event, name, value);
195
- };
196
- /**
197
- * 消息处理器
198
- * @param event
199
- * @param name
200
- * @deprecated 该方法已被弃用,请使用 onProcessor() 替代。
201
- * @returns
202
- */
203
- const OnProcessor = (event, name) => {
204
- onProcessor(name, event);
205
- };
206
-
207
- export { OnProcessor, onProcessor };
@@ -1,6 +0,0 @@
1
- /**
2
- * 卸载模块
3
- * @param name
4
- * @throws {Error} - 如果 name 无效,抛出错误。
5
- */
6
- export declare const unChildren: (name?: string) => void;
@@ -1,22 +0,0 @@
1
- import { ResultCode } from '../../core/variable.js';
2
- import { ChildrenApp } from '../../store/store.js';
3
-
4
- /**
5
- * 卸载模块
6
- * @param name
7
- * @throws {Error} - 如果 name 无效,抛出错误。
8
- */
9
- const unChildren = (name = 'main') => {
10
- if (!name || typeof name !== 'string') {
11
- logger.error({
12
- code: ResultCode.FailParams,
13
- message: 'Invalid name: name must be a string',
14
- data: null
15
- });
16
- throw new Error('Invalid name: name must be a string');
17
- }
18
- const app = new ChildrenApp(name);
19
- app.un();
20
- };
21
-
22
- export { unChildren };
@@ -1,8 +0,0 @@
1
- import { EventKeys, Events } from '../../types';
2
- /**
3
- * 频道处理
4
- * @deprecated 待支持
5
- * @param event
6
- * @returns
7
- */
8
- export declare const useChannel: <T extends EventKeys>(event: Events[T]) => readonly [{}];
@@ -1,33 +0,0 @@
1
- import { ResultCode } from '../../core/variable.js';
2
-
3
- /**
4
- * 频道处理
5
- * @deprecated 待支持
6
- * @param event
7
- * @returns
8
- */
9
- const useChannel = (event) => {
10
- if (!event || typeof event !== 'object') {
11
- logger.error({
12
- code: ResultCode.FailParams,
13
- message: 'Invalid event: event must be an object',
14
- data: null
15
- });
16
- throw new Error('Invalid event: event must be an object');
17
- }
18
- // // 退出
19
- // const exit = async (channel_id?: string) => {
20
- // return createResult(ResultCode.Warn, '暂未支持', channel_id)
21
- // }
22
- // // 加入
23
- // const join = async (channel_id?: string) => {
24
- // return createResult(ResultCode.Warn, '暂未支持', channel_id)
25
- // }
26
- const channel = {
27
- // exit,
28
- // join
29
- };
30
- return [channel];
31
- };
32
-
33
- export { useChannel };
@@ -1,7 +0,0 @@
1
- /**
2
- * 使用客户端
3
- * @param event
4
- * @param _ApiClass
5
- * @returns
6
- */
7
- export declare const useClient: <T extends object>(event: any, _ApiClass: new (...args: any[]) => T) => readonly [T];
@@ -1,27 +0,0 @@
1
- import { sendAPI } from '../../cbp/processor/api.js';
2
-
3
- /**
4
- * 使用客户端
5
- * @param event
6
- * @param _ApiClass
7
- * @returns
8
- */
9
- const useClient = (event, _ApiClass) => {
10
- const client = new Proxy({}, {
11
- get(_target, prop) {
12
- return (...args) => {
13
- return sendAPI({
14
- action: 'client.api',
15
- payload: {
16
- event,
17
- key: String(prop),
18
- params: args
19
- }
20
- });
21
- };
22
- }
23
- });
24
- return [client];
25
- };
26
-
27
- export { useClient };
@@ -1,8 +0,0 @@
1
- import { User } from '../../types';
2
- import { Result } from '../../core/utils';
3
- /**
4
- * 获取我相关的数据
5
- */
6
- export declare const useMe: () => readonly [{
7
- info: () => Promise<Result<User | null>>;
8
- }];
@@ -1,45 +0,0 @@
1
- import { ResultCode } from '../../core/variable.js';
2
- import { createResult } from '../../core/utils.js';
3
- import { sendAction } from '../../cbp/processor/actions.js';
4
-
5
- /**
6
- * 获取我相关的数据
7
- */
8
- const useMe = () => {
9
- /**
10
- * 个人信息
11
- * @returns
12
- */
13
- const info = async () => {
14
- try {
15
- const results = await sendAction({
16
- action: 'me.info',
17
- payload: {}
18
- });
19
- const result = results.find(item => item.code === ResultCode.Ok);
20
- if (result) {
21
- const data = result?.data ?? null;
22
- return createResult(ResultCode.Ok, 'Successfully retrieved bot information', data);
23
- }
24
- return createResult(ResultCode.Warn, 'No bot information found', null);
25
- }
26
- catch {
27
- return createResult(ResultCode.Fail, 'Failed to get bot information', null);
28
- }
29
- };
30
- /**
31
- * 加入的服务器列表
32
- */
33
- /**
34
- * 好友列表
35
- */
36
- /**
37
- * 私聊线程列表
38
- */
39
- const control = {
40
- info
41
- };
42
- return [control];
43
- };
44
-
45
- export { useMe };
@@ -1,8 +0,0 @@
1
- import { EventKeys, Events } from '../../types';
2
- /**
3
- * 用户处理
4
- * @deprecated 待支持
5
- * @param event
6
- * @returns
7
- */
8
- export declare const useMember: <T extends EventKeys>(event: Events[T]) => readonly [{}];
@@ -1,59 +0,0 @@
1
- import { ResultCode } from '../../core/variable.js';
2
-
3
- /**
4
- * 用户处理
5
- * @deprecated 待支持
6
- * @param event
7
- * @returns
8
- */
9
- const useMember = (event) => {
10
- if (!event || typeof event !== 'object') {
11
- logger.error({
12
- code: ResultCode.FailParams,
13
- message: 'Invalid event: event must be an object',
14
- data: null
15
- });
16
- throw new Error('Invalid event: event must be an object');
17
- }
18
- // /**
19
- // * 获取用户信息
20
- // * @param user_id
21
- // * @returns
22
- // */
23
- // const information = async (user_id?: string) => {
24
- // return createResult(ResultCode.Warn, '暂未支持', user_id)
25
- // }
26
- // /**
27
- // * 禁言
28
- // * @param all 是否是全体
29
- // * @returns
30
- // */
31
- // const mute = async (all: boolean = false) => {
32
- // return createResult(ResultCode.Warn, '暂未支持', all)
33
- // }
34
- // /**
35
- // * 解除禁言
36
- // * @param all 是否是全体
37
- // * @returns
38
- // */
39
- // const unmute = async (all: boolean = false) => {
40
- // return createResult(ResultCode.Warn, '暂未支持', all)
41
- // }
42
- // /**
43
- // * 移除用户
44
- // * @param user_id
45
- // * @returns
46
- // */
47
- // const remove = async (user_id?: string) => {
48
- // return createResult(ResultCode.Warn, '暂未支持', user_id)
49
- // }
50
- const member = {
51
- // information,
52
- // mute,
53
- // unmute,
54
- // remove
55
- };
56
- return [member];
57
- };
58
-
59
- export { useMember };
@@ -1,23 +0,0 @@
1
- import { EventKeys, Events, User } from '../../types';
2
- import { Result } from '../../core/utils';
3
- type Options = {
4
- UserId?: string;
5
- UserKey?: string;
6
- UserName?: string;
7
- IsMaster?: boolean;
8
- IsBot?: boolean;
9
- };
10
- /**
11
- * 使用提及。
12
- * @param {Object} event - 事件对象,包含触发提及的相关信息。
13
- * @throws {Error} - 如果 event 无效,抛出错误。
14
- */
15
- export declare const useMention: <T extends EventKeys>(event: Events[T]) => [{
16
- find: (options?: Options) => Promise<Result<User[]> & {
17
- count: number;
18
- }>;
19
- findOne: (options?: Options) => Promise<Result<User | null> & {
20
- count: number;
21
- }>;
22
- }];
23
- export {};