@onebots/adapter-kook 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 凉菜
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # @onebots/adapter-kook
2
+
3
+ onebots KOOK (开黑了) 适配器
4
+
5
+ ## 简介
6
+
7
+ 这是一个用于 onebots 框架的 KOOK(原开黑了)平台适配器。KOOK 是一个面向游戏玩家的即时通讯平台,类似于 Discord。
8
+
9
+ ## 功能特性
10
+
11
+ - ✅ WebSocket 和 Webhook 两种连接模式
12
+ - ✅ 频道消息收发
13
+ - ✅ 私聊消息收发
14
+ - ✅ 服务器(公会)管理
15
+ - ✅ 频道管理
16
+ - ✅ 成员管理
17
+ - ✅ 角色管理
18
+ - ✅ 表情回应
19
+ - ✅ 文件上传
20
+ - ✅ KMarkdown 消息格式支持
21
+ - ✅ 卡片消息支持
22
+
23
+ ## 安装
24
+
25
+ ```bash
26
+ npm install @onebots/adapter-kook
27
+ # 或
28
+ pnpm add @onebots/adapter-kook
29
+ ```
30
+
31
+ ## 配置
32
+
33
+ 在配置文件中添加 KOOK 账号:
34
+
35
+ ```yaml
36
+ accounts:
37
+ - platform: kook
38
+ account_id: your_bot_id
39
+ token: your_bot_token
40
+ mode: websocket # 或 webhook
41
+ verifyToken: your_verify_token # Webhook 模式需要
42
+ encryptKey: your_encrypt_key # 可选,消息加密密钥
43
+ ```
44
+
45
+ ### 配置项说明
46
+
47
+ | 配置项 | 类型 | 必填 | 说明 |
48
+ |--------|------|------|------|
49
+ | account_id | string | 是 | 机器人账号 ID |
50
+ | token | string | 是 | 机器人 Token |
51
+ | mode | string | 否 | 连接模式:`websocket`(默认)或 `webhook` |
52
+ | verifyToken | string | 否 | Webhook 验证 Token |
53
+ | encryptKey | string | 否 | 消息加密密钥 |
54
+
55
+ ## 获取 Token
56
+
57
+ 1. 访问 [KOOK 开发者平台](https://developer.kookapp.cn/)
58
+ 2. 创建应用并添加机器人
59
+ 3. 在机器人设置中获取 Token
60
+
61
+ ## 消息类型支持
62
+
63
+ ### 发送消息
64
+
65
+ 支持的消息段类型:
66
+ - `text` - 文本消息
67
+ - `at` - @用户/全体成员/在线成员
68
+ - `image` - 图片消息
69
+ - `face` - 表情
70
+
71
+ ### 接收消息
72
+
73
+ 支持的消息类型:
74
+ - 文字消息
75
+ - KMarkdown 消息
76
+ - 图片消息
77
+ - 视频消息
78
+ - 文件消息
79
+ - 音频消息
80
+ - 卡片消息
81
+
82
+ ## API 支持
83
+
84
+ ### 消息相关
85
+ - `sendMessage` - 发送消息
86
+ - `deleteMessage` - 删除消息
87
+ - `getMessage` - 获取消息
88
+ - `updateMessage` - 更新消息
89
+
90
+ ### 用户相关
91
+ - `getLoginInfo` - 获取机器人信息
92
+ - `getUserInfo` - 获取用户信息
93
+ - `getFriendList` - 获取私聊会话列表
94
+ - `getFriendInfo` - 获取好友信息
95
+
96
+ ### 服务器相关
97
+ - `getGroupList` - 获取服务器列表
98
+ - `getGroupInfo` - 获取服务器信息
99
+ - `leaveGroup` - 退出服务器
100
+ - `getGroupMemberList` - 获取服务器成员列表
101
+ - `getGroupMemberInfo` - 获取成员信息
102
+ - `kickGroupMember` - 踢出成员
103
+ - `setGroupCard` - 设置成员昵称
104
+
105
+ ### 频道相关
106
+ - `getChannelList` - 获取频道列表
107
+ - `getChannelInfo` - 获取频道信息
108
+ - `createChannel` - 创建频道
109
+ - `updateChannel` - 更新频道
110
+ - `deleteChannel` - 删除频道
111
+ - `getChannelMemberList` - 获取频道成员列表
112
+
113
+ ### 公会相关
114
+ - `getGuildList` - 获取服务器列表
115
+ - `getGuildInfo` - 获取服务器信息
116
+ - `getGuildMemberInfo` - 获取成员信息
117
+
118
+ ## 事件支持
119
+
120
+ ### 消息事件
121
+ - 频道消息
122
+ - 私聊消息
123
+
124
+ ### 通知事件
125
+ - 成员加入服务器
126
+ - 成员离开服务器
127
+ - 表情回应添加
128
+ - 消息更新
129
+ - 消息删除
130
+
131
+ ## 许可证
132
+
133
+ MIT
@@ -0,0 +1,137 @@
1
+ /**
2
+ * KOOK (开黑了) 适配器
3
+ * 继承 Adapter 基类,实现 KOOK 平台功能
4
+ * - 消息收发(sendMessage)
5
+ * - 服务器管理(getGroupList, getGroupInfo 等,对应 KOOK 的服务器)
6
+ * - 频道管理(getChannelList, getChannelInfo 等)
7
+ * - 用户管理(getFriendList, getUserInfo 等)
8
+ */
9
+ import { Account } from "onebots";
10
+ import { Adapter } from "onebots";
11
+ import { BaseApp } from "onebots";
12
+ import { KookBot } from "./bot.js";
13
+ import type { KookConfig } from "./types.js";
14
+ export declare class KookAdapter extends Adapter<KookBot, "kook"> {
15
+ constructor(app: BaseApp);
16
+ /**
17
+ * 发送消息
18
+ * KOOK 支持频道消息和私聊消息
19
+ */
20
+ sendMessage(uin: string, params: Adapter.SendMessageParams): Promise<Adapter.SendMessageResult>;
21
+ /**
22
+ * 删除/撤回消息
23
+ */
24
+ deleteMessage(uin: string, params: Adapter.DeleteMessageParams): Promise<void>;
25
+ /**
26
+ * 获取消息
27
+ */
28
+ getMessage(uin: string, params: Adapter.GetMessageParams): Promise<Adapter.MessageInfo>;
29
+ /**
30
+ * 更新消息
31
+ */
32
+ updateMessage(uin: string, params: Adapter.UpdateMessageParams): Promise<void>;
33
+ /**
34
+ * 获取机器人自身信息
35
+ */
36
+ getLoginInfo(uin: string): Promise<Adapter.UserInfo>;
37
+ /**
38
+ * 获取用户信息
39
+ */
40
+ getUserInfo(uin: string, params: Adapter.GetUserInfoParams): Promise<Adapter.UserInfo>;
41
+ /**
42
+ * 获取好友列表(私聊会话列表)
43
+ */
44
+ getFriendList(uin: string, params?: Adapter.GetFriendListParams): Promise<Adapter.FriendInfo[]>;
45
+ /**
46
+ * 获取好友信息
47
+ */
48
+ getFriendInfo(uin: string, params: Adapter.GetFriendInfoParams): Promise<Adapter.FriendInfo>;
49
+ /**
50
+ * 获取群列表(服务器列表)
51
+ */
52
+ getGroupList(uin: string, params?: Adapter.GetGroupListParams): Promise<Adapter.GroupInfo[]>;
53
+ /**
54
+ * 获取群信息(服务器信息)
55
+ */
56
+ getGroupInfo(uin: string, params: Adapter.GetGroupInfoParams): Promise<Adapter.GroupInfo>;
57
+ /**
58
+ * 退出群组(退出服务器)
59
+ */
60
+ leaveGroup(uin: string, params: Adapter.LeaveGroupParams): Promise<void>;
61
+ /**
62
+ * 获取群成员列表(服务器成员列表)
63
+ */
64
+ getGroupMemberList(uin: string, params: Adapter.GetGroupMemberListParams): Promise<Adapter.GroupMemberInfo[]>;
65
+ /**
66
+ * 获取群成员信息
67
+ */
68
+ getGroupMemberInfo(uin: string, params: Adapter.GetGroupMemberInfoParams): Promise<Adapter.GroupMemberInfo>;
69
+ /**
70
+ * 踢出群成员
71
+ */
72
+ kickGroupMember(uin: string, params: Adapter.KickGroupMemberParams): Promise<void>;
73
+ /**
74
+ * 设置群名片(设置服务器昵称)
75
+ */
76
+ setGroupCard(uin: string, params: Adapter.SetGroupCardParams): Promise<void>;
77
+ /**
78
+ * 获取频道列表
79
+ */
80
+ getChannelList(uin: string, params?: Adapter.GetChannelListParams): Promise<Adapter.ChannelInfo[]>;
81
+ /**
82
+ * 获取频道信息
83
+ */
84
+ getChannelInfo(uin: string, params: Adapter.GetChannelInfoParams): Promise<Adapter.ChannelInfo>;
85
+ /**
86
+ * 创建频道
87
+ */
88
+ createChannel(uin: string, params: Adapter.CreateChannelParams): Promise<Adapter.ChannelInfo>;
89
+ /**
90
+ * 更新频道
91
+ */
92
+ updateChannel(uin: string, params: Adapter.UpdateChannelParams): Promise<void>;
93
+ /**
94
+ * 删除频道
95
+ */
96
+ deleteChannel(uin: string, params: Adapter.DeleteChannelParams): Promise<void>;
97
+ /**
98
+ * 获取频道成员列表
99
+ */
100
+ getChannelMemberList(uin: string, params: Adapter.GetChannelMemberListParams): Promise<Adapter.ChannelMemberInfo[]>;
101
+ /**
102
+ * 获取服务器列表
103
+ */
104
+ getGuildList(uin: string): Promise<Adapter.GuildInfo[]>;
105
+ /**
106
+ * 获取服务器信息
107
+ */
108
+ getGuildInfo(uin: string, params: Adapter.GetGuildInfoParams): Promise<Adapter.GuildInfo>;
109
+ /**
110
+ * 获取服务器成员信息
111
+ */
112
+ getGuildMemberInfo(uin: string, params: Adapter.GetGuildMemberInfoParams): Promise<Adapter.GuildMemberInfo>;
113
+ /**
114
+ * 获取版本信息
115
+ */
116
+ getVersion(uin: string): Promise<Adapter.VersionInfo>;
117
+ /**
118
+ * 获取运行状态
119
+ */
120
+ getStatus(uin: string): Promise<Adapter.StatusInfo>;
121
+ createAccount(config: Account.Config<'kook'>): Account<'kook', KookBot>;
122
+ }
123
+ declare module "onebots" {
124
+ namespace Adapter {
125
+ interface Configs {
126
+ kook: KookConfig;
127
+ }
128
+ }
129
+ }
130
+ declare module './adapter.js' {
131
+ namespace Adapter {
132
+ interface Configs {
133
+ kook: KookConfig;
134
+ }
135
+ }
136
+ }
137
+ //# sourceMappingURL=adapter.d.ts.map