Files
Memoh/assets/zh_getting-started_access.md.Xdj3gnBr.js
2026-04-24 06:37:27 +00:00

2 lines
8.6 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{_ as a,o,c as e,ag as l}from"./chunks/framework.CAXxHpAX.js";const u=JSON.parse('{"title":"访问控制","description":"","frontmatter":{},"headers":[],"relativePath":"zh/getting-started/access.md","filePath":"zh/getting-started/access.md","lastUpdated":1777012567000}'),r={name:"zh/getting-started/access.md"};function d(n,t,i,s,c,h){return o(),e("div",null,[...t[0]||(t[0]=[l('<h1 id="访问控制" tabindex="-1">访问控制 <a class="header-anchor" href="#访问控制" aria-label="Permalink to &quot;访问控制&quot;"></a></h1><p>Memoh 用 <strong>ACL</strong> 控制谁能跟你的机器人说话。可在机器人 <strong>Access</strong> tab 里按人、按平台账号、按整类渠道设规则,并设<strong>优先级</strong>。</p><hr><h2 id="快速入门-acl-预设" tabindex="-1">快速入门:ACL 预设 <a class="header-anchor" href="#快速入门-acl-预设" aria-label="Permalink to &quot;快速入门:ACL 预设&quot;"></a></h2><p>建机器人时可选 <strong>ACL 预设</strong>,只是常见起步方式:</p><table tabindex="0"><thead><tr><th>预设</th><th>效果</th></tr></thead><tbody><tr><td><code>allow_all</code></td><td>默认 <strong>允许</strong>;来者不拒,除非你再加拒绝规则</td></tr><tr><td><code>private_only</code></td><td>默认 <strong>拒绝</strong>;私聊放行(视具体实现与后续规则)</td></tr><tr><td><code>group_only</code></td><td>默认 <strong>拒绝</strong>;群聊放行</td></tr><tr><td><code>group_and_thread_only</code></td><td>默认 <strong>拒绝</strong>;群与 thread 放行</td></tr><tr><td><code>deny_all</code></td><td>默认 <strong>拒绝</strong>;除 owner/管理员路径外都要你显式允许</td></tr></tbody></table><p>预设只是起点,之后都在 <strong>Access</strong> 里改。</p><hr><h2 id="概念" tabindex="-1">概念 <a class="header-anchor" href="#概念" aria-label="Permalink to &quot;概念&quot;"></a></h2><h3 id="默认效果" tabindex="-1">默认效果 <a class="header-anchor" href="#默认效果" aria-label="Permalink to &quot;默认效果&quot;"></a></h3><p>每个机器人有一个 <strong>default effect</strong><code>allow</code> 或 <code>deny</code>):<strong>没有任一条规则命中</strong>时怎么办。</p><ul><li><strong>Allow</strong>:默认谁都能聊,除非你按规则挡。</li><li><strong>Deny</strong>:默认都挡,只放行 owner、管理员和你写允许规则的对象。</li></ul><h3 id="主体类型" tabindex="-1">主体类型 <a class="header-anchor" href="#主体类型" aria-label="Permalink to &quot;主体类型&quot;"></a></h3><table tabindex="0"><thead><tr><th>主体</th><th>说明</th></tr></thead><tbody><tr><td><strong>All</strong></td><td>所有入站消息,用来做全局放行/拒绝</td></tr><tr><td><strong>Channel Identity</strong></td><td>某个外部平台上的具体身份(如某个 TG 用户)</td></tr><tr><td><strong>Channel Type</strong></td><td>某整类渠道(如所有 Telegram 用户)</td></tr></tbody></table><h3 id="效果" tabindex="-1">效果 <a class="header-anchor" href="#效果" aria-label="Permalink to &quot;效果&quot;"></a></h3><p>每条规则不是 <strong>Allow</strong> 就是 <strong>Deny</strong>。</p><h3 id="优先级" tabindex="-1">优先级 <a class="header-anchor" href="#优先级" aria-label="Permalink to &quot;优先级&quot;"></a></h3><p>按列表<strong>自上而下</strong>匹配,<strong>第一条命中的</strong>生效:</p><ol><li>机器人 owner、系统管理员 → <strong>始终允许</strong>(绕 ACL)。</li><li>再按规则从上往下,找第一个主体匹配的发送者。</li><li>若都不匹配 → 用 <strong>默认效果</strong>。</li></ol><p>所以<strong>顺序很重要</strong>:同一个人,上面一条 <code>deny</code> 会盖住下面一条 <code>allow</code>(若先匹配到 deny)。</p><hr><h2 id="管理" tabindex="-1">管理 <a class="header-anchor" href="#管理" aria-label="Permalink to &quot;管理&quot;"></a></h2><h3 id="建议流程" tabindex="-1">建议流程 <a class="header-anchor" href="#建议流程" aria-label="Permalink to &quot;建议流程&quot;"></a></h3><ol><li>建机时选一个预设。</li><li>打开 <strong>Access</strong>,确认 <strong>Default Effect</strong>。</li><li>只有在太宽或太窄时再加/调规则。</li></ol><h3 id="加规则" tabindex="-1">加规则 <a class="header-anchor" href="#加规则" aria-label="Permalink to &quot;加规则&quot;"></a></h3><ol><li><strong>Add Rule</strong>。</li><li>选主体:All / 某平台账号 / 某渠道类型。</li><li>选效果 <code>allow</code> 或 <code>deny</code>。</li><li>可选 <strong>来源范围</strong>(把规则限在更细的上下文): <ul><li>某条渠道配置</li><li>会话类型:私聊 / 群 / thread</li><li>会话 ID</li><li>线索程 ID(通常要配合会话 ID</li></ul></li><li>保存。</li></ol><h3 id="排序" tabindex="-1">排序 <a class="header-anchor" href="#排序" aria-label="Permalink to &quot;排序&quot;"></a></h3><p>可拖拽改优先级;<strong>越靠上越先判</strong>。改完记得 <strong>Save</strong>。</p><h3 id="来源范围" tabindex="-1">来源范围 <a class="header-anchor" href="#来源范围" aria-label="Permalink to &quot;来源范围&quot;"></a></h3><p>用来写细规则,例如:</p><ul><li>只允许从 Telegram 进,不允许 Discord</li><li>某渠道类型只在群里挡</li><li>某个群、某条 thread 单独管</li></ul><p>范围大致是:渠道 → 会话类型 → 会话 ID → 线程 ID;后几级可选,但 <strong>Thread 一般要有 Conversation ID</strong>。</p><hr><h2 id="预设怎么选" tabindex="-1">预设怎么选 <a class="header-anchor" href="#预设怎么选" aria-label="Permalink to &quot;预设怎么选&quot;"></a></h2><ul><li><code>allow_all</code>:开放试用、公开展示。</li><li><code>private_only</code>:只打算私聊用。</li><li><code>group_only</code>:只打算在共享房间用。</li><li><code>group_and_thread_only</code>:要群/线程,不要私聊。</li><li><code>deny_all</code>:敏感用例,<strong>逐个加白名单</strong>。</li></ul><p>吃不准时,个人测试机可 <code>allow_all</code>,敏感环境可 <code>deny_all</code> 再白名单。</p><hr><h2 id="例子" tabindex="-1">例子 <a class="header-anchor" href="#例子" aria-label="Permalink to &quot;例子&quot;"></a></h2><h3 id="谁都能聊" tabindex="-1">谁都能聊 <a class="header-anchor" href="#谁都能聊" aria-label="Permalink to &quot;谁都能聊&quot;"></a></h3><ol><li>预设 <code>allow_all</code>,或默认效果 <code>allow</code>。</li><li>不加规则也行。</li></ol><h3 id="只给少数私用" tabindex="-1">只给少数私用 <a class="header-anchor" href="#只给少数私用" aria-label="Permalink to &quot;只给少数私用&quot;"></a></h3><ol><li>预设 <code>deny_all</code> 或默认 <code>deny</code>。</li><li>对要放行的人加 <strong>allow</strong> 的 Channel Identity。</li></ol><h3 id="公开但拉黑几个人" tabindex="-1">公开但拉黑几个人 <a class="header-anchor" href="#公开但拉黑几个人" aria-label="Permalink to &quot;公开但拉黑几个人&quot;"></a></h3><ol><li>预设 <code>allow_all</code> 或默认 <code>allow</code>。</li><li>在列表<strong>上面</strong>加 <strong>deny</strong> 给那几个人(先判 deny)。</li></ol><h3 id="只开某一整平台" tabindex="-1">只开某一整平台 <a class="header-anchor" href="#只开某一整平台" aria-label="Permalink to &quot;只开某一整平台&quot;"></a></h3><ol><li>从 <code>deny_all</code> 或 <code>private_only</code> 等起步。</li><li>加 <strong>Channel Type</strong> 的 <code>allow</code>,例如只开 <code>telegram</code>。</li></ol><h3 id="只让某人在某一渠道聊" tabindex="-1">只让某人在某一渠道聊 <a class="header-anchor" href="#只让某人在某一渠道聊" aria-label="Permalink to &quot;只让某人在某一渠道聊&quot;"></a></h3><ol><li>给该人 <strong>allow</strong>。</li><li><strong>来源范围</strong> 里把渠道指到具体那条 Telegram/Discord 配置。</li></ol><hr><h2 id="查为什么判成这样" tabindex="-1">查为什么判成这样 <a class="header-anchor" href="#查为什么判成这样" aria-label="Permalink to &quot;查为什么判成这样&quot;"></a></h2><ul><li>看 <strong>Access</strong> 里规则顺序和默认效果。</li><li>用 <code>/access</code> 看当前身份、角色、ACL 判定上下文。</li></ul><p>多平台身份绑在一起、或群/thread 判晕时,这条特别有用。</p>',52)])])}const b=a(r,[["render",d]]);export{u as __pageData,b as default};