Skip to main content

openlark_bot/
service.rs

1use openlark_core::config::Config;
2use std::sync::Arc;
3
4/// BotService:机器人服务的统一入口
5///
6/// 提供对机器人搜索 API(v4)的访问能力。
7#[derive(Clone)]
8pub struct BotService {
9    // config 仅在 v4 feature 开启时被 search_bot() accessor 读取;feature 关闭时受控标注为预期死代码。
10    #[cfg_attr(not(feature = "v4"), expect(dead_code))]
11    config: Arc<Config>,
12}
13
14impl BotService {
15    /// 创建新的机器人服务实例。
16    pub fn new(config: Config) -> Self {
17        Self {
18            config: Arc::new(config),
19        }
20    }
21
22    /// 搜索机器人请求构建器(直达 leaf)。
23    ///
24    /// ADR 0001:消除 `Bot` / `V4` / `BotResource` 3 层纯转发壳
25    /// (原 `service.bot().v4().bot().search()` 4 跳 → `service.search_bot()` 1 跳)。
26    /// leaf `SearchBotRequest` API 不变。
27    #[cfg(feature = "v4")]
28    pub fn search_bot(&self) -> crate::bot::bot::v4::bot::search::SearchBotRequest {
29        crate::bot::bot::v4::bot::search::SearchBotRequest::new(self.config.clone())
30    }
31}