@aka_openclaw_plugin/mychat 0.2.4 → 0.2.6

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/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as tryGetMychatRuntime, i as setMychatRuntime, n as init_runtime, t as getMychatRuntime } from "./runtime-CkiGSF1r.js";
2
- import { t as mychatPlugin } from "./channel-BV8RZeLR.js";
2
+ import { t as mychatPlugin } from "./channel-Bm6L1z-e.js";
3
3
  //#region extensions/mychat/api.ts
4
4
  init_runtime();
5
5
  //#endregion
@@ -319,13 +319,13 @@ function isBotMentioned(message, botUserId) {
319
319
  //#endregion
320
320
  //#region extensions/mychat/src/monitor/message-handler.preflight.ts
321
321
  /** Check if an inbound message should be accepted. */
322
- function mychatPreflight(message, account) {
322
+ function mychatPreflight(message, account, botSelfId) {
323
323
  const senderId = message.from?.id;
324
324
  if (!senderId) return {
325
325
  allowed: false,
326
326
  reason: "no-sender"
327
327
  };
328
- if (senderId === account.accountId) return {
328
+ if (senderId === botSelfId || senderId === account.accountId) return {
329
329
  allowed: false,
330
330
  reason: "self"
331
331
  };
@@ -360,12 +360,12 @@ function mychatPreflight(message, account) {
360
360
  allowed: false,
361
361
  reason: "group-disabled"
362
362
  };
363
- if (groupConfig.requireMention && !isBotMentioned(message, account.accountId)) return {
363
+ if (groupConfig.requireMention && !isBotMentioned(message, botSelfId ?? account.accountId)) return {
364
364
  allowed: false,
365
365
  reason: "mention-required"
366
366
  };
367
367
  }
368
- if (account.requireMention && !isBotMentioned(message, account.accountId)) return {
368
+ if (account.requireMention && !isBotMentioned(message, botSelfId ?? account.accountId)) return {
369
369
  allowed: false,
370
370
  reason: "mention-required"
371
371
  };
@@ -420,7 +420,7 @@ function processMychatInbound(message, account) {
420
420
  //#endregion
421
421
  //#region extensions/mychat/src/monitor/message-handler.ts
422
422
  function createMychatMessageHandler(params) {
423
- const { account, onInbound, logger } = params;
423
+ const { account, botSelfId, onInbound, logger } = params;
424
424
  const dedupe = createMychatInboundDedupe();
425
425
  const prefix = mychatLogPrefix("handler");
426
426
  return { async handleMessage(message) {
@@ -430,7 +430,8 @@ function createMychatMessageHandler(params) {
430
430
  logger?.debug(`${prefix} duplicate messageId=${message.id}, skipping`);
431
431
  return;
432
432
  }
433
- const preflight = mychatPreflight(message, account);
433
+ logger?.debug(`${prefix} preflight check for accountId=${account.accountId} botSelfId=${botSelfId ?? "unknown"} messageId=${message.id}, account=${JSON.stringify(account)}`);
434
+ const preflight = mychatPreflight(message, account, botSelfId);
434
435
  if (!preflight.allowed) {
435
436
  logger?.info(`${prefix} rejected messageId=${message.id} reason=${preflight.reason} from=${message.from?.id}`);
436
437
  return;
@@ -625,7 +626,7 @@ function createMychatTypingListener(params) {
625
626
  const prefix = mychatLogPrefix("typing");
626
627
  return { handle(message) {
627
628
  const senderId = message.from?.id;
628
- if (senderId === params.account.accountId) return;
629
+ if (senderId === params.botSelfId || senderId === params.account.accountId) return;
629
630
  if (logger) logger.debug(`${prefix} from ${senderId}`);
630
631
  } };
631
632
  }
@@ -641,14 +642,17 @@ function createMychatProviderClients(account, botSelfId, logger) {
641
642
  }) };
642
643
  }
643
644
  function registerMychatMonitorListeners(params) {
644
- const { account, handler, wsClient, logger } = params;
645
+ const { account, botSelfId, handler, wsClient, logger } = params;
645
646
  const prefix = mychatLogPrefix("router");
646
647
  const messageListener = createMychatMessageListener({
647
648
  account,
648
649
  handler
649
650
  });
650
651
  const reactionListener = createMychatReactionListener({ account });
651
- const typingListener = createMychatTypingListener({ account });
652
+ const typingListener = createMychatTypingListener({
653
+ account,
654
+ botSelfId
655
+ });
652
656
  wsClient.onMessage((message) => {
653
657
  switch (message.type) {
654
658
  case "message":
@@ -713,15 +717,18 @@ async function monitorMychatProvider(ctx) {
713
717
  try {
714
718
  setMychatRuntime(ctx.runtime);
715
719
  } catch {}
720
+ const handler = createMychatMessageHandler({
721
+ account,
722
+ botSelfId: botSelf.botId,
723
+ logger,
724
+ onInbound: async (result) => {
725
+ await dispatchMychatInbound(ctx, httpClient, result);
726
+ }
727
+ });
716
728
  registerMychatMonitorListeners({
717
729
  account,
718
- handler: createMychatMessageHandler({
719
- account,
720
- logger,
721
- onInbound: async (result) => {
722
- await dispatchMychatInbound(ctx, httpClient, result);
723
- }
724
- }),
730
+ botSelfId: botSelf.botId,
731
+ handler,
725
732
  wsClient,
726
733
  logger
727
734
  });
@@ -1,2 +1,2 @@
1
- import { t as mychatPlugin } from "./channel-BV8RZeLR.js";
1
+ import { t as mychatPlugin } from "./channel-Bm6L1z-e.js";
2
2
  export { mychatPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aka_openclaw_plugin/mychat",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "OpenClaw MyChat channel plugin",
5
5
  "repository": {
6
6
  "type": "git",