@openclaw-china/qqbot 0.1.4 → 0.1.5

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
@@ -5366,7 +5366,8 @@ async function sendGroupMessage(params) {
5366
5366
  messageId: params.messageId,
5367
5367
  markdown: params.markdown
5368
5368
  });
5369
- return apiPost(params.accessToken, `/v2/groups/${params.groupOpenid}/messages`, body, {
5369
+ const groupOpenidLower = params.groupOpenid.toLowerCase();
5370
+ return apiPost(params.accessToken, `/v2/groups/${groupOpenidLower}/messages`, body, {
5370
5371
  timeout: 15e3
5371
5372
  });
5372
5373
  }
@@ -5375,7 +5376,8 @@ async function sendChannelMessage(params) {
5375
5376
  if (params.messageId) {
5376
5377
  body.msg_id = params.messageId;
5377
5378
  }
5378
- return apiPost(params.accessToken, `/channels/${params.channelId}/messages`, body, {
5379
+ const channelIdLower = params.channelId.toLowerCase();
5380
+ return apiPost(params.accessToken, `/channels/${channelIdLower}/messages`, body, {
5379
5381
  timeout: 15e3
5380
5382
  });
5381
5383
  }
@@ -5800,6 +5802,7 @@ function parseTextWithAttachments(payload) {
5800
5802
  }
5801
5803
  var VOICE_ASR_FALLBACK_TEXT = "\u5F53\u524D\u8BED\u97F3\u529F\u80FD\u672A\u542F\u52A8\u6216\u8BC6\u522B\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002";
5802
5804
  var VOICE_EXTENSIONS = [".silk", ".amr", ".mp3", ".wav", ".ogg", ".m4a", ".aac", ".speex"];
5805
+ var VOICE_ASR_ERROR_MAX_LENGTH = 500;
5803
5806
  function isHttpUrl2(value) {
5804
5807
  return /^https?:\/\//i.test(value);
5805
5808
  }
@@ -5839,6 +5842,17 @@ function scheduleTempCleanup(filePath) {
5839
5842
  }, 20 * 60 * 1e3);
5840
5843
  timer.unref?.();
5841
5844
  }
5845
+ function trimTextForReply(text, maxLength) {
5846
+ if (text.length <= maxLength) return text;
5847
+ return `${text.slice(0, maxLength)}...`;
5848
+ }
5849
+ function buildVoiceASRFallbackReply(errorMessage) {
5850
+ const detail = errorMessage?.trim();
5851
+ if (!detail) return VOICE_ASR_FALLBACK_TEXT;
5852
+ return `${VOICE_ASR_FALLBACK_TEXT}
5853
+
5854
+ \u63A5\u53E3\u9519\u8BEF\uFF1A${trimTextForReply(detail, VOICE_ASR_ERROR_MAX_LENGTH)}`;
5855
+ }
5842
5856
  async function resolveInboundAttachmentsForAgent(params) {
5843
5857
  const { attachments, qqCfg, logger } = params;
5844
5858
  const list = attachments ?? [];
@@ -5846,7 +5860,8 @@ async function resolveInboundAttachmentsForAgent(params) {
5846
5860
  return {
5847
5861
  attachments: [],
5848
5862
  hasVoiceAttachment: false,
5849
- hasVoiceTranscript: false
5863
+ hasVoiceTranscript: false,
5864
+ asrErrorMessage: void 0
5850
5865
  };
5851
5866
  }
5852
5867
  const timeout = qqCfg.mediaTimeoutMs ?? 3e4;
@@ -5856,6 +5871,7 @@ async function resolveInboundAttachmentsForAgent(params) {
5856
5871
  const resolved = [];
5857
5872
  let hasVoiceAttachment = false;
5858
5873
  let hasVoiceTranscript = false;
5874
+ let asrErrorMessage;
5859
5875
  for (const att of list) {
5860
5876
  const next = { attachment: att };
5861
5877
  if (isImageAttachment(att) && isHttpUrl2(att.url)) {
@@ -5908,6 +5924,7 @@ async function resolveInboundAttachmentsForAgent(params) {
5908
5924
  logger.warn(
5909
5925
  `voice ASR failed: kind=${err.kind} provider=${err.provider} retryable=${err.retryable} message=${err.message}`
5910
5926
  );
5927
+ asrErrorMessage ??= err.message.trim() || void 0;
5911
5928
  } else {
5912
5929
  logger.warn(`voice ASR failed: ${String(err)}`);
5913
5930
  }
@@ -5919,7 +5936,8 @@ async function resolveInboundAttachmentsForAgent(params) {
5919
5936
  return {
5920
5937
  attachments: resolved,
5921
5938
  hasVoiceAttachment,
5922
- hasVoiceTranscript
5939
+ hasVoiceTranscript,
5940
+ asrErrorMessage
5923
5941
  };
5924
5942
  }
5925
5943
  function buildInboundContentWithAttachments(params) {
@@ -6067,7 +6085,7 @@ function resolveInbound(eventType, data) {
6067
6085
  }
6068
6086
  function resolveChatTarget(event) {
6069
6087
  if (event.type === "group") {
6070
- const group = event.groupOpenid ?? "";
6088
+ const group = (event.groupOpenid ?? "").toLowerCase();
6071
6089
  return {
6072
6090
  to: `group:${group}`,
6073
6091
  peerId: `group:${group}`,
@@ -6075,7 +6093,7 @@ function resolveChatTarget(event) {
6075
6093
  };
6076
6094
  }
6077
6095
  if (event.type === "channel") {
6078
- const channel = event.channelId ?? "";
6096
+ const channel = (event.channelId ?? "").toLowerCase();
6079
6097
  return {
6080
6098
  to: `channel:${channel}`,
6081
6099
  peerId: `channel:${channel}`,
@@ -6090,10 +6108,10 @@ function resolveChatTarget(event) {
6090
6108
  }
6091
6109
  function resolveEnvelopeFrom(event) {
6092
6110
  if (event.type === "group") {
6093
- return `group:${event.groupOpenid ?? "unknown"}`;
6111
+ return `group:${(event.groupOpenid ?? "unknown").toLowerCase()}`;
6094
6112
  }
6095
6113
  if (event.type === "channel") {
6096
- return `channel:${event.channelId ?? "unknown"}`;
6114
+ return `channel:${(event.channelId ?? "unknown").toLowerCase()}`;
6097
6115
  }
6098
6116
  return event.senderName?.trim() || event.senderId;
6099
6117
  }
@@ -6230,7 +6248,7 @@ async function dispatchToAgent(params) {
6230
6248
  const fallback = await qqbotOutbound.sendText({
6231
6249
  cfg: { channels: { qqbot: qqCfg } },
6232
6250
  to: target.to,
6233
- text: VOICE_ASR_FALLBACK_TEXT,
6251
+ text: buildVoiceASRFallbackReply(resolvedAttachmentResult.asrErrorMessage),
6234
6252
  replyToId: inbound.messageId
6235
6253
  });
6236
6254
  if (fallback.error) {