node-karin 0.5.1 → 0.6.2

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.
@@ -1,12 +1,12 @@
1
1
  import WebSocket from 'ws';
2
2
  import { IncomingMessage } from 'http';
3
- import { KarinAdapter } from '../../types/adapter.js';
3
+ import { KarinAdapter } from '../../types/index.js';
4
4
  import { contact, OneBot11Api, KarinElement, OneBot11Segment, CustomNodeSegment, OneBot11ApiParamsType, GroupInfo, KarinNodeElement } from '../../types/index.js';
5
5
  /**
6
6
  * @class OneBot11
7
7
  * @extends KarinAdapter
8
8
  */
9
- export declare class OneBot11 implements KarinAdapter {
9
+ export declare class AdapterOneBot11 implements KarinAdapter {
10
10
  #private;
11
11
  /**
12
12
  * - 重连次数 仅正向ws使用
@@ -106,7 +106,6 @@ export declare class OneBot11 implements KarinAdapter {
106
106
  * 撤回消息
107
107
  * @param _contact - ob11无需提供contact参数
108
108
  * @param message_id - 消息ID
109
- * @returns {Promise<null>}
110
109
  */
111
110
  RecallMessage(_contact: contact, message_id: string): Promise<any>;
112
111
  /**
@@ -152,9 +151,9 @@ export declare class OneBot11 implements KarinAdapter {
152
151
  /**
153
152
  * 群组全员禁言
154
153
  * @param group_id - 群号
155
- * @param enable - 是否全员禁言
154
+ * @param is_ban - 是否全员禁言
156
155
  */
157
- SetGroupWholeBan(group_id: string, enable?: boolean): Promise<void>;
156
+ SetGroupWholeBan(group_id: string, is_ban?: boolean): Promise<void>;
158
157
  /**
159
158
  * 设置群管理员
160
159
  * @param {{
@@ -217,7 +216,6 @@ export declare class OneBot11 implements KarinAdapter {
217
216
  GetStrangerProfileCard(target_uid_or_uin: Array<string>): Promise<any[]>;
218
217
  /**
219
218
  * 获取好友列表
220
- * @returns {Promise<Array<IFriendInfo>>} - 好友列表
221
219
  */
222
220
  GetFriendList(): Promise<any>;
223
221
  /**
@@ -279,9 +277,9 @@ export declare class OneBot11 implements KarinAdapter {
279
277
  SetEssenceMessage(): Promise<void>;
280
278
  DeleteEssenceMessage(): Promise<void>;
281
279
  SetFriendApplyResult(): Promise<void>;
282
- SetGroupApplyResultRequest(): Promise<void>;
280
+ SetGroupApplyResult(): Promise<void>;
283
281
  SetInvitedJoinGroupResult(): Promise<void>;
284
- ReactMessageWithEmojiRequest(): Promise<void>;
282
+ ReactMessageWithEmoji(): Promise<void>;
285
283
  UploadPrivateFile(): Promise<void>;
286
284
  UploadGroupFile(): Promise<void>;
287
285
  sendForwardMessage(): Promise<{}>;
@@ -296,6 +294,6 @@ export declare class OneBot11 implements KarinAdapter {
296
294
  declare const _default: {
297
295
  type: string;
298
296
  path: string;
299
- adapter: typeof OneBot11;
297
+ adapter: typeof AdapterOneBot11;
300
298
  };
301
299
  export default _default;
@@ -7,7 +7,7 @@ import { KarinMessage, KarinNotice, KarinRequest } from '../../event/index.js';
7
7
  * @class OneBot11
8
8
  * @extends KarinAdapter
9
9
  */
10
- export class OneBot11 {
10
+ export class AdapterOneBot11 {
11
11
  /**
12
12
  * 是否初始化
13
13
  */
@@ -173,6 +173,7 @@ export class OneBot11 {
173
173
  case 'message_sent': {
174
174
  const message = {
175
175
  event: (data.post_type + ''),
176
+ event_id: data.message_id + '',
176
177
  self_id: data.self_id + '',
177
178
  user_id: data.sender.user_id + '',
178
179
  time: data.time,
@@ -191,7 +192,7 @@ export class OneBot11 {
191
192
  peer: data.message_type === 'private' ? data.sender.user_id : data.group_id,
192
193
  sub_peer: '',
193
194
  },
194
- group_id: 'group_id' in data ? data.group_id : '',
195
+ group_id: data.message_type === 'group' ? data.group_id : '',
195
196
  raw_message: '',
196
197
  };
197
198
  const e = new KarinMessage(message);
@@ -212,10 +213,10 @@ export class OneBot11 {
212
213
  }
213
214
  case 'notice':
214
215
  this.#notice_event(data);
215
- break;
216
+ return;
216
217
  case 'request':
217
218
  this.#request_event(data);
218
- break;
219
+ return;
219
220
  default:
220
221
  this.logger('info', `未知事件:${JSON.stringify(data)}`);
221
222
  }
@@ -248,12 +249,11 @@ export class OneBot11 {
248
249
  operator_uid: data.user_id + '',
249
250
  operator_uin: data.user_id + '',
250
251
  file_id: data.file.id,
251
- file_sub_id: '',
252
+ file_sub_id: 0,
252
253
  file_name: data.file.name,
253
254
  file_size: data.file.size,
254
- bus_id: 0,
255
255
  expire_time: 0,
256
- url: '',
256
+ file_url: '',
257
257
  };
258
258
  const options = {
259
259
  time,
@@ -401,7 +401,7 @@ export class OneBot11 {
401
401
  sender,
402
402
  contact,
403
403
  content,
404
- sub_event: 'group_recall',
404
+ sub_event: 'private_recall',
405
405
  };
406
406
  notice = new KarinNotice(options);
407
407
  break;
@@ -427,7 +427,7 @@ export class OneBot11 {
427
427
  sender,
428
428
  contact,
429
429
  content,
430
- sub_event: 'group_poke',
430
+ sub_event: data.group_id ? 'group_poke' : 'private_poke',
431
431
  };
432
432
  notice = new KarinNotice(options);
433
433
  break;
@@ -488,7 +488,7 @@ export class OneBot11 {
488
488
  nick: '',
489
489
  role: '',
490
490
  },
491
- sub_event: 'friend_apply',
491
+ sub_event: 'private_apply',
492
492
  content: {
493
493
  applier_uid: data.user_id + '',
494
494
  applier_uin: data.user_id + '',
@@ -803,7 +803,6 @@ export class OneBot11 {
803
803
  * 撤回消息
804
804
  * @param _contact - ob11无需提供contact参数
805
805
  * @param message_id - 消息ID
806
- * @returns {Promise<null>}
807
806
  */
808
807
  async RecallMessage(_contact, message_id) {
809
808
  return await this.SendApi('delete_msg', { message_id });
@@ -887,10 +886,10 @@ export class OneBot11 {
887
886
  /**
888
887
  * 群组全员禁言
889
888
  * @param group_id - 群号
890
- * @param enable - 是否全员禁言
889
+ * @param is_ban - 是否全员禁言
891
890
  */
892
- async SetGroupWholeBan(group_id, enable = true) {
893
- await this.SendApi('set_group_whole_ban', { group_id, enable });
891
+ async SetGroupWholeBan(group_id, is_ban = true) {
892
+ await this.SendApi('set_group_whole_ban', { group_id, enable: is_ban });
894
893
  }
895
894
  /**
896
895
  * 设置群管理员
@@ -997,7 +996,6 @@ export class OneBot11 {
997
996
  }
998
997
  /**
999
998
  * 获取好友列表
1000
- * @returns {Promise<Array<IFriendInfo>>} - 好友列表
1001
999
  */
1002
1000
  async GetFriendList() {
1003
1001
  /** @type {{
@@ -1217,7 +1215,7 @@ export class OneBot11 {
1217
1215
  // * @param message_id - 消息ID
1218
1216
  // * @param face_id - 表情ID
1219
1217
  // */
1220
- // async ReactMessageWithEmojiRequest(Contact: any, message_id: any, face_id: any, is_set = true) {
1218
+ // async ReactMessageWithEmoji(Contact: any, message_id: any, face_id: any, is_set = true) {
1221
1219
  // return await this.SendApi('set_msg_emoji_like', { message_id, emoji_id: face_id, is_set })
1222
1220
  // }
1223
1221
  /**
@@ -1235,9 +1233,9 @@ export class OneBot11 {
1235
1233
  async SetEssenceMessage() { }
1236
1234
  async DeleteEssenceMessage() { }
1237
1235
  async SetFriendApplyResult() { }
1238
- async SetGroupApplyResultRequest() { }
1236
+ async SetGroupApplyResult() { }
1239
1237
  async SetInvitedJoinGroupResult() { }
1240
- async ReactMessageWithEmojiRequest() { }
1238
+ async ReactMessageWithEmoji() { }
1241
1239
  async UploadPrivateFile() { }
1242
1240
  async UploadGroupFile() { }
1243
1241
  async sendForwardMessage() {
@@ -1256,8 +1254,13 @@ export class OneBot11 {
1256
1254
  const request = JSON.stringify({ echo, action, params });
1257
1255
  logger.debug(`[API请求] ${action}: ${request}`);
1258
1256
  return new Promise((resolve, reject) => {
1257
+ const timeoutId = setTimeout(() => {
1258
+ reject(new Error('API请求超时'));
1259
+ }, time * 1000);
1259
1260
  this.socket.send(request);
1260
1261
  this.socket.once(echo, data => {
1262
+ /** 停止监听器 */
1263
+ clearTimeout(timeoutId);
1261
1264
  if (data.status === 'ok') {
1262
1265
  resolve(data.data);
1263
1266
  }
@@ -1266,15 +1269,11 @@ export class OneBot11 {
1266
1269
  reject(data);
1267
1270
  }
1268
1271
  });
1269
- /** 设置一个超时计时器 */
1270
- setTimeout(() => {
1271
- reject(new Error('API请求超时'));
1272
- }, time * 1000);
1273
1272
  });
1274
1273
  }
1275
1274
  }
1276
1275
  export default {
1277
1276
  type: 'websocket',
1278
1277
  path: '/onebot/v11/ws',
1279
- adapter: OneBot11,
1278
+ adapter: AdapterOneBot11,
1280
1279
  };
package/lib/core/dir.d.ts CHANGED
@@ -1 +1,4 @@
1
+ /**
2
+ * - 获取当前npm包的根目录
3
+ */
1
4
  export declare const karinDir: string;
package/lib/core/dir.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import path from 'path'
2
2
  import { fileURLToPath } from 'url'
3
3
  const filename = fileURLToPath(import.meta.url)
4
+ /**
5
+ * - 获取当前npm包的根目录
6
+ */
4
7
  export const karinDir = path.resolve(filename, '../../../').replace(/\\/g, '/').replace(/\/$/, '')
@@ -111,7 +111,7 @@ export const pluginLoader = new (class PluginLoader {
111
111
  * 一共3种模式
112
112
  * 1. npm run dev 开发模式 直接加载ts,js文件,对于同时存在编译产物、源代码的情况,优先加载编译产物而不加载源代码
113
113
  * 2. node . 生产模式 只加载js文件
114
- * 3. npm run debug 调试模式 在2的基础上,对apps进行热更新
114
+ * 3. npm run debug 调试模式 利用tsx自身的热更新机制,重启karin
115
115
  */
116
116
  /** 非插件包 加载该文件夹下全部js 视语言环境加载ts */
117
117
  if (!common.isPlugin(PluginPath)) {
@@ -131,6 +131,18 @@ export const pluginLoader = new (class PluginLoader {
131
131
  this.watchList.push({ dir, name: index })
132
132
  this.FileList.push({ dir, name: index })
133
133
  }
134
+ /** 检查是否存在karin.apps */
135
+ const pack = common.readJson(`${PluginPath}/package.json`)
136
+ if (pack && pack?.karin?.apps) {
137
+ const cfg = pack.karin.apps
138
+ if (Array.isArray(cfg)) {
139
+ cfg.forEach((apps) => {
140
+ /** 路径不存在跳过 */
141
+ if (!common.isDir(`${PluginPath}/${apps}`)) { return }
142
+ this.getApps((`${dir}/${apps}`), this.isTs)
143
+ })
144
+ }
145
+ }
134
146
  /** ts环境 全部加载 如果存在编译产物 则不加载ts */
135
147
  if (this.isTs) {
136
148
  /** 编译产物 存在不加载ts */
@@ -6,7 +6,7 @@ import { createServer } from 'http'
6
6
  import express from 'express'
7
7
  import { exec, config, logger, common } from '../utils/index.js'
8
8
  import { render, HttpRenderer, Wormhole, RenderClient } from '../render/index.js'
9
- import { OneBot11 } from '../adapter/onebot/onebot11.js'
9
+ import { AdapterOneBot11 } from '../adapter/onebot/onebot11.js'
10
10
  export const server = new (class Server {
11
11
  reg
12
12
  list
@@ -120,7 +120,7 @@ export const server = new (class Server {
120
120
  const Onebot11 = config.Server.websocket.OneBot11Host
121
121
  if (Array.isArray(Onebot11) && Onebot11.length) {
122
122
  for (const connect of Onebot11) {
123
- new OneBot11().client(connect)
123
+ new AdapterOneBot11().client(connect)
124
124
  }
125
125
  }
126
126
  const { enable, WormholeClient } = config.Server.HttpRender
@@ -3,5 +3,7 @@ export * from './event.handler.js';
3
3
  export * from './message.js';
4
4
  export * from './message.handler.js';
5
5
  export * from './notice.js';
6
+ export * from './notice.handler.js';
6
7
  export * from './request.js';
8
+ export * from './request.handler.js';
7
9
  export * from './review.handler.js';
@@ -3,7 +3,7 @@ export * from './event.handler.js'
3
3
  export * from './message.js'
4
4
  export * from './message.handler.js'
5
5
  export * from './notice.js'
6
- // export * from './notice.handler.js'
6
+ export * from './notice.handler.js'
7
7
  export * from './request.js'
8
- // export * from './request.handler.js'
8
+ export * from './request.handler.js'
9
9
  export * from './review.handler.js'
@@ -4,11 +4,15 @@ import { contact, Sender, KarinElement } from '../types/index.js';
4
4
  * - 消息事件基类
5
5
  */
6
6
  export declare class KarinMessage extends KarinEvent {
7
- constructor({ event, self_id, user_id, time, message_id, message_seq, raw_message, contact, sender, elements, group_id, }: {
7
+ constructor({ event, event_id, self_id, user_id, time, message_id, message_seq, raw_message, contact, sender, elements, group_id, }: {
8
8
  /**
9
9
  * - 事件类型
10
10
  */
11
11
  event: 'message' | 'message_sent';
12
+ /**
13
+ * - 事件ID
14
+ */
15
+ event_id: string;
12
16
  /**
13
17
  * - 机器人ID 请尽量使用UID
14
18
  */
@@ -3,8 +3,8 @@ import { KarinEvent } from './event.js'
3
3
  * - 消息事件基类
4
4
  */
5
5
  export class KarinMessage extends KarinEvent {
6
- constructor ({ event = 'message', self_id, user_id, time, message_id, message_seq = '', raw_message = '', contact, sender, elements, group_id = '' }) {
7
- super({ event, event_id: message_id, self_id, user_id, group_id, time, contact, sender, sub_event: contact.scene === 'group' ? 'group_message' : 'friend_message' })
6
+ constructor ({ event = 'message', event_id, self_id, user_id, time, message_id, message_seq = '', raw_message = '', contact, sender, elements, group_id = '' }) {
7
+ super({ event, event_id: event_id || message_id, self_id, user_id, group_id, time, contact, sender, sub_event: contact.scene === 'group' ? 'group_message' : 'private_message' })
8
8
  this.message_id = message_id
9
9
  this.message_seq = message_seq
10
10
  this.raw_message = raw_message
@@ -84,20 +84,20 @@ export default class NoticeHandler extends EventHandler {
84
84
  raw_message () {
85
85
  switch (this.e.sub_event) {
86
86
  /** 好友头像戳一戳 */
87
- case 'friend_poke': {
87
+ case 'private_poke': {
88
88
  this.e.raw_message = '[好友戳一戳]: 戳了你一下'
89
89
  break
90
90
  }
91
91
  /** 好友消息撤回 */
92
- case 'friend_recall': {
92
+ case 'private_recall': {
93
93
  this.e.raw_message = `[好友消息撤回]: ${this.e.content.message_id}`
94
94
  break
95
95
  }
96
96
  /** 私聊文件上传 */
97
- case 'friend_file_uploaded': {
97
+ case 'private_file_uploaded': {
98
98
  const content = this.e.content
99
- const { url } = content
100
- this.e.raw_message = `[私聊文件上传]: ${url}`
99
+ const { file_url } = content
100
+ this.e.raw_message = `[私聊文件上传]: ${file_url}`
101
101
  break
102
102
  }
103
103
  /** 群头像戳一戳 */
@@ -114,8 +114,8 @@ export default class NoticeHandler extends EventHandler {
114
114
  }
115
115
  /** 群文件上传 */
116
116
  case 'group_file_uploaded': {
117
- const { url, operator_uid, operator_uin } = this.e.content
118
- this.e.raw_message = `[群文件上传]: ${operator_uid || operator_uin} 上传了 ${url}`
117
+ const { file_url, operator_uid, operator_uin } = this.e.content
118
+ this.e.raw_message = `[群文件上传]: ${operator_uid || operator_uin} 上传了 ${file_url}`
119
119
  break
120
120
  }
121
121
  /** 群成员增加 */
@@ -160,7 +160,7 @@ export default class NoticeHandler extends EventHandler {
160
160
  break
161
161
  }
162
162
  /** 群签到 */
163
- case 'group_sign': {
163
+ case 'group_sign_in': {
164
164
  const { target_uid, target_uin } = this.e.content
165
165
  this.e.raw_message = `[群签到]: ${target_uid || target_uin}`
166
166
  break
@@ -84,7 +84,7 @@ export default class RequestHandler extends EventHandler {
84
84
  raw_message () {
85
85
  switch (this.e.sub_event) {
86
86
  /** 好友申请 */
87
- case 'friend_apply': {
87
+ case 'private_apply': {
88
88
  const { applier_uid, applier_uin, message } = this.e.content
89
89
  this.e.raw_message = `[好友申请]: ${applier_uid || applier_uin} 申请理由: ${message}`
90
90
  break
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './db/index.js';
5
5
  export * from './render/index.js';
6
6
  export * from './utils/index.js';
7
7
  export * from './types/index.js';
8
+ export * from './adapter/index.js';
8
9
  import { Karin, Plugin } from './core/index.js';
9
10
  /**
10
11
  * @description 即将废弃,请使用 `Plugin`
@@ -36,7 +37,7 @@ export declare const Cfg: {
36
37
  logger: import("log4js").Logger;
37
38
  initCfg(): Promise<void>;
38
39
  getPlugins(): string[];
39
- checkPath(path: string): void;
40
+ mkdir(dirname: string): boolean;
40
41
  dirPath(name: string, plugins: string[]): Promise<void>;
41
42
  timeout(type?: "ws" | "grpc"): number;
42
43
  readonly redis: import("./types/index.js").Redis;
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@ export * from './db/index.js';
11
11
  export * from './render/index.js';
12
12
  export * from './utils/index.js';
13
13
  export * from './types/index.js';
14
+ export * from './adapter/index.js';
14
15
  import { config, update } from './utils/index.js';
15
16
  import { render } from './render/index.js';
16
17
  import { RenderServer } from './render/index.js';
package/lib/modules.d.ts CHANGED
@@ -11,4 +11,5 @@ import { Level as level } from 'level';
11
11
  import schedule from 'node-schedule';
12
12
  import yaml from 'yaml';
13
13
  import log4js from 'log4js';
14
- export { fs, ws, path, axios, lodash, moment, express, chalk, chokidar, level, schedule, yaml, log4js, };
14
+ import art_template from 'art-template';
15
+ export { fs, ws, path, axios, lodash, moment, express, chalk, chokidar, level, schedule, yaml, log4js, art_template, };
package/lib/modules.js CHANGED
@@ -11,4 +11,5 @@ import { Level as level } from 'level';
11
11
  import schedule from 'node-schedule';
12
12
  import yaml from 'yaml';
13
13
  import log4js from 'log4js';
14
- export { fs, ws, path, axios, lodash, moment, express, chalk, chokidar, level, schedule, yaml, log4js, };
14
+ import art_template from 'art-template';
15
+ export { fs, ws, path, axios, lodash, moment, express, chalk, chokidar, level, schedule, yaml, log4js, art_template, };
package/lib/tools/init.js CHANGED
@@ -23,15 +23,13 @@ for (const dir of delList) {
23
23
  if (!fs.existsSync(path)) { fs.copyFileSync(pathDef, path) }
24
24
  }
25
25
  }
26
- // 判断是否为第一次使用
27
- if (!fs.existsSync('./index.js')) {
28
- // 创建一个index.js文件 以供初次开箱使用,写入默认配置
29
- fs.writeFileSync('./index.js', `import { Bot } from 'node-karin'
30
- console.log(Bot.name + '开始初始化~')
31
- `)
32
- }
33
26
  // 修改package.json为esm模块
34
27
  const pack = JSON.parse(fs.readFileSync('./package.json', 'utf-8'))
35
- pack.type = 'module'
36
- fs.writeFileSync('./package.json', JSON.stringify(pack, null, 2))
37
- console.log('初始化完成~,请通过 node index 启动程序~')
28
+ // 解析包内的package.json文件
29
+ const npmPack = JSON.parse(fs.readFileSync(`${karinDir}/package.json`, 'utf-8'))
30
+ npmPack.main = './node_modules/node-karin/lib/index.js'
31
+ delete npmPack.bin
32
+ delete npmPack.types
33
+ npmPack.dependencies = pack.dependencies
34
+ fs.writeFileSync('./package.json', JSON.stringify(npmPack, null, 2))
35
+ console.log('初始化完成~,请通过 【 node . 】 启动程序~')
@@ -325,7 +325,7 @@ export interface KarinAdapter {
325
325
  /**
326
326
  * - 是否开启全员禁言
327
327
  */
328
- enable: boolean): Promise<void>;
328
+ is_ban: boolean): Promise<void>;
329
329
  /**
330
330
  * - 设置群管理员
331
331
  */
@@ -520,7 +520,7 @@ export interface KarinAdapter {
520
520
  /**
521
521
  * - 设置申请加入群请求结果
522
522
  */
523
- SetGroupApplyResultRequest(
523
+ SetGroupApplyResult(
524
524
  /**
525
525
  * - 请求ID
526
526
  */
@@ -545,7 +545,6 @@ export interface KarinAdapter {
545
545
  * 发送合并转发消息
546
546
  * @param contact 联系人信息
547
547
  * @param elements 消息元素
548
- * @return {Promise<{message_id?}>}
549
548
  */
550
549
  sendForwardMessage(contact: contact, elements: Array<KarinNodeElement>): Promise<{
551
550
  message_id?: string;
@@ -556,7 +555,7 @@ export interface KarinAdapter {
556
555
  * @param message_id - 消息ID
557
556
  * @param face_id - 表情ID
558
557
  */
559
- ReactMessageWithEmojiRequest(contact: contact, message_id: string, face_id: number, is_set: boolean): Promise<void>;
558
+ ReactMessageWithEmoji(contact: contact, message_id: string, face_id: number, is_set: boolean): Promise<void>;
560
559
  /**
561
560
  * 上传群文件
562
561
  * @param group_id - 群号
@@ -89,7 +89,7 @@ export interface ImageElement extends Element {
89
89
  */
90
90
  md5?: string;
91
91
  /** 图片子类型 */
92
- sub_type?: number;
92
+ sub_type?: string;
93
93
  /**
94
94
  * - 图片宽度
95
95
  */
@@ -107,6 +107,7 @@ export interface ImageElement extends Element {
107
107
  }
108
108
  /**
109
109
  * - 语音元素
110
+ * @deprecated 即将废弃 请使用segment.record
110
111
  */
111
112
  export interface VoiceElement extends Element {
112
113
  type: 'voice';
@@ -244,6 +245,7 @@ export interface CustomMusicElemen {
244
245
  * - 封面
245
246
  */
246
247
  pic: string;
248
+ id: string;
247
249
  }
248
250
  export interface MusicElement extends Element {
249
251
  type: 'music';
@@ -13,11 +13,11 @@ export type Scene = 'group' | 'private' | 'guild' | 'nearby' | 'stranger' | 'str
13
13
  * - 类型映射
14
14
  */
15
15
  export type EventToSubEvent = {
16
- message: 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
17
- notice: 'friend_poke' | 'friend_recall' | 'friend_file_uploaded' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_ban' | 'group_sign' | 'group_whole_ban' | 'group_file_uploaded' | 'group_message_reaction';
18
- request: 'friend_apply' | 'group_apply' | 'invited_group';
19
- meta_event: 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
20
- message_sent: 'group_message' | 'friend_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
16
+ message: 'group_message' | 'private_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
17
+ notice: 'private_poke' | 'private_recall' | 'private_file_uploaded' | 'group_poke' | 'group_card_changed' | 'group_member_unique_title_changed' | 'group_essence_changed' | 'group_recall' | 'group_member_increase' | 'group_member_decrease' | 'group_admin_changed' | 'group_member_ban' | 'group_sign_in' | 'group_whole_ban' | 'group_file_uploaded' | 'group_message_reaction';
18
+ request: 'private_apply' | 'group_apply' | 'invited_group';
19
+ meta_event: 'group_message' | 'private_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
20
+ message_sent: 'group_message' | 'private_message' | 'guild_message' | 'nearby' | 'stranger' | 'stranger_from_group';
21
21
  };
22
22
  /**
23
23
  * - 事件子类型
@@ -76,7 +76,7 @@ export interface NoticeType {
76
76
  /**
77
77
  * - 私聊戳一戳
78
78
  */
79
- friend_poke: {
79
+ private_poke: {
80
80
  /**
81
81
  * - 操作者uid
82
82
  */
@@ -101,7 +101,7 @@ export interface NoticeType {
101
101
  /**
102
102
  * - 私聊撤回消息
103
103
  */
104
- friend_recall: {
104
+ private_recall: {
105
105
  /**
106
106
  * - 操作者uid
107
107
  */
@@ -123,7 +123,7 @@ export interface NoticeType {
123
123
  * - 私聊文件上传
124
124
  * - 文件信息最少需要提供一个url
125
125
  */
126
- friend_file_uploaded: {
126
+ private_file_uploaded: {
127
127
  /**
128
128
  * - 操作者uid
129
129
  */
@@ -139,7 +139,7 @@ export interface NoticeType {
139
139
  /**
140
140
  * - 文件子ID 此项没有则为空字符串
141
141
  */
142
- file_sub_id: string;
142
+ file_sub_id: number;
143
143
  /**
144
144
  * - 文件名 此项没有则为空字符串
145
145
  */
@@ -155,7 +155,7 @@ export interface NoticeType {
155
155
  /**
156
156
  * - 文件URL
157
157
  */
158
- url: string;
158
+ file_url: string;
159
159
  };
160
160
  /**
161
161
  * - 群聊戳一戳
@@ -239,9 +239,9 @@ export interface NoticeType {
239
239
  */
240
240
  file_id: string;
241
241
  /**
242
- * - 文件子ID 此项没有则为空字符串
242
+ * - 文件子ID 此项没有则为0
243
243
  */
244
- file_sub_id: string;
244
+ file_sub_id: number;
245
245
  /**
246
246
  * - 文件名 此项没有则为空字符串
247
247
  */
@@ -250,10 +250,6 @@ export interface NoticeType {
250
250
  * - 文件大小 此项没有则为0
251
251
  */
252
252
  file_size: number;
253
- /**
254
- * - 目前未知
255
- */
256
- bus_id: number;
257
253
  /**
258
254
  * - 过期时间 此项没有则为0
259
255
  */
@@ -261,7 +257,7 @@ export interface NoticeType {
261
257
  /**
262
258
  * - 文件URL
263
259
  */
264
- url: string;
260
+ file_url: string;
265
261
  };
266
262
  /**
267
263
  * - 群名片变动
@@ -420,7 +416,7 @@ export interface NoticeType {
420
416
  /**
421
417
  * - 群打卡
422
418
  */
423
- group_sign: {
419
+ group_sign_in: {
424
420
  /**
425
421
  * - 群ID
426
422
  */
@@ -525,7 +521,7 @@ export interface RequestType {
525
521
  /**
526
522
  * - 好友申请
527
523
  */
528
- friend_apply: {
524
+ private_apply: {
529
525
  /**
530
526
  * - 申请者uid
531
527
  */
@@ -759,7 +755,7 @@ export type NoticeEvent<T extends keyof NoticeType> = KarinNoticeEventBase & {
759
755
  /**
760
756
  * - 通知事件基类
761
757
  */
762
- export type KarinNoticeEvent = NoticeEvent<'friend_poke'> | NoticeEvent<'friend_recall'> | NoticeEvent<'friend_file_uploaded'> | NoticeEvent<'group_poke'> | NoticeEvent<'group_card_changed'> | NoticeEvent<'group_member_unique_title_changed'> | NoticeEvent<'group_essence_changed'> | NoticeEvent<'group_recall'> | NoticeEvent<'group_member_increase'> | NoticeEvent<'group_member_decrease'> | NoticeEvent<'group_admin_changed'> | NoticeEvent<'group_member_ban'> | NoticeEvent<'group_sign'> | NoticeEvent<'group_whole_ban'> | NoticeEvent<'group_file_uploaded'> | NoticeEvent<'group_message_reaction'>;
758
+ export type KarinNoticeEvent = NoticeEvent<'private_poke'> | NoticeEvent<'private_recall'> | NoticeEvent<'private_file_uploaded'> | NoticeEvent<'group_poke'> | NoticeEvent<'group_card_changed'> | NoticeEvent<'group_member_unique_title_changed'> | NoticeEvent<'group_essence_changed'> | NoticeEvent<'group_recall'> | NoticeEvent<'group_member_increase'> | NoticeEvent<'group_member_decrease'> | NoticeEvent<'group_admin_changed'> | NoticeEvent<'group_member_ban'> | NoticeEvent<'group_sign_in'> | NoticeEvent<'group_whole_ban'> | NoticeEvent<'group_file_uploaded'> | NoticeEvent<'group_message_reaction'>;
763
759
  /**
764
760
  * - 请求事件基类
765
761
  */
@@ -776,7 +772,7 @@ export type RequestEvent<T extends keyof RequestType> = KarinRequestEventBase &
776
772
  /**
777
773
  * - 请求事件基类
778
774
  */
779
- export type KarinRequestEvent = RequestEvent<'friend_apply'> | RequestEvent<'group_apply'> | RequestEvent<'invited_group'>;
775
+ export type KarinRequestEvent = RequestEvent<'private_apply'> | RequestEvent<'group_apply'> | RequestEvent<'invited_group'>;
780
776
  export interface EMap {
781
777
  message: KarinMessageEvent;
782
778
  notice: KarinNoticeEvent;
@@ -57,6 +57,10 @@ export declare const common: {
57
57
  * @returns 返回true为存在
58
58
  */
59
59
  exists(path: string): boolean;
60
+ /**
61
+ * - 解析json文件
62
+ */
63
+ readJson(file: string): any;
60
64
  /**
61
65
  * 根据文件后缀名从指定路径下读取符合要求的文件
62
66
  * @param path - 路径