@aka_openclaw_plugin/mychat 0.2.5 → 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-DXBwjTlu.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,8 +430,8 @@ function createMychatMessageHandler(params) {
430
430
  logger?.debug(`${prefix} duplicate messageId=${message.id}, skipping`);
431
431
  return;
432
432
  }
433
- logger?.debug(`${prefix} preflight check for accountId=${account.accountId} messageId=${message.id}, account=${JSON.stringify(account)}`);
434
- 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);
435
435
  if (!preflight.allowed) {
436
436
  logger?.info(`${prefix} rejected messageId=${message.id} reason=${preflight.reason} from=${message.from?.id}`);
437
437
  return;
@@ -626,7 +626,7 @@ function createMychatTypingListener(params) {
626
626
  const prefix = mychatLogPrefix("typing");
627
627
  return { handle(message) {
628
628
  const senderId = message.from?.id;
629
- if (senderId === params.account.accountId) return;
629
+ if (senderId === params.botSelfId || senderId === params.account.accountId) return;
630
630
  if (logger) logger.debug(`${prefix} from ${senderId}`);
631
631
  } };
632
632
  }
@@ -642,14 +642,17 @@ function createMychatProviderClients(account, botSelfId, logger) {
642
642
  }) };
643
643
  }
644
644
  function registerMychatMonitorListeners(params) {
645
- const { account, handler, wsClient, logger } = params;
645
+ const { account, botSelfId, handler, wsClient, logger } = params;
646
646
  const prefix = mychatLogPrefix("router");
647
647
  const messageListener = createMychatMessageListener({
648
648
  account,
649
649
  handler
650
650
  });
651
651
  const reactionListener = createMychatReactionListener({ account });
652
- const typingListener = createMychatTypingListener({ account });
652
+ const typingListener = createMychatTypingListener({
653
+ account,
654
+ botSelfId
655
+ });
653
656
  wsClient.onMessage((message) => {
654
657
  switch (message.type) {
655
658
  case "message":
@@ -714,15 +717,18 @@ async function monitorMychatProvider(ctx) {
714
717
  try {
715
718
  setMychatRuntime(ctx.runtime);
716
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
+ });
717
728
  registerMychatMonitorListeners({
718
729
  account,
719
- handler: createMychatMessageHandler({
720
- account,
721
- logger,
722
- onInbound: async (result) => {
723
- await dispatchMychatInbound(ctx, httpClient, result);
724
- }
725
- }),
730
+ botSelfId: botSelf.botId,
731
+ handler,
726
732
  wsClient,
727
733
  logger
728
734
  });
@@ -1,2 +1,2 @@
1
- import { t as mychatPlugin } from "./channel-DXBwjTlu.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.5",
3
+ "version": "0.2.6",
4
4
  "description": "OpenClaw MyChat channel plugin",
5
5
  "repository": {
6
6
  "type": "git",