node-karin 0.12.5 → 0.12.7

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/api/npm.js CHANGED
@@ -21,7 +21,7 @@ export async function getNpmPlugins(showDetails) {
21
21
  list.push(name);
22
22
  }
23
23
  catch (error) {
24
- logger.error(`[common] 解析 package.json 时出错:${error.stack || error.message || JSON.stringify(error)}`);
24
+ console.error(`[common] 解析 package.json 时出错:${error.stack || error.message || JSON.stringify(error)}`);
25
25
  }
26
26
  };
27
27
  await Promise.all(dependencies.map(readPackageJson));
@@ -42,7 +42,7 @@ export async function getNpmPlugins(showDetails) {
42
42
  if (pkg?.karin?.apps?.length) {
43
43
  pkg.karin.apps.forEach((app) => {
44
44
  if (!fs.existsSync(path.join(root, app))) {
45
- logger.error(`[common] npm插件${files}的app目录${app}不存在 已跳过`);
45
+ console.error(`[common] npm插件${files}的app目录${app}不存在 已跳过`);
46
46
  return;
47
47
  }
48
48
  fs.readdirSync(path.join(root, app)).forEach((filename) => {
@@ -55,7 +55,7 @@ export async function getNpmPlugins(showDetails) {
55
55
  }
56
56
  }
57
57
  catch (error) {
58
- logger.error(`[common] 获取npm插件列表时出错:${error.stack || error.message || JSON.stringify(error)}`);
58
+ console.error(`[common] 获取npm插件列表时出错:${error.stack || error.message || JSON.stringify(error)}`);
59
59
  }
60
60
  };
61
61
  await Promise.all(dependencies.map(readPackageJson));
@@ -1,4 +1,4 @@
1
- export type ElementType = 'text' | 'at' | 'face' | 'bubble_face' | 'reply' | 'image' | 'video' | 'basketball' | 'dice' | 'rps' | 'poke' | 'music' | 'weather' | 'location' | 'share' | 'gift' | 'market_face' | 'forward' | 'contact' | 'json' | 'xml' | 'file' | 'markdown' | 'markdown_tpl' | 'keyboard' | 'node' | 'rows' | 'record' | 'long_msg' | 'raw';
1
+ export type ElementType = 'text' | 'at' | 'face' | 'bubble_face' | 'reply' | 'image' | 'video' | 'basketball' | 'dice' | 'rps' | 'poke' | 'music' | 'weather' | 'location' | 'share' | 'gift' | 'market_face' | 'forward' | 'contact' | 'json' | 'xml' | 'file' | 'markdown' | 'markdown_tpl' | 'keyboard' | 'node' | 'rows' | 'record' | 'long_msg' | 'raw' | 'passive_reply';
2
2
  export interface Element {
3
3
  /**
4
4
  * - 元素类型
@@ -552,6 +552,13 @@ export interface LongMsgElement extends Element {
552
552
  */
553
553
  id: string;
554
554
  }
555
+ /**
556
+ * - 回复被动消息 键入此字段代表此条消息为被动消息
557
+ */
558
+ export interface PassiveElement extends Element {
559
+ type: 'passive_reply';
560
+ id: string;
561
+ }
555
562
  /**
556
563
  * 原生元素
557
564
  */
@@ -559,7 +566,7 @@ export interface RawElement extends Element {
559
566
  type: 'raw';
560
567
  data: any;
561
568
  }
562
- export type KarinElement = TextElement | AtElement | FaceElement | BubbleFaceElement | ReplyElement | ImageElement | VideoElement | BasketballElement | DiceElement | RpsElement | PokeElement | MusicElement | WeatherElement | LocationElement | ShareElement | GiftElement | MarketFaceElement | ForwardElement | ContactElement | JsonElement | XmlElement | FileElement | ButtonElement | KeyBoardElement | RecordElement | LongMsgElement | TplMarkdownElement | RawMarkdownElement | RawElement;
569
+ export type KarinElement = TextElement | AtElement | FaceElement | BubbleFaceElement | ReplyElement | ImageElement | VideoElement | BasketballElement | DiceElement | RpsElement | PokeElement | MusicElement | WeatherElement | LocationElement | ShareElement | GiftElement | MarketFaceElement | ForwardElement | ContactElement | JsonElement | XmlElement | FileElement | ButtonElement | KeyBoardElement | RecordElement | LongMsgElement | TplMarkdownElement | RawMarkdownElement | RawElement | PassiveElement;
563
570
  /**
564
571
  * - 构建自定义转发节点 此元素仅可通过专用接口发送 不支持混合发送
565
572
  */
@@ -2,11 +2,19 @@
2
2
  * - 事件来源枚举
3
3
  */
4
4
  export declare const enum Scene {
5
+ /** 群 */
5
6
  Group = "group",
7
+ /** 好友 */
6
8
  Private = "friend",
9
+ /** 频道 */
7
10
  Guild = "guild",
11
+ /** 频道私信 */
12
+ GuildPrivate = "guild_private",
13
+ /** 临时会话 */
8
14
  Nearby = "nearby",
15
+ /** 陌生人 */
9
16
  Stranger = "stranger",
17
+ /** 临时群会话 */
10
18
  StrangerFromGroup = "stranger_from_group"
11
19
  }
12
20
  /**
@@ -229,7 +229,7 @@ export const config = new (class Cfg {
229
229
  const key = 'change.group';
230
230
  /** 取缓存 */
231
231
  const res = this.change.get(key);
232
- const keys = e?.self_id ? [`Bot.${e.self_id}.${group_id}`, `Bot.${e.self_id}`, group_id] : [group_id];
232
+ const keys = e?.self_id ? [`Bot:${e.self_id}:${group_id}`, `Bot:${e.self_id}`, group_id] : [group_id];
233
233
  if (res) {
234
234
  const cfg = { ...res.defCfg.default, ...res.Config.default };
235
235
  for (const k of keys) {
@@ -281,4 +281,11 @@ export declare const segment: {
281
281
  * @param data - 原生数据
282
282
  */
283
283
  raw(data: any): RawElement;
284
+ /**
285
+ * 回复被动消息
286
+ */
287
+ passive_reply(id: string): {
288
+ type: "passive_reply";
289
+ id: string;
290
+ };
284
291
  };
@@ -458,4 +458,13 @@ export const segment = new (class Segment {
458
458
  data,
459
459
  };
460
460
  }
461
+ /**
462
+ * 回复被动消息
463
+ */
464
+ passive_reply(id) {
465
+ return {
466
+ type: 'passive_reply',
467
+ id,
468
+ };
469
+ }
461
470
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",
@@ -118,7 +118,7 @@
118
118
  ],
119
119
  "scripts": {
120
120
  ".": "node lib/cli/start.js .",
121
- "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix:all",
121
+ "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
122
122
  "build:npm": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
123
123
  "dev": "node lib/cli/start.js dev",
124
124
  "fix": "eslint lib/**/*.js --fix",