@xmanrui/dsh-im 4.1.0 → 4.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmanrui/dsh-im",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "把九种 IM 机器人和公网 AI Office 接入本机 DeepSeek Harness。 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -109,6 +109,15 @@ function conversationKey(message) {
109
109
  return `${message.kind}:${message.kind === 'group' ? message.groupOpenid : message.senderId}`;
110
110
  }
111
111
 
112
+ function senderAllowed(message, ownerUserOpenid) {
113
+ // QR binding yields a C2C user_openid, while group events identify senders
114
+ // with a group-scoped member_openid. Treat group membership plus @mention as
115
+ // the access boundary, and keep the scanner restriction for private chats.
116
+ return message?.kind === 'group'
117
+ || ownerUserOpenid === '*'
118
+ || message?.senderId === ownerUserOpenid;
119
+ }
120
+
112
121
  function safeText(message) {
113
122
  return typeof message?.content === 'string' ? message.content.trim() : '';
114
123
  }
@@ -442,7 +451,7 @@ export class QqHarnessBridge {
442
451
  }
443
452
  const pending = this.#pendingInteractions.get(key);
444
453
  const commandText = safeText(message);
445
- const allowed = this.#ownerUserOpenid === '*' || sender === this.#ownerUserOpenid;
454
+ const allowed = senderAllowed(message, this.#ownerUserOpenid);
446
455
  const addressed = message.kind !== 'group'
447
456
  || message.rawEventType === 'GROUP_AT_MESSAGE_CREATE';
448
457
  const batchCommand = isBatchInputCommand(commandText);
@@ -569,7 +578,7 @@ export class QqHarnessBridge {
569
578
  alreadyRecorded = false,
570
579
  batchSubmission = null,
571
580
  } = {}) {
572
- const allowed = this.#ownerUserOpenid === '*' || message.senderId === this.#ownerUserOpenid;
581
+ const allowed = senderAllowed(message, this.#ownerUserOpenid);
573
582
  const addressed = message.kind !== 'group'
574
583
  || message.rawEventType === 'GROUP_AT_MESSAGE_CREATE';
575
584
  const preparedMessage = allowed && addressed
@@ -721,7 +730,7 @@ export class QqHarnessBridge {
721
730
  await this.#state.markSeen(messageId);
722
731
  messageRecorded = true;
723
732
  };
724
- if (this.#ownerUserOpenid !== '*' && sender !== this.#ownerUserOpenid) {
733
+ if (!senderAllowed(message, this.#ownerUserOpenid)) {
725
734
  this.#status.messagesRejected += 1;
726
735
  this.#status.lastRejectedAt = new Date().toISOString();
727
736
  return;