alemonjs 2.1.10 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/hook-use-api.d.ts +3 -0
- package/lib/app/hook-use-api.js +26 -1
- package/lib/app/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/actions.d.ts +5 -1
- package/package.json +1 -2
|
@@ -22,4 +22,7 @@ export declare const unChildren: (name?: string) => void;
|
|
|
22
22
|
export declare const onSelects: <T extends EventKeys[] | EventKeys>(values: T) => T;
|
|
23
23
|
export declare const createSelects: <T extends EventKeys[] | EventKeys>(values: T) => T;
|
|
24
24
|
export declare const useClient: <T extends object>(event: any, _ApiClass: new (...args: any[]) => T) => readonly [T];
|
|
25
|
+
export declare const useMe: () => readonly [{
|
|
26
|
+
info: () => Promise<Result<any>>;
|
|
27
|
+
}];
|
|
25
28
|
export {};
|
package/lib/app/hook-use-api.js
CHANGED
|
@@ -202,5 +202,30 @@ const useClient = (event, _ApiClass) => {
|
|
|
202
202
|
});
|
|
203
203
|
return [client];
|
|
204
204
|
};
|
|
205
|
+
const useMe = () => {
|
|
206
|
+
const info = async () => {
|
|
207
|
+
try {
|
|
208
|
+
const results = await sendAction({
|
|
209
|
+
action: 'me.info',
|
|
210
|
+
payload: {}
|
|
211
|
+
});
|
|
212
|
+
const result = results.find(item => item.code === ResultCode.Ok);
|
|
213
|
+
if (result) {
|
|
214
|
+
const data = result.data;
|
|
215
|
+
return createResult(ResultCode.Ok, 'Successfully retrieved bot information', data);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
return createResult(ResultCode.Warn, 'No bot information found', null);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
return createResult(ResultCode.Fail, err?.message || 'Failed to get bot information', null);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const control = {
|
|
226
|
+
info
|
|
227
|
+
};
|
|
228
|
+
return [control];
|
|
229
|
+
};
|
|
205
230
|
|
|
206
|
-
export { createSelects, onSelects, unChildren, useChannel, useClient, useMenber, useMention, useMessage, useSend, useSends };
|
|
231
|
+
export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, useMenber, useMention, useMessage, useSend, useSends };
|
package/lib/app/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { expendCycle } from './event-processor-cycle.js';
|
|
|
12
12
|
export { expendEvent } from './event-processor-event.js';
|
|
13
13
|
export { expendMiddleware } from './event-processor-middleware.js';
|
|
14
14
|
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './event-processor-subscribe.js';
|
|
15
|
-
export { createSelects, onSelects, unChildren, useChannel, useClient, useMenber, useMention, useMessage, useSend, useSends } from './hook-use-api.js';
|
|
15
|
+
export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, useMenber, useMention, useMessage, useSend, useSends } from './hook-use-api.js';
|
|
16
16
|
export { onState, unState, useState } from './hook-use-state.js';
|
|
17
17
|
export { useObserver, useSubscribe } from './hook-use-subscribe.js';
|
|
18
18
|
export { createDataFormat, createEventValue, format, sendToChannel, sendToUser } from './message-api.js';
|
package/lib/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export { expendCycle } from './app/event-processor-cycle.js';
|
|
|
19
19
|
export { expendEvent } from './app/event-processor-event.js';
|
|
20
20
|
export { expendMiddleware } from './app/event-processor-middleware.js';
|
|
21
21
|
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './app/event-processor-subscribe.js';
|
|
22
|
-
export { createSelects, onSelects, unChildren, useChannel, useClient, useMenber, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
22
|
+
export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, useMenber, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
23
23
|
export { onState, unState, useState } from './app/hook-use-state.js';
|
|
24
24
|
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
25
25
|
export { createDataFormat, createEventValue, format, sendToChannel, sendToUser } from './app/message-api.js';
|
package/lib/types/actions.d.ts
CHANGED
|
@@ -83,9 +83,13 @@ export type ActionMessageForwardChannel = {
|
|
|
83
83
|
}[];
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
+
export type ActionMeInfo = {
|
|
87
|
+
action: 'me.info';
|
|
88
|
+
payload: object;
|
|
89
|
+
};
|
|
86
90
|
type base = {
|
|
87
91
|
actionId?: string;
|
|
88
92
|
DeviceId?: string;
|
|
89
93
|
};
|
|
90
|
-
export type Actions = (ActionMessageSend | ActionMentionGet | ActionMessageSendChannel | ActionMessageSendUser | ActionMessageDelete | ActionFileSendChannel | ActionFileSendUser | ActionMessageForwardUser | ActionMessageForwardChannel) & base;
|
|
94
|
+
export type Actions = (ActionMessageSend | ActionMentionGet | ActionMessageSendChannel | ActionMessageSendUser | ActionMessageDelete | ActionFileSendChannel | ActionFileSendUser | ActionMessageForwardUser | ActionMessageForwardChannel | ActionMeInfo) & base;
|
|
91
95
|
export {};
|