@alemonjs/qq-bot 2.1.0-alpha.20 → 2.1.0-alpha.22

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { platform } from './config';
2
2
  export * from './hook';
3
3
  export { QQBotAPI as API } from './sdk/api';
4
- declare const main: () => void;
5
- export default main;
4
+ declare const _default: () => any;
5
+ export default _default;
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getConfigValue } from 'alemonjs';
1
+ import { definePlatform, getConfigValue } from 'alemonjs';
2
2
  import { start } from './index.webhook.js';
3
3
  import { start as start$1 } from './index.websoket.js';
4
4
  import { platform } from './config.js';
@@ -18,32 +18,6 @@ const main = () => {
18
18
  start$1();
19
19
  }
20
20
  };
21
- const mainProcess = () => {
22
- ['SIGINT', 'SIGTERM', 'SIGQUIT', 'disconnect'].forEach(sig => {
23
- process?.on?.(sig, () => {
24
- logger.info?.(`[@alemonjs/qq-bot][${sig}] 收到信号,正在关闭...`);
25
- setImmediate(() => process.exit(0));
26
- });
27
- });
28
- process?.on?.('exit', code => {
29
- logger.info?.(`[@alemonjs/qq-bot][exit] 进程退出,code=${code}`);
30
- });
31
- process.on('message', msg => {
32
- try {
33
- const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
34
- if (data?.type === 'start') {
35
- main();
36
- }
37
- else if (data?.type === 'stop') {
38
- process.exit(0);
39
- }
40
- }
41
- catch { }
42
- });
43
- if (process.send) {
44
- process.send(JSON.stringify({ type: 'ready' }));
45
- }
46
- };
47
- mainProcess();
21
+ var index = definePlatform({ main });
48
22
 
49
- export { main as default, platform };
23
+ export { index as default, platform };
package/lib/register.js CHANGED
@@ -381,7 +381,21 @@ const register = (client) => {
381
381
  }
382
382
  };
383
383
  const onactions = async (data, consume) => {
384
- if (data.action === 'message.send') {
384
+ if (data.action === 'me.info') {
385
+ const res = await client.usersMe();
386
+ const UserId = res.id;
387
+ const [isMaster, UserKey] = getMaster(UserId);
388
+ const botInfo = {
389
+ UserId: res?.id,
390
+ UserName: res?.username,
391
+ UserAvatar: createUserAvatarURL(res?.id),
392
+ IsBot: true,
393
+ IsMaster: isMaster,
394
+ UserKey: UserKey
395
+ };
396
+ consume([createResult(ResultCode.Ok, '请求完成', botInfo)]);
397
+ }
398
+ else if (data.action === 'message.send') {
385
399
  const event = data.payload.event;
386
400
  const paramFormat = data.payload.params.format;
387
401
  const res = await api.use.send(event, paramFormat);
@@ -404,6 +418,9 @@ const register = (client) => {
404
418
  const res = await api.active.send.user(user_id, paramFormat);
405
419
  consume(res);
406
420
  }
421
+ else {
422
+ consume([createResult(ResultCode.Fail, '未知请求,请尝试升级版本', null)]);
423
+ }
407
424
  };
408
425
  cbp.onactions((data, consume) => void onactions(data, consume));
409
426
  const onapis = async (data, consume) => {
@@ -413,6 +430,9 @@ const register = (client) => {
413
430
  const res = await client[key](...params);
414
431
  consume([createResult(ResultCode.Ok, '请求完成', res)]);
415
432
  }
433
+ else {
434
+ consume([createResult(ResultCode.Fail, '未知请求,请尝试升级版本', null)]);
435
+ }
416
436
  };
417
437
  cbp.onapis((data, consume) => void onapis(data, consume));
418
438
  };