访问组是命名的发送者列表,定义一次后可在多个频道白名单中通过 accessGroup:<name> 引用。适用于同一批人需要在多个消息频道被允许的场景。

静态消息发送者组

{
  accessGroups: {
    operators: {
      type: "message.senders",
      members: {
        "*": ["global-owner-id"],          // 所有频道共享
        discord: ["discord:123456789012345678"],
        telegram: ["987654321"],
        whatsapp: ["+15551234567"],
      },
    },
  },
}

成员列表按消息频道 ID 分组,"*" 为所有频道共享条目。

在白名单中引用

DM 白名单:

{
  channels: {
    discord: { dmPolicy: "allowlist", allowFrom: ["accessGroup:operators"] },
    telegram: { dmPolicy: "allowlist", allowFrom: ["accessGroup:operators"] },
  },
}

群组发送者白名单:

{
  accessGroups: {
    oncall: {
      type: "message.senders",
      members: {
        whatsapp: ["+15551234567"],
        googlechat: ["users/1234567890"],
      },
    },
  },
  channels: {
    whatsapp: { groupPolicy: "allowlist", groupAllowFrom: ["accessGroup:oncall"] },
  },
}

可混合使用组引用和直接条目:

{ allowFrom: ["accessGroup:operators", "discord:123456789012345678"] }

支持的频道

Discord、Feishu、Google Chat、iMessage、LINE、Mattermost、Microsoft Teams、Nextcloud Talk、Nostr、QQBot、Signal、WhatsApp、Zalo、Zalo Personal

Discord 动态访问组

{
  accessGroups: {
    maintainers: {
      type: "discord.channelAudience",
      guildId: "1456350064065904867",
      channelId: "1456744319972282449",
      membership: "canViewChannel",
    },
  },
}

允许能查看指定 Discord 频道的用户发送 DM。需要 bot 有 Server Members Intent 权限。

安全注意

  • 访问组是白名单别名,不是角色,不授予工具权限
  • dmPolicy: "open" 仍需 "*" 在有效 DM 白名单中
  • 引用不存在的组名会 fail closed(不授权任何人)
  • 运行 openclaw doctor 验证访问控制配置

故障排查

发送者应匹配但被阻止时:

  1. 确认白名单字段包含正确的 accessGroup:<name> 引用
  2. 确认 accessGroups.<name>.type 正确
  3. 确认发送者 ID 在对应频道键或 "*" 下
  4. 对 Discord 频道受众,确认 bot 可见该频道且有 Server Members Intent

相关链接