Skip to main content

nagisa_types/
capability.rs

1//! 协议标识 [`Protocol`] 与能力枚举 [`Capability`],用于运行时能力探测:业务用
2//! `Bot::supports(cap)` 问「当前后端能不能做这件事」,据此对不支持的端做降级。
3
4/// 后端协议。
5#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
6pub enum Protocol {
7    OneBot11,
8    Milky,
9}
10
11/// 可探测的能力。适配器据实现/版本回答 `Bot::supports`。
12/// `#[non_exhaustive]`:新增能力不破坏下游 match。
13#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
14#[non_exhaustive]
15pub enum Capability {
16    GroupMute,
17    GroupAdmin,
18    GroupKick,
19    HandleRequest,
20    Essence,
21    Announcement,
22    PeerPin,
23    Reaction,
24    Forward,
25    /// 群/私聊文件上传、下载、管理(upload_group_file / get_file 等)。
26    FileOps,
27    /// 戳一戳(nudge / poke)。
28    Nudge,
29    /// 点赞(get_profile_like / send_like)。
30    ProfileLike,
31    /// 读写自身资料(set_self_longnick 等)。
32    SelfProfile,
33    /// 拉取历史消息(get_message_history)。
34    MessageHistory,
35    /// 获取登录 Cookie / SKEY。
36    Cookies,
37    /// OCR 图片文字识别(ocr_image)。
38    Ocr,
39    /// AI 语音合成与音色列表(get_ai_characters / send_group_ai_record 等)。
40    /// 仅 Lagrange.OneBot / NapCat / LLOneBot 支持;其他端返回 `false`。
41    Ai,
42}
43
44impl Protocol {
45    pub fn name(&self) -> &'static str {
46        match self {
47            Protocol::OneBot11 => "onebot11",
48            Protocol::Milky => "milky",
49        }
50    }
51}