node-karin 0.6.6 → 0.6.9

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.
@@ -267,6 +267,13 @@ export declare class AdapterOneBot11 implements KarinAdapter {
267
267
  id: number;
268
268
  description: string;
269
269
  }[]>;
270
+ /**
271
+ * 对消息进行表情回应
272
+ * @param contact - 联系人信息
273
+ * @param message_id - 消息ID
274
+ * @param face_id - 表情ID
275
+ */
276
+ ReactMessageWithEmoji(contact: contact, message_id: string, face_id: number, is_set?: boolean): Promise<any>;
270
277
  /**
271
278
  * 获取版本信息
272
279
  */
@@ -278,10 +285,11 @@ export declare class AdapterOneBot11 implements KarinAdapter {
278
285
  SetFriendApplyResult(): Promise<void>;
279
286
  SetGroupApplyResult(): Promise<void>;
280
287
  SetInvitedJoinGroupResult(): Promise<void>;
281
- ReactMessageWithEmoji(): Promise<void>;
282
288
  UploadPrivateFile(): Promise<void>;
283
289
  UploadGroupFile(): Promise<void>;
284
- sendForwardMessage(): Promise<{}>;
290
+ sendForwardMessage(contact: contact, elements: KarinNodeElement[]): Promise<{
291
+ message_id: any;
292
+ }>;
285
293
  /**
286
294
  * 发送API请求
287
295
  * @param action - API断点
@@ -1208,15 +1208,15 @@ export class AdapterOneBot11 {
1208
1208
  });
1209
1209
  return result;
1210
1210
  }
1211
- // /**
1212
- // * 对消息进行表情回应
1213
- // * @param Contact - 联系人信息
1214
- // * @param message_id - 消息ID
1215
- // * @param face_id - 表情ID
1216
- // */
1217
- // async ReactMessageWithEmoji(Contact: any, message_id: any, face_id: any, is_set = true) {
1218
- // return await this.SendApi('set_msg_emoji_like', { message_id, emoji_id: face_id, is_set })
1219
- // }
1211
+ /**
1212
+ * 对消息进行表情回应
1213
+ * @param contact - 联系人信息
1214
+ * @param message_id - 消息ID
1215
+ * @param face_id - 表情ID
1216
+ */
1217
+ async ReactMessageWithEmoji(contact, message_id, face_id, is_set = true) {
1218
+ return await this.SendApi('set_msg_emoji_like', { message_id, emoji_id: face_id, is_set });
1219
+ }
1220
1220
  /**
1221
1221
  * 获取版本信息
1222
1222
  */
@@ -1234,11 +1234,14 @@ export class AdapterOneBot11 {
1234
1234
  async SetFriendApplyResult() { }
1235
1235
  async SetGroupApplyResult() { }
1236
1236
  async SetInvitedJoinGroupResult() { }
1237
- async ReactMessageWithEmoji() { }
1238
1237
  async UploadPrivateFile() { }
1239
1238
  async UploadGroupFile() { }
1240
- async sendForwardMessage() {
1241
- return {};
1239
+ async sendForwardMessage(contact, elements) {
1240
+ let message_id = await this.UploadForwardMessage(contact, elements);
1241
+ if (this.version.name === 'Lagrange.OneBot') {
1242
+ message_id = await this.SendMessage(contact, [segment.forward(message_id)]);
1243
+ }
1244
+ return { message_id };
1242
1245
  }
1243
1246
  /**
1244
1247
  * 发送API请求
package/lib/index.d.ts CHANGED
@@ -57,7 +57,6 @@ export declare const Cfg: {
57
57
  };
58
58
  export declare const Update: {
59
59
  dir: string;
60
- getPlugins(): string[];
61
60
  update(path: string, cmd?: string, time?: number): Promise<{
62
61
  status: string;
63
62
  data: string;
@@ -848,7 +848,7 @@ export type ByPostType<T extends EventPostType> = Extract<OneBot11Event, {
848
848
  /**
849
849
  * - OneBot11公开Api
850
850
  */
851
- export type OneBot11Api = 'send_private_msg' | 'send_group_msg' | 'send_msg' | 'delete_msg' | 'get_msg' | 'get_forward_msg' | 'send_like' | 'set_group_kick' | 'set_group_ban' | 'set_group_anonymous_ban' | 'set_group_whole_ban' | 'set_group_admin' | 'set_group_anonymous' | 'set_group_card' | 'set_group_name' | 'set_group_leave' | 'set_group_special_title' | 'set_friend_add_request' | 'set_group_add_request' | 'get_login_info' | 'get_stranger_info' | 'get_friend_list' | 'get_group_info' | 'get_group_list' | 'get_group_member_info' | 'get_group_member_list' | 'get_group_honor_info' | 'get_cookies' | 'get_csrf_token' | 'get_credentials' | 'get_record' | 'get_image' | 'can_send_image' | 'can_send_record' | 'get_status' | 'get_version_info' | 'set_restart' | 'clean_cache' | 'get_version' | 'send_forward_msg' | 'get_friend_msg_history' | 'get_group_msg_history';
851
+ export type OneBot11Api = 'send_private_msg' | 'send_group_msg' | 'send_msg' | 'delete_msg' | 'get_msg' | 'get_forward_msg' | 'send_like' | 'set_group_kick' | 'set_group_ban' | 'set_group_anonymous_ban' | 'set_group_whole_ban' | 'set_group_admin' | 'set_group_anonymous' | 'set_group_card' | 'set_group_name' | 'set_group_leave' | 'set_group_special_title' | 'set_friend_add_request' | 'set_group_add_request' | 'get_login_info' | 'get_stranger_info' | 'get_friend_list' | 'get_group_info' | 'get_group_list' | 'get_group_member_info' | 'get_group_member_list' | 'get_group_honor_info' | 'get_cookies' | 'get_csrf_token' | 'get_credentials' | 'get_record' | 'get_image' | 'can_send_image' | 'can_send_record' | 'get_status' | 'get_version_info' | 'set_restart' | 'clean_cache' | 'get_version' | 'send_forward_msg' | 'get_friend_msg_history' | 'get_group_msg_history' | 'set_msg_emoji_like';
852
852
  /**
853
853
  * - OneBot11公开Api参数 params
854
854
  */
@@ -1362,6 +1362,23 @@ export type OneBot11ApiParams = {
1362
1362
  */
1363
1363
  message_count: number;
1364
1364
  };
1365
+ /**
1366
+ * - 对消息进行表情回应
1367
+ */
1368
+ set_msg_emoji_like: {
1369
+ /**
1370
+ * - 需要回应的消息 ID
1371
+ */
1372
+ message_id: string;
1373
+ /**
1374
+ * - 回应的表情 ID
1375
+ */
1376
+ emoji_id: number;
1377
+ /**
1378
+ * - 设置、取消
1379
+ */
1380
+ is_set: boolean;
1381
+ };
1365
1382
  };
1366
1383
  /**
1367
1384
  * - OneBot11公开Api与参数映射
@@ -1,6 +1,5 @@
1
1
  import schedule from 'node-schedule';
2
- import { KarinNodeElement } from './element.js';
3
- import { Reply, replyCallback } from './reply.js';
2
+ import { Reply, replyCallback, replyForward } from './reply.js';
4
3
  import { EventType, Event, Permission, SubEvent, KarinMessageEvent, KarinNoticeEvent, KarinRequestEvent } from './event.js';
5
4
  /**
6
5
  * - 插件根目录名称
@@ -175,9 +174,7 @@ export interface PluginType {
175
174
  /**
176
175
  * - 快速回复合并转发
177
176
  */
178
- replyForward: (msg: KarinNodeElement[]) => Promise<{
179
- message_id?: string;
180
- }>;
177
+ replyForward: replyForward;
181
178
  /**
182
179
  * - 构建上下文键
183
180
  */
@@ -10,7 +10,8 @@ export interface KarinRenderType {
10
10
  /**
11
11
  * - vue文件路径 与file二选一
12
12
  */
13
- vue?: string;
13
+ vue?: boolean;
14
+ props?: any;
14
15
  /**
15
16
  * - 模板名称
16
17
  */
@@ -1,4 +1,4 @@
1
- import { KarinElement } from './element.js';
1
+ import { KarinElement, KarinNodeElement } from './element.js';
2
2
  export type Reply = (
3
3
  /**
4
4
  * 发送的消息
@@ -38,3 +38,6 @@ elements: KarinElement[],
38
38
  retry_count?: number) => Promise<{
39
39
  message_id?: string;
40
40
  }>;
41
+ export type replyForward = (msg: KarinNodeElement[]) => Promise<{
42
+ message_id?: string;
43
+ }>;
@@ -1,11 +1,6 @@
1
1
  import fs from 'fs';
2
2
  export declare const update: {
3
3
  dir: string;
4
- /**
5
- * 获取插件列表 拥有packageon才会被识别
6
- * @returns {string[]}
7
- */
8
- getPlugins(): string[];
9
4
  /**
10
5
  * 更新框架或插件
11
6
  * @param path - 插件相对路径
@@ -6,23 +6,6 @@ export const update = new (class Update {
6
6
  this.dir = './plugins'
7
7
  }
8
8
 
9
- /**
10
- * 获取插件列表 拥有packageon才会被识别
11
- * @returns {string[]}
12
- */
13
- getPlugins () {
14
- const list = []
15
- const files = fs.readdirSync(this.dir, { withFileTypes: true })
16
- /** 忽略非文件夹、非karin-plugin-开头的文件夹或/karin-adapter-开头的文件夹 */
17
- files.forEach(file => {
18
- if (!file.isDirectory()) { return }
19
- if (!file.name.startsWith('karin-plugin-') && !file.name.startsWith('karin-adapter-')) { return }
20
- if (!fs.existsSync(`${this.dir}/${file.name}/packageon`)) { return }
21
- list.push(file.name)
22
- })
23
- return list
24
- }
25
-
26
9
  /**
27
10
  * 更新框架或插件
28
11
  * @param path - 插件相对路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.6.6",
3
+ "version": "0.6.9",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",