@lih-x-x/kmr 1.0.18 → 1.0.20

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/dist/index.js CHANGED
@@ -85,7 +85,7 @@ function createEventDispatcher(botOpenId, onMessage) {
85
85
  if (isGroup && !isMentioned) {
86
86
  const hasDocLink = /(https?:\/\/[^\s]*feishu\.cn\/[^\s]+)/.test(text);
87
87
  if (!hasDocLink) {
88
- console.log(`[recv] \u7FA4\u804A\u975E@\u6D88\u606F\u4E14\u975E\u6587\u6863\u94FE\u63A5, \u5FFD\u7565`);
88
+ console.log(`[recv] \u7FA4\u804A\u975E@\u673A\u5668\u4EBA\u6D88\u606F\u4E14\u975E\u6587\u6863\u94FE\u63A5, \u5FFD\u7565`);
89
89
  return;
90
90
  }
91
91
  }
@@ -335,6 +335,19 @@ var Messenger = class {
335
335
  }
336
336
  await this.replyText(messageId, lines.join("\n"));
337
337
  }
338
+ /**
339
+ * 主动向指定用户发送消息(不需要先收到消息)
340
+ */
341
+ async sendToUser(openId, text) {
342
+ await this.client.im.message.create({
343
+ params: { receive_id_type: "open_id" },
344
+ data: {
345
+ receive_id: openId,
346
+ content: JSON.stringify({ text }),
347
+ msg_type: "text"
348
+ }
349
+ });
350
+ }
338
351
  };
339
352
 
340
353
  // src/lark/router.ts
@@ -1310,5 +1323,10 @@ async function main() {
1310
1323
  openBrowser(`http://localhost:${port}`);
1311
1324
  console.log(`KMR Web \u754C\u9762\u5DF2\u542F\u52A8: http://localhost:${port}`);
1312
1325
  console.log("KMR \u670D\u52A1\u5DF2\u542F\u52A8\uFF0C\u7B49\u5F85\u98DE\u4E66\u6D88\u606F...");
1326
+ if (config.lark.adminOpenId) {
1327
+ messenger.sendToUser(config.lark.adminOpenId, "\u2705 KMR \u670D\u52A1\u5DF2\u542F\u52A8").catch((err) => {
1328
+ console.error("[notify] \u5411\u7BA1\u7406\u5458\u63A8\u9001\u542F\u52A8\u901A\u77E5\u5931\u8D25:", err.message);
1329
+ });
1330
+ }
1313
1331
  }
1314
1332
  main().catch(console.error);
@@ -278,6 +278,10 @@ async function renderSettings() {
278
278
  '<label class="form-label">App Secret</label>' +
279
279
  '<input class="form-input" id="cfg-appSecret" type="password" value="' + escapeAttr(config.lark.appSecret) + '">' +
280
280
  '</div>' +
281
+ '<div class="form-field">' +
282
+ '<label class="form-label">管理员 Open ID(可选,用于接收服务通知)</label>' +
283
+ '<input class="form-input" id="cfg-adminOpenId" type="text" value="' + escapeAttr(config.lark.adminOpenId || '') + '">' +
284
+ '</div>' +
281
285
  '</div>' +
282
286
  '<div class="settings-group">' +
283
287
  '<div class="settings-group-title">Agent 配置</div>' +
@@ -308,6 +312,7 @@ async function saveSettings() {
308
312
  lark: {
309
313
  appId: document.getElementById('cfg-appId').value,
310
314
  appSecret: document.getElementById('cfg-appSecret').value,
315
+ adminOpenId: document.getElementById('cfg-adminOpenId').value || undefined,
311
316
  },
312
317
  agent: {
313
318
  provider: document.getElementById('cfg-provider').value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lih-x-x/kmr",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {