@luckylillia-dev/plugin-onebot11 1.0.4 → 1.1.0

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 (177) hide show
  1. package/lib/api.js +110 -0
  2. package/lib/api.js.map +7 -0
  3. package/lib/chunk-DYMW7N7M.js +24193 -0
  4. package/lib/chunk-DYMW7N7M.js.map +7 -0
  5. package/lib/index.js +411 -16848
  6. package/lib/index.js.map +4 -4
  7. package/lib/types/action/go-cqhttp/QuickOperation.d.ts +19 -0
  8. package/lib/types/action/index.d.ts +2 -0
  9. package/lib/types/action/llbot/system/GetEvent.d.ts +21 -0
  10. package/lib/types/adapter.d.ts +29 -0
  11. package/lib/types/api.d.ts +2 -0
  12. package/lib/types/config.d.ts +30 -64
  13. package/lib/types/connect/http.d.ts +43 -0
  14. package/lib/types/connect/ws.d.ts +47 -0
  15. package/lib/types/eventfilter.d.ts +2 -0
  16. package/lib/types/helper/eventForHttp.d.ts +6 -0
  17. package/lib/types/helper/quickOperation.d.ts +27 -0
  18. package/lib/types/index.d.ts +7 -7
  19. package/lib/types/protocol/action/BaseAction.d.ts +20 -0
  20. package/lib/types/protocol/action/OB11Response.d.ts +6 -0
  21. package/lib/types/protocol/action/file/GetFile.d.ts +39 -0
  22. package/lib/types/protocol/action/file/GetImage.d.ts +5 -0
  23. package/lib/types/protocol/action/file/GetRecord.d.ts +26 -0
  24. package/lib/types/protocol/action/go-cqhttp/CreateGroupFileFolder.d.ts +24 -0
  25. package/lib/types/protocol/action/go-cqhttp/DeleteEssenceMsg.d.ts +15 -0
  26. package/lib/types/protocol/action/go-cqhttp/DeleteFriend.d.ts +15 -0
  27. package/lib/types/protocol/action/go-cqhttp/DeleteGroupFile.d.ts +21 -0
  28. package/lib/types/protocol/action/go-cqhttp/DeleteGroupFolder.d.ts +18 -0
  29. package/lib/types/protocol/action/go-cqhttp/DownloadFile.d.ts +27 -0
  30. package/lib/types/protocol/action/go-cqhttp/GetForwardMsg.d.ts +25 -0
  31. package/lib/types/protocol/action/go-cqhttp/GetGroupAtAllRemain.d.ts +24 -0
  32. package/lib/types/protocol/action/go-cqhttp/GetGroupEssence.d.ts +24 -0
  33. package/lib/types/protocol/action/go-cqhttp/GetGroupFileSystemInfo.d.ts +26 -0
  34. package/lib/types/protocol/action/go-cqhttp/GetGroupFileUrl.d.ts +23 -0
  35. package/lib/types/protocol/action/go-cqhttp/GetGroupFilesByFolder.d.ts +38 -0
  36. package/lib/types/protocol/action/go-cqhttp/GetGroupMsgHistory.d.ts +30 -0
  37. package/lib/types/protocol/action/go-cqhttp/GetGroupNotice.d.ts +35 -0
  38. package/lib/types/protocol/action/go-cqhttp/GetGroupRootFiles.d.ts +46 -0
  39. package/lib/types/protocol/action/go-cqhttp/GetGroupSystemMsg.d.ts +28 -0
  40. package/lib/types/protocol/action/go-cqhttp/GetStrangerInfo.d.ts +52 -0
  41. package/lib/types/protocol/action/go-cqhttp/MarkMsgAsRead.d.ts +15 -0
  42. package/lib/types/protocol/action/go-cqhttp/OCRImage.d.ts +37 -0
  43. package/lib/types/protocol/action/go-cqhttp/SendForwardMsg.d.ts +76 -0
  44. package/lib/types/protocol/action/go-cqhttp/SendGroupNotice.d.ts +36 -0
  45. package/lib/types/protocol/action/go-cqhttp/SendGroupSign.d.ts +15 -0
  46. package/lib/types/protocol/action/go-cqhttp/SetEssenceMsg.d.ts +15 -0
  47. package/lib/types/protocol/action/go-cqhttp/SetGroupPortrait.d.ts +19 -0
  48. package/lib/types/protocol/action/go-cqhttp/SetGroupSpecialTitle.d.ts +21 -0
  49. package/lib/types/protocol/action/go-cqhttp/SetQQProfile.d.ts +18 -0
  50. package/lib/types/protocol/action/go-cqhttp/UploadGroupFile.d.ts +32 -0
  51. package/lib/types/protocol/action/go-cqhttp/UploadPrivateFile.d.ts +26 -0
  52. package/lib/types/protocol/action/group/GetGroupHonorInfo.d.ts +38 -0
  53. package/lib/types/protocol/action/group/GetGroupInfo.d.ts +32 -0
  54. package/lib/types/protocol/action/group/GetGroupList.d.ts +29 -0
  55. package/lib/types/protocol/action/group/GetGroupMemberInfo.d.ts +22 -0
  56. package/lib/types/protocol/action/group/GetGroupMemberList.d.ts +19 -0
  57. package/lib/types/protocol/action/group/GetGuildList.d.ts +6 -0
  58. package/lib/types/protocol/action/group/SendGroupMsg.d.ts +10 -0
  59. package/lib/types/protocol/action/group/SetGroupAddRequest.d.ts +21 -0
  60. package/lib/types/protocol/action/group/SetGroupAdmin.d.ts +21 -0
  61. package/lib/types/protocol/action/group/SetGroupBan.d.ts +21 -0
  62. package/lib/types/protocol/action/group/SetGroupCard.d.ts +21 -0
  63. package/lib/types/protocol/action/group/SetGroupKick.d.ts +21 -0
  64. package/lib/types/protocol/action/group/SetGroupLeave.d.ts +16 -0
  65. package/lib/types/protocol/action/group/SetGroupName.d.ts +18 -0
  66. package/lib/types/protocol/action/group/SetGroupWholeBan.d.ts +18 -0
  67. package/lib/types/protocol/action/index.d.ts +3 -0
  68. package/lib/types/protocol/action/llbot/file/DownloadFlashFile.d.ts +6 -0
  69. package/lib/types/protocol/action/llbot/file/GetFlashFileDownloadUrls.d.ts +26 -0
  70. package/lib/types/protocol/action/llbot/file/GetFlashFileInfo.d.ts +41 -0
  71. package/lib/types/protocol/action/llbot/file/GetPrivateFileUrl.d.ts +19 -0
  72. package/lib/types/protocol/action/llbot/file/GetRkey.d.ts +18 -0
  73. package/lib/types/protocol/action/llbot/file/MoveGroupFile.d.ts +24 -0
  74. package/lib/types/protocol/action/llbot/file/ReShareFlashFile.d.ts +17 -0
  75. package/lib/types/protocol/action/llbot/file/RenameGroupFile.d.ts +24 -0
  76. package/lib/types/protocol/action/llbot/file/RenameGroupFileFolder.d.ts +21 -0
  77. package/lib/types/protocol/action/llbot/file/SetGroupFileForever.d.ts +18 -0
  78. package/lib/types/protocol/action/llbot/file/UploadFlashFile.d.ts +41 -0
  79. package/lib/types/protocol/action/llbot/group/BatchDeleteGroupMember.d.ts +18 -0
  80. package/lib/types/protocol/action/llbot/group/DeleteGroupNotice.d.ts +18 -0
  81. package/lib/types/protocol/action/llbot/group/GetGroupAddRequest.d.ts +12 -0
  82. package/lib/types/protocol/action/llbot/group/GetGroupNoticeAcklist.d.ts +30 -0
  83. package/lib/types/protocol/action/llbot/group/GetGroupShutList.d.ts +38 -0
  84. package/lib/types/protocol/action/llbot/group/GetGroupSignedList.d.ts +26 -0
  85. package/lib/types/protocol/action/llbot/group/GroupAlbum/CreateGroupAlbum.d.ts +21 -0
  86. package/lib/types/protocol/action/llbot/group/GroupAlbum/DeleteGroupAlbum.d.ts +18 -0
  87. package/lib/types/protocol/action/llbot/group/GroupAlbum/GetGroupAlbumList.d.ts +132 -0
  88. package/lib/types/protocol/action/llbot/group/GroupAlbum/GetGroupAlbumMediaList.d.ts +306 -0
  89. package/lib/types/protocol/action/llbot/group/GroupAlbum/UploadGroupAlbum.d.ts +21 -0
  90. package/lib/types/protocol/action/llbot/group/GroupPoke.d.ts +18 -0
  91. package/lib/types/protocol/action/llbot/group/SetGroupMsgMask.d.ts +18 -0
  92. package/lib/types/protocol/action/llbot/group/SetGroupRemark.d.ts +18 -0
  93. package/lib/types/protocol/action/llbot/msg/FetchCustomFace.d.ts +6 -0
  94. package/lib/types/protocol/action/llbot/msg/FetchEmojiLike.d.ts +37 -0
  95. package/lib/types/protocol/action/llbot/msg/ForwardSingleMsg.d.ts +31 -0
  96. package/lib/types/protocol/action/llbot/msg/GetAiCharacters.d.ts +26 -0
  97. package/lib/types/protocol/action/llbot/msg/GetFriendMsgHistory.d.ts +30 -0
  98. package/lib/types/protocol/action/llbot/msg/GetRecommendFace.d.ts +20 -0
  99. package/lib/types/protocol/action/llbot/msg/SendGroupAiRecord.d.ts +27 -0
  100. package/lib/types/protocol/action/llbot/msg/SendPoke.d.ts +21 -0
  101. package/lib/types/protocol/action/llbot/msg/SetMsgEmojiLike.d.ts +26 -0
  102. package/lib/types/protocol/action/llbot/msg/VoiceMsg2Text.d.ts +17 -0
  103. package/lib/types/protocol/action/llbot/system/Config.d.ts +32 -0
  104. package/lib/types/protocol/action/llbot/system/Debug.d.ts +21 -0
  105. package/lib/types/protocol/action/llbot/system/GetRobotUinRange.d.ts +10 -0
  106. package/lib/types/protocol/action/llbot/system/ScanQRCode.d.ts +18 -0
  107. package/lib/types/protocol/action/llbot/system/SendPB.d.ts +27 -0
  108. package/lib/types/protocol/action/llbot/user/FriendPoke.d.ts +18 -0
  109. package/lib/types/protocol/action/llbot/user/GetDoubtFriendsAddRequest.d.ts +36 -0
  110. package/lib/types/protocol/action/llbot/user/GetFriendWithCategory.d.ts +23 -0
  111. package/lib/types/protocol/action/llbot/user/GetProfileLike.d.ts +41 -0
  112. package/lib/types/protocol/action/llbot/user/GetProfileLikeCount.d.ts +18 -0
  113. package/lib/types/protocol/action/llbot/user/GetProfileLikeMe.d.ts +23 -0
  114. package/lib/types/protocol/action/llbot/user/GetQQAvatar.d.ts +23 -0
  115. package/lib/types/protocol/action/llbot/user/SetDoubtFriendsAddRequest.d.ts +15 -0
  116. package/lib/types/protocol/action/llbot/user/SetFriendCategory.d.ts +18 -0
  117. package/lib/types/protocol/action/llbot/user/SetFriendRemark.d.ts +18 -0
  118. package/lib/types/protocol/action/llbot/user/SetInputStatus.d.ts +18 -0
  119. package/lib/types/protocol/action/llbot/user/SetOnlineStatus.d.ts +21 -0
  120. package/lib/types/protocol/action/llbot/user/SetQQAvatar.d.ts +15 -0
  121. package/lib/types/protocol/action/msg/DeleteMsg.d.ts +15 -0
  122. package/lib/types/protocol/action/msg/GetMsg.d.ts +18 -0
  123. package/lib/types/protocol/action/msg/SendMsg.d.ts +26 -0
  124. package/lib/types/protocol/action/msg/SendPrivateMsg.d.ts +10 -0
  125. package/lib/types/protocol/action/system/CanSendImage.d.ts +5 -0
  126. package/lib/types/protocol/action/system/CanSendRecord.d.ts +12 -0
  127. package/lib/types/protocol/action/system/CleanCache.d.ts +6 -0
  128. package/lib/types/protocol/action/system/GetCredentials.d.ts +22 -0
  129. package/lib/types/protocol/action/system/GetCsrfToken.d.ts +12 -0
  130. package/lib/types/protocol/action/system/GetLoginInfo.d.ts +11 -0
  131. package/lib/types/protocol/action/system/GetStatus.d.ts +7 -0
  132. package/lib/types/protocol/action/system/GetVersionInfo.d.ts +7 -0
  133. package/lib/types/protocol/action/system/SetRestart.d.ts +6 -0
  134. package/lib/types/protocol/action/types.d.ts +133 -0
  135. package/lib/types/protocol/action/user/GetCookie.d.ts +22 -0
  136. package/lib/types/protocol/action/user/GetFriendList.d.ts +7 -0
  137. package/lib/types/protocol/action/user/SendLike.d.ts +18 -0
  138. package/lib/types/protocol/action/user/SetFriendAddRequest.d.ts +21 -0
  139. package/lib/types/protocol/cqcode.d.ts +3 -0
  140. package/lib/types/protocol/entities.d.ts +14 -0
  141. package/lib/types/protocol/event/OB11BaseEvent.d.ts +15 -0
  142. package/lib/types/protocol/event/index.d.ts +47 -0
  143. package/lib/types/protocol/event/message/OB11MessageEvent.d.ts +2 -0
  144. package/lib/types/protocol/event/meta/OB11BaseMetaEvent.d.ts +5 -0
  145. package/lib/types/protocol/event/meta/OB11HeartbeatEvent.d.ts +12 -0
  146. package/lib/types/protocol/event/meta/OB11LifeCycleEvent.d.ts +11 -0
  147. package/lib/types/protocol/event/notice/OB11BaseNoticeEvent.d.ts +4 -0
  148. package/lib/types/protocol/event/notice/OB11FlashFileEvent.d.ts +36 -0
  149. package/lib/types/protocol/event/notice/OB11FriendAddNoticeEvent.d.ts +6 -0
  150. package/lib/types/protocol/event/notice/OB11FriendRecallNoticeEvent.d.ts +7 -0
  151. package/lib/types/protocol/event/notice/OB11GroupAdminNoticeEvent.d.ts +8 -0
  152. package/lib/types/protocol/event/notice/OB11GroupBanEvent.d.ts +10 -0
  153. package/lib/types/protocol/event/notice/OB11GroupCardEvent.d.ts +9 -0
  154. package/lib/types/protocol/event/notice/OB11GroupDecreaseEvent.d.ts +10 -0
  155. package/lib/types/protocol/event/notice/OB11GroupDismissEvent.d.ts +7 -0
  156. package/lib/types/protocol/event/notice/OB11GroupEssenceEvent.d.ts +11 -0
  157. package/lib/types/protocol/event/notice/OB11GroupIncreaseEvent.d.ts +11 -0
  158. package/lib/types/protocol/event/notice/OB11GroupNoticeEvent.d.ts +6 -0
  159. package/lib/types/protocol/event/notice/OB11GroupRecallNoticeEvent.d.ts +9 -0
  160. package/lib/types/protocol/event/notice/OB11GroupTitleEvent.d.ts +9 -0
  161. package/lib/types/protocol/event/notice/OB11GroupUploadNoticeEvent.d.ts +14 -0
  162. package/lib/types/protocol/event/notice/OB11MsgEmojiLikeEvent.d.ts +15 -0
  163. package/lib/types/protocol/event/notice/OB11PokeEvent.d.ts +25 -0
  164. package/lib/types/protocol/event/notice/OB11ProfileLikeEvent.d.ts +9 -0
  165. package/lib/types/protocol/event/request/OB11FriendRequest.d.ts +11 -0
  166. package/lib/types/protocol/event/request/OB11GroupRequest.d.ts +25 -0
  167. package/lib/types/protocol/host.d.ts +8 -0
  168. package/lib/types/protocol/index.d.ts +14 -0
  169. package/lib/types/protocol/support/utils.d.ts +28 -0
  170. package/lib/types/protocol/transform/message/incoming.d.ts +7 -0
  171. package/lib/types/protocol/transform/message/index.d.ts +1 -0
  172. package/lib/types/protocol/transform/message/outgoing.d.ts +8 -0
  173. package/lib/types/protocol/types.d.ts +389 -0
  174. package/lib/types/protocol/utils.d.ts +21 -0
  175. package/lib/types/settings.d.ts +5 -0
  176. package/lib/types/support.d.ts +3 -0
  177. package/package.json +89 -16
@@ -0,0 +1,19 @@
1
+ import { BaseAction, Schema } from '../../protocol';
2
+ import { QuickOperation, QuickOperationEvent } from '../../helper/quickOperation';
3
+ import { ActionName } from '../../protocol';
4
+ interface Payload {
5
+ context: QuickOperationEvent;
6
+ operation: QuickOperation;
7
+ }
8
+ export declare class HandleQuickOperation extends BaseAction<Payload, null> {
9
+ actionName: ActionName;
10
+ payloadSchema: Schema<Schemastery.ObjectS<{
11
+ context: Schema<any, any>;
12
+ operation: Schema<any, any>;
13
+ }>, Schemastery.ObjectT<{
14
+ context: Schema<any, any>;
15
+ operation: Schema<any, any>;
16
+ }>>;
17
+ protected _handle(payload: Payload): Promise<null>;
18
+ }
19
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ActionHost, BaseAction } from '../protocol';
2
+ export declare function initActionMap(host: ActionHost): Map<string, BaseAction<any, unknown>>;
@@ -0,0 +1,21 @@
1
+ import { BaseAction, Schema } from '../../../protocol';
2
+ import { ActionName } from '../../../protocol';
3
+ import { OB11Message } from '../../../protocol';
4
+ import { OB11BaseEvent } from '../../../protocol';
5
+ type PostEventType = OB11BaseEvent | OB11Message;
6
+ interface Payload {
7
+ key: string;
8
+ timeout: number | string;
9
+ }
10
+ export declare class GetEvent extends BaseAction<Payload, PostEventType[]> {
11
+ actionName: ActionName;
12
+ payloadSchema: Schema<Schemastery.ObjectS<{
13
+ key: Schema<string, string>;
14
+ timeout: Schema<string | number, string | number>;
15
+ }>, Schemastery.ObjectT<{
16
+ key: Schema<string, string>;
17
+ timeout: Schema<string | number, string | number>;
18
+ }>>;
19
+ protected _handle(payload: Payload): Promise<PostEventType[]>;
20
+ }
21
+ export {};
@@ -0,0 +1,29 @@
1
+ import { Context, Service } from 'cordis';
2
+ import { OB11Config } from './config';
3
+ import { OB11BaseEvent } from './protocol';
4
+ import { BaseAction } from './protocol';
5
+ declare module 'cordis' {
6
+ interface Context {
7
+ onebot: Onebot11Adapter;
8
+ }
9
+ }
10
+ declare class Onebot11Adapter extends Service {
11
+ ctx: Context;
12
+ config: Onebot11Adapter.Config;
13
+ static inject: string[];
14
+ private connect;
15
+ readonly actionMap: Map<string, BaseAction<unknown, unknown>>;
16
+ private reportOfflineMessage;
17
+ private reportSelfMessage;
18
+ constructor(ctx: Context, config: Onebot11Adapter.Config);
19
+ [Service.init](): Promise<() => Promise<void>>;
20
+ dispatch(event: OB11BaseEvent): void;
21
+ dispatchMessageLike(event: OB11BaseEvent, self: boolean, offline: boolean): void;
22
+ private handleMsg;
23
+ start(): void;
24
+ }
25
+ declare namespace Onebot11Adapter {
26
+ interface Config extends OB11Config {
27
+ }
28
+ }
29
+ export default Onebot11Adapter;
@@ -0,0 +1,2 @@
1
+ /** OneBot models, transformations and action implementations. Importing this entry opens no listeners. */
2
+ export * from './protocol';
@@ -1,76 +1,42 @@
1
1
  export interface BaseConnectConfig {
2
- type: string
3
- name?: string
4
- enable: boolean
5
- token: string
6
- reportSelfMessage: boolean
7
- reportOfflineMessage: boolean
8
- messageFormat: 'array' | 'string'
9
- debug: boolean
10
- filter?: Record<string, unknown>
2
+ type: string;
3
+ name?: string;
4
+ enable: boolean;
5
+ token: string;
6
+ reportSelfMessage: boolean;
7
+ reportOfflineMessage: boolean;
8
+ messageFormat: 'array' | 'string';
9
+ debug: boolean;
10
+ filter?: Record<string, unknown>;
11
11
  }
12
-
13
12
  export interface WsConnectConfig extends BaseConnectConfig {
14
- type: 'ws'
15
- host: string
16
- port: number
17
- heartInterval: number // ms
13
+ type: 'ws';
14
+ host: string;
15
+ port: number;
16
+ heartInterval: number;
18
17
  }
19
-
20
18
  export interface WsReverseConnectConfig extends BaseConnectConfig {
21
- type: 'ws-reverse'
22
- url: string
23
- heartInterval: number // ms
19
+ type: 'ws-reverse';
20
+ url: string;
21
+ heartInterval: number;
24
22
  }
25
-
26
23
  export interface HttpConnectConfig extends BaseConnectConfig {
27
- type: 'http'
28
- host: string
29
- port: number
24
+ type: 'http';
25
+ host: string;
26
+ port: number;
30
27
  }
31
-
32
28
  export interface HttpPostConnectConfig extends BaseConnectConfig {
33
- type: 'http-post'
34
- url: string
35
- enableHeart: boolean
36
- heartInterval: number // ms
29
+ type: 'http-post';
30
+ url: string;
31
+ enableHeart: boolean;
32
+ heartInterval: number;
37
33
  }
38
-
39
34
  export interface OB11Config {
40
- enable: boolean
41
- connect: (WsConnectConfig | WsReverseConnectConfig | HttpConnectConfig | HttpPostConnectConfig)[]
42
- // /** @deprecated */
43
- // token?: string
44
- // /** @deprecated */
45
- // httpPort?: number
46
- // /** @deprecated */
47
- // httpPostUrls?: string[]
48
- // /** @deprecated */
49
- // httpSecret?: string
50
- // /** @deprecated */
51
- // wsPort?: number
52
- // /** @deprecated */
53
- // wsReverseUrls?: string[]
54
- // /** @deprecated */
55
- // enableHttp?: boolean
56
- // /** @deprecated */
57
- // enableHttpPost?: boolean
58
- // /** @deprecated */
59
- // enableWs?: boolean
60
- // /** @deprecated */
61
- // enableWsReverse?: boolean
62
- // /** @deprecated */
63
- // messagePostFormat?: 'array' | 'string'
64
- // /** @deprecated */
65
- // enableHttpHeart?: boolean
66
- // /**
67
- // * 快速操作回复自动引用原消息
68
- // * @deprecated
69
- // */
70
- // enableQOAutoQuote?: boolean
71
- // /** @deprecated */
72
- // reportSelfMessage?: boolean
35
+ enable: boolean;
36
+ connect: (WsConnectConfig | WsReverseConnectConfig | HttpConnectConfig | HttpPostConnectConfig)[];
37
+ }
38
+ export interface Config {
39
+ msgCacheExpire: number;
40
+ musicCardSignUrl: string;
41
+ ffmpeg: string;
73
42
  }
74
-
75
-
76
- export interface Config { msgCacheExpire: number; musicCardSignUrl: string; ffmpeg: string }
@@ -0,0 +1,43 @@
1
+ import { BaseAction } from '../protocol';
2
+ import { Context } from 'cordis';
3
+ import { OB11BaseEvent } from '../protocol';
4
+ import { HttpConnectConfig, HttpPostConnectConfig } from '../config';
5
+ declare class OB11Http {
6
+ protected ctx: Context;
7
+ config: OB11Http.Config;
8
+ private app?;
9
+ private server?;
10
+ private sseClients;
11
+ private activated;
12
+ private disposeHeartbeat?;
13
+ constructor(ctx: Context, config: OB11Http.Config);
14
+ start(): void;
15
+ stop(): Promise<boolean>;
16
+ emitEvent(event: OB11BaseEvent): Promise<void>;
17
+ emitMessageLikeEvent(event: OB11BaseEvent, self: boolean, offline: boolean): Promise<void>;
18
+ updateConfig(config: Partial<OB11Http.Config>): void;
19
+ private authorize;
20
+ private handleRequest;
21
+ }
22
+ declare namespace OB11Http {
23
+ interface Config extends HttpConnectConfig {
24
+ actionMap: Map<string, BaseAction<unknown, unknown>>;
25
+ }
26
+ }
27
+ declare class OB11HttpPost {
28
+ protected ctx: Context;
29
+ config: OB11HttpPost.Config;
30
+ private disposeInterval?;
31
+ private activated;
32
+ constructor(ctx: Context, config: OB11HttpPost.Config);
33
+ start(): void;
34
+ stop(): void;
35
+ emitEvent(event: OB11BaseEvent): Promise<void>;
36
+ emitMessageLikeEvent(event: OB11BaseEvent, self: boolean, offline: boolean): Promise<void>;
37
+ updateConfig(config: Partial<OB11HttpPost.Config>): void;
38
+ }
39
+ declare namespace OB11HttpPost {
40
+ interface Config extends HttpPostConnectConfig {
41
+ }
42
+ }
43
+ export { OB11Http, OB11HttpPost };
@@ -0,0 +1,47 @@
1
+ import { BaseAction } from '../protocol';
2
+ import { Context } from 'cordis';
3
+ import { OB11BaseEvent } from '../protocol';
4
+ import { WsConnectConfig, WsReverseConnectConfig } from '../config';
5
+ declare class OB11WebSocket {
6
+ protected ctx: Context;
7
+ config: OB11WebSocket.Config;
8
+ private wsServer?;
9
+ private wsClients;
10
+ private activated;
11
+ constructor(ctx: Context, config: OB11WebSocket.Config);
12
+ start(): void;
13
+ stop(): Promise<boolean>;
14
+ emitEvent(event: OB11BaseEvent): Promise<void>;
15
+ emitMessageLikeEvent(event: OB11BaseEvent, self: boolean, offline: boolean): Promise<void>;
16
+ updateConfig(config: Partial<OB11WebSocket.Config>): void;
17
+ private reply;
18
+ private authorize;
19
+ private handleAction;
20
+ private connect;
21
+ }
22
+ declare namespace OB11WebSocket {
23
+ interface Config extends WsConnectConfig {
24
+ actionMap: Map<string, BaseAction<unknown, unknown>>;
25
+ }
26
+ }
27
+ declare class OB11WebSocketReverse {
28
+ protected ctx: Context;
29
+ config: OB11WebSocketReverse.Config;
30
+ private activated;
31
+ private wsClient?;
32
+ constructor(ctx: Context, config: OB11WebSocketReverse.Config);
33
+ start(): void;
34
+ stop(): void;
35
+ emitEvent(event: OB11BaseEvent): Promise<void>;
36
+ emitMessageLikeEvent(event: OB11BaseEvent, self: boolean, offline: boolean): Promise<void>;
37
+ updateConfig(config: Partial<OB11WebSocketReverse.Config>): void;
38
+ private reply;
39
+ private handleAction;
40
+ private tryConnect;
41
+ }
42
+ declare namespace OB11WebSocketReverse {
43
+ interface Config extends WsReverseConnectConfig {
44
+ actionMap: Map<string, BaseAction<unknown, unknown>>;
45
+ }
46
+ }
47
+ export { OB11WebSocket, OB11WebSocketReverse };
@@ -0,0 +1,2 @@
1
+ import { OB11BaseEvent } from './protocol';
2
+ export declare function matchEventFilter(filter: unknown, event: OB11BaseEvent): boolean;
@@ -0,0 +1,6 @@
1
+ import { OB11Message } from '../protocol';
2
+ import { OB11BaseEvent } from '../protocol';
3
+ type PostEventType = OB11Message | OB11BaseEvent;
4
+ export declare function postHttpEvent(event: PostEventType): void;
5
+ export declare function getHttpEvent(userKey: string, timeout?: number): Promise<PostEventType[]>;
6
+ export {};
@@ -0,0 +1,27 @@
1
+ import { OB11Message } from '../protocol';
2
+ import { OB11FriendRequestEvent } from '../protocol';
3
+ import { OB11GroupRequestAddEvent, OB11GroupRequestInviteBotEvent } from '../protocol';
4
+ import { Context } from 'cordis';
5
+ interface QuickOperationPrivateMessage {
6
+ reply?: string;
7
+ auto_escape?: boolean;
8
+ }
9
+ interface QuickOperationGroupMessage extends QuickOperationPrivateMessage {
10
+ at_sender?: boolean;
11
+ delete?: boolean;
12
+ kick?: boolean;
13
+ ban?: boolean;
14
+ ban_duration?: number;
15
+ }
16
+ interface QuickOperationFriendRequest {
17
+ approve?: boolean;
18
+ remark?: string;
19
+ }
20
+ interface QuickOperationGroupRequest {
21
+ approve?: boolean;
22
+ reason?: string;
23
+ }
24
+ export type QuickOperation = QuickOperationPrivateMessage & QuickOperationGroupMessage & QuickOperationFriendRequest & QuickOperationGroupRequest;
25
+ export type QuickOperationEvent = OB11Message | OB11FriendRequestEvent | OB11GroupRequestAddEvent | OB11GroupRequestInviteBotEvent;
26
+ export declare function handleQuickOperation(ctx: Context, event: QuickOperationEvent, quickAction: QuickOperation): Promise<void>;
27
+ export {};
@@ -1,7 +1,7 @@
1
- import type { Context, Schema } from '@luckylillia-dev/plugin-sdk'
2
- import type { OB11Config } from './config'
3
- export type Config = Omit<OB11Config, 'enable'>
4
- export declare const Config: Schema<Config>
5
- export declare const name: string
6
- export declare const inject: string[]
7
- export declare function apply(ctx: Context, config: Config): Promise<void>
1
+ import { Context } from 'cordis';
2
+ import { type OB11Settings } from './settings';
3
+ export declare const name = "@luckylillia-dev/plugin-onebot11";
4
+ export type Config = OB11Settings;
5
+ export declare const Config: import("schemastery")<OB11Settings>;
6
+ export declare const inject: string[];
7
+ export declare function apply(ctx: Context, config: Config): Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { ActionName } from './types';
2
+ import { OB11Return } from '../types';
3
+ import { Context } from 'cordis';
4
+ import { ParseMessageConfig } from '../types';
5
+ import z from 'schemastery';
6
+ /** Account actions only need their context; they never own transport listeners. */
7
+ export interface ActionHost {
8
+ ctx: Context;
9
+ }
10
+ declare abstract class BaseAction<PayloadType, ReturnDataType> {
11
+ protected adapter: ActionHost;
12
+ abstract actionName: ActionName;
13
+ protected ctx: Context;
14
+ payloadSchema?: z<PayloadType>;
15
+ constructor(adapter: ActionHost);
16
+ handle(payload: PayloadType, config: ParseMessageConfig): Promise<OB11Return<ReturnDataType | null>>;
17
+ websocketHandle(payload: PayloadType, echo: unknown, config: ParseMessageConfig): Promise<OB11Return<ReturnDataType | null>>;
18
+ protected abstract _handle(payload: PayloadType, config: ParseMessageConfig): Promise<ReturnDataType>;
19
+ }
20
+ export { BaseAction, z as Schema };
@@ -0,0 +1,6 @@
1
+ import { OB11Return } from '../types';
2
+ export declare class OB11Response {
3
+ static res<T>(data: T, status: string, retcode: number, message?: string): OB11Return<T>;
4
+ static ok<T>(data: T, echo?: unknown): OB11Return<T>;
5
+ static error(err: string, retcode: number, echo?: unknown): OB11Return<null>;
6
+ }
@@ -0,0 +1,39 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ export interface GetFilePayload {
4
+ file: string;
5
+ download: boolean;
6
+ }
7
+ export interface GetFileResponse {
8
+ file?: string;
9
+ url?: string;
10
+ file_size?: string;
11
+ file_name?: string;
12
+ }
13
+ export declare abstract class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
14
+ payloadSchema: Schema<Schemastery.ObjectS<{
15
+ file: Schema<string, string>;
16
+ download: Schema<string | boolean, boolean>;
17
+ }>, Schemastery.ObjectT<{
18
+ file: Schema<string, string>;
19
+ download: Schema<string | boolean, boolean>;
20
+ }>>;
21
+ protected _handle(payload: GetFilePayload): Promise<GetFileResponse>;
22
+ }
23
+ export default class GetFile extends GetFileBase {
24
+ actionName: ActionName;
25
+ payloadSchema: Schema<Schemastery.ObjectS<{
26
+ file: Schema<string, string>;
27
+ file_id: Schema<string, string>;
28
+ download: Schema<string | boolean, boolean>;
29
+ }>, Schemastery.ObjectT<{
30
+ file: Schema<string, string>;
31
+ file_id: Schema<string, string>;
32
+ download: Schema<string | boolean, boolean>;
33
+ }>>;
34
+ protected _handle(payload: {
35
+ file_id: string;
36
+ file: string;
37
+ download: boolean;
38
+ }): Promise<GetFileResponse>;
39
+ }
@@ -0,0 +1,5 @@
1
+ import { GetFileBase } from './GetFile';
2
+ import { ActionName } from '../types';
3
+ export default class GetImage extends GetFileBase {
4
+ actionName: ActionName;
5
+ }
@@ -0,0 +1,26 @@
1
+ import { ActionName } from '../types';
2
+ import { BaseAction, Schema } from '../BaseAction';
3
+ interface Payload {
4
+ file: string;
5
+ out_format: 'mp3' | 'amr' | 'wma' | 'm4a' | 'spx' | 'ogg' | 'wav' | 'flac';
6
+ }
7
+ interface Response {
8
+ /** The converted file, on the bot's machine */
9
+ file: string;
10
+ file_size: string;
11
+ file_name: string;
12
+ /** The original voice (silk / amr), for a client that cannot read the bot's files */
13
+ url: string;
14
+ }
15
+ export default class GetRecord extends BaseAction<Payload, Response> {
16
+ actionName: ActionName;
17
+ payloadSchema: Schema<Schemastery.ObjectS<{
18
+ file: Schema<string, string>;
19
+ out_format: Schema<"mp3" | "amr" | "wma" | "m4a" | "spx" | "ogg" | "wav" | "flac", "mp3" | "amr" | "wma" | "m4a" | "spx" | "ogg" | "wav" | "flac">;
20
+ }>, Schemastery.ObjectT<{
21
+ file: Schema<string, string>;
22
+ out_format: Schema<"mp3" | "amr" | "wma" | "m4a" | "spx" | "ogg" | "wav" | "flac", "mp3" | "amr" | "wma" | "m4a" | "spx" | "ogg" | "wav" | "flac">;
23
+ }>>;
24
+ protected _handle(payload: Payload): Promise<Response>;
25
+ }
26
+ export {};
@@ -0,0 +1,24 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ group_id: number | string;
5
+ name: string;
6
+ parent_id?: '/';
7
+ }
8
+ interface Response {
9
+ folder_id: string;
10
+ }
11
+ export declare class CreateGroupFileFolder extends BaseAction<Payload, Response> {
12
+ actionName: ActionName;
13
+ payloadSchema: Schema<Schemastery.ObjectS<{
14
+ group_id: Schema<string | number, string | number>;
15
+ name: Schema<string, string>;
16
+ }>, Schemastery.ObjectT<{
17
+ group_id: Schema<string | number, string | number>;
18
+ name: Schema<string, string>;
19
+ }>>;
20
+ _handle(payload: Payload): Promise<{
21
+ folder_id: string;
22
+ }>;
23
+ }
24
+ export {};
@@ -0,0 +1,15 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ message_id: number | string;
5
+ }
6
+ export declare class DeleteEssenceMsg extends BaseAction<Payload, null> {
7
+ actionName: ActionName;
8
+ payloadSchema: Schema<Schemastery.ObjectS<{
9
+ message_id: Schema<string | number, string | number>;
10
+ }>, Schemastery.ObjectT<{
11
+ message_id: Schema<string | number, string | number>;
12
+ }>>;
13
+ protected _handle(payload: Payload): Promise<null>;
14
+ }
15
+ export {};
@@ -0,0 +1,15 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ user_id: number | string;
5
+ }
6
+ export declare class DeleteFriend extends BaseAction<Payload, null> {
7
+ actionName: ActionName;
8
+ payloadSchema: Schema<Schemastery.ObjectS<{
9
+ user_id: Schema<string | number, string | number>;
10
+ }>, Schemastery.ObjectT<{
11
+ user_id: Schema<string | number, string | number>;
12
+ }>>;
13
+ protected _handle(payload: Payload): Promise<null>;
14
+ }
15
+ export {};
@@ -0,0 +1,21 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ group_id: number | string;
5
+ file_id: string;
6
+ busid: number | string;
7
+ }
8
+ export declare class DeleteGroupFile extends BaseAction<Payload, null> {
9
+ actionName: ActionName;
10
+ payloadSchema: Schema<Schemastery.ObjectS<{
11
+ group_id: Schema<string | number, string | number>;
12
+ file_id: Schema<string, string>;
13
+ busid: Schema<string | number, string | number>;
14
+ }>, Schemastery.ObjectT<{
15
+ group_id: Schema<string | number, string | number>;
16
+ file_id: Schema<string, string>;
17
+ busid: Schema<string | number, string | number>;
18
+ }>>;
19
+ _handle(payload: Payload): Promise<null>;
20
+ }
21
+ export {};
@@ -0,0 +1,18 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ group_id: number | string;
5
+ folder_id: string;
6
+ }
7
+ export declare class DeleteGroupFolder extends BaseAction<Payload, null> {
8
+ actionName: ActionName;
9
+ payloadSchema: Schema<Schemastery.ObjectS<{
10
+ group_id: Schema<string | number, string | number>;
11
+ folder_id: Schema<string, string>;
12
+ }>, Schemastery.ObjectT<{
13
+ group_id: Schema<string | number, string | number>;
14
+ folder_id: Schema<string, string>;
15
+ }>>;
16
+ _handle(payload: Payload): Promise<null>;
17
+ }
18
+ export {};
@@ -0,0 +1,27 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ thread_count?: number;
5
+ url?: string;
6
+ base64?: string;
7
+ name?: string;
8
+ headers?: string | string[];
9
+ }
10
+ interface FileResponse {
11
+ file: string;
12
+ }
13
+ export declare class DownloadFile extends BaseAction<Payload, FileResponse> {
14
+ actionName: ActionName;
15
+ payloadSchema: Schema<Schemastery.ObjectS<{
16
+ url: Schema<string, string>;
17
+ base64: Schema<string, string>;
18
+ headers: Schema<string | string[], string | string[]>;
19
+ }>, Schemastery.ObjectT<{
20
+ url: Schema<string, string>;
21
+ base64: Schema<string, string>;
22
+ headers: Schema<string | string[], string | string[]>;
23
+ }>>;
24
+ protected _handle(payload: Payload): Promise<FileResponse>;
25
+ getHeaders(headersIn?: string | string[]): Record<string, string>;
26
+ }
27
+ export {};
@@ -0,0 +1,25 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { OB11ForwardMessage } from '../../types';
3
+ import { ActionName } from '../types';
4
+ import { ParseMessageConfig } from '../../types';
5
+ interface Payload {
6
+ message_id: string;
7
+ id?: string;
8
+ }
9
+ interface Response {
10
+ messages: OB11ForwardMessage[];
11
+ }
12
+ export declare class GetForwardMsg extends BaseAction<Payload, Response> {
13
+ actionName: ActionName;
14
+ payloadSchema: Schema<Schemastery.ObjectS<{
15
+ message_id: Schema<string, string>;
16
+ id: Schema<string, string>;
17
+ }>, Schemastery.ObjectT<{
18
+ message_id: Schema<string, string>;
19
+ id: Schema<string, string>;
20
+ }>>;
21
+ protected _handle(payload: Payload, config: ParseMessageConfig): Promise<{
22
+ messages: OB11ForwardMessage[];
23
+ }>;
24
+ }
25
+ export {};
@@ -0,0 +1,24 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ group_id: number | string;
5
+ }
6
+ interface Response {
7
+ can_at_all: boolean;
8
+ remain_at_all_count_for_group: number;
9
+ remain_at_all_count_for_uin: number;
10
+ }
11
+ export declare class GetGroupAtAllRemain extends BaseAction<Payload, Response> {
12
+ actionName: ActionName;
13
+ payloadSchema: Schema<Schemastery.ObjectS<{
14
+ group_id: Schema<string | number, string | number>;
15
+ }>, Schemastery.ObjectT<{
16
+ group_id: Schema<string | number, string | number>;
17
+ }>>;
18
+ _handle(payload: Payload): Promise<{
19
+ can_at_all: boolean;
20
+ remain_at_all_count_for_group: number;
21
+ remain_at_all_count_for_uin: number;
22
+ }>;
23
+ }
24
+ export {};
@@ -0,0 +1,24 @@
1
+ import { BaseAction, Schema } from '../BaseAction';
2
+ import { ActionName } from '../types';
3
+ interface Payload {
4
+ group_id: number | string;
5
+ }
6
+ interface EssenceMsg {
7
+ sender_id: number;
8
+ sender_nick: string;
9
+ sender_time: number;
10
+ operator_id: number;
11
+ operator_nick: string;
12
+ operator_time: number;
13
+ message_id: number;
14
+ }
15
+ export declare class GetEssenceMsgList extends BaseAction<Payload, EssenceMsg[]> {
16
+ actionName: ActionName;
17
+ payloadSchema: Schema<Schemastery.ObjectS<{
18
+ group_id: Schema<string | number, string | number>;
19
+ }>, Schemastery.ObjectT<{
20
+ group_id: Schema<string | number, string | number>;
21
+ }>>;
22
+ protected _handle(payload: Payload): Promise<EssenceMsg[]>;
23
+ }
24
+ export {};