@chbo297/infoflow 2026.3.8 → 2026.3.10

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": "@chbo297/infoflow",
3
- "version": "2026.3.8",
3
+ "version": "2026.3.10",
4
4
  "description": "OpenClaw Infoflow (如流) channel plugin for Baidu enterprise messaging",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/src/bot.ts CHANGED
@@ -103,10 +103,10 @@ function checkWatchMentioned(
103
103
  return undefined;
104
104
  }
105
105
 
106
- /** Check if message content matches the configured watchRegex regex pattern */
106
+ /** Check if message content matches the configured watchRegex regex pattern. Uses "s" (dotAll) so that . matches newlines in multi-line messages. */
107
107
  function checkWatchRegex(mes: string, pattern: string): boolean {
108
108
  try {
109
- return new RegExp(pattern, "i").test(mes);
109
+ return new RegExp(pattern, "is").test(mes);
110
110
  } catch {
111
111
  return false;
112
112
  }
@@ -373,11 +373,15 @@ export async function handlePrivateChatMessage(params: HandlePrivateChatParams):
373
373
  export async function handleGroupChatMessage(params: HandleGroupChatParams): Promise<void> {
374
374
  const { cfg, msgData, accountId, statusSink } = params;
375
375
 
376
- // Extract sender from nested structure or flat fields
376
+ // Extract sender from nested structure or flat fields.
377
+ // Some Infoflow events (including bot-authored forwards) only populate `fromid` on the root,
378
+ // so include msgData.fromid as a final fallback.
377
379
  const header = (msgData.message as Record<string, unknown>)?.header as
378
380
  | Record<string, unknown>
379
381
  | undefined;
380
- const fromuser = String(header?.fromuserid ?? msgData.fromuserid ?? msgData.from ?? "");
382
+ const fromuser = String(
383
+ header?.fromuserid ?? msgData.fromuserid ?? msgData.from ?? msgData.fromid ?? "",
384
+ );
381
385
 
382
386
  // Extract message ID (priority: header.messageid > header.msgid > MsgId)
383
387
  const messageId = header?.messageid ?? header?.msgid ?? msgData.MsgId;
@@ -426,7 +430,7 @@ export async function handleGroupChatMessage(params: HandleGroupChatParams): Pro
426
430
  if (replyBody) {
427
431
  replyContextItems.push(replyBody);
428
432
  }
429
- } else if (item.type === "TEXT") {
433
+ } else if (item.type === "TEXT" || item.type === "MD") {
430
434
  textContent += item.content ?? "";
431
435
  rawTextContent += item.content ?? "";
432
436
  } else if (item.type === "LINK") {
@@ -447,6 +451,10 @@ export async function handleGroupChatMessage(params: HandleGroupChatParams): Pro
447
451
  if (typeof url === "string" && url.trim()) {
448
452
  imageUrls.push(url.trim());
449
453
  }
454
+ } else if (typeof item.content === "string" && item.content.trim()) {
455
+ // Fallback: for any other item types with string content, treat content as text.
456
+ textContent += item.content;
457
+ rawTextContent += item.content;
450
458
  }
451
459
  }
452
460
  }
@@ -904,3 +912,6 @@ export const _checkWatchMentioned = checkWatchMentioned;
904
912
 
905
913
  /** @internal — Extract non-bot mention IDs. Only exported for tests. */
906
914
  export const _extractMentionIds = extractMentionIds;
915
+
916
+ /** @internal — Check watchRegex against message content (dotAll). Only exported for tests. */
917
+ export const _checkWatchRegex = checkWatchRegex;
package/src/channel.ts CHANGED
@@ -207,7 +207,7 @@ export const infoflowPlugin: ChannelPlugin<ResolvedInfoflowAccount> = {
207
207
  outbound: {
208
208
  deliveryMode: "direct",
209
209
  chunkerMode: "markdown",
210
- textChunkLimit: 4000,
210
+ textChunkLimit: 2048,
211
211
  chunker: (text, limit) => getInfoflowRuntime().channel.text.chunkText(text, limit),
212
212
  sendText: async ({ cfg, to, text, accountId }) => {
213
213
  logVerbose(`[infoflow:sendText] to=${to}, accountId=${accountId}`);
@@ -148,8 +148,8 @@ export function createInfoflowReplyDispatcher(params: CreateInfoflowReplyDispatc
148
148
  messageText = atPrefix + text;
149
149
  }
150
150
 
151
- // Chunk text to 4000 chars max (Infoflow limit)
152
- const chunks = core.channel.text.chunkText(messageText, 4000);
151
+ // Chunk text to 2048 chars max (Infoflow limit)
152
+ const chunks = core.channel.text.chunkText(messageText, 2048);
153
153
  // Only include @mentions in the first chunk (avoid duplicate @s)
154
154
  let isFirstChunk = true;
155
155