pub struct ChatbotReplier { /* private fields */ }Expand description
聊天机器人回复工具
Implementations§
Source§impl ChatbotReplier
impl ChatbotReplier
Sourcepub fn new(
http_client: HttpClient,
token_manager: Arc<TokenManager>,
client_id: String,
) -> Self
pub fn new( http_client: HttpClient, token_manager: Arc<TokenManager>, client_id: String, ) -> Self
创建新的 ChatbotReplier
Sourcepub async fn reply_text(
&self,
text: &str,
incoming_message: &ChatbotMessage,
) -> Result<Value>
pub async fn reply_text( &self, text: &str, incoming_message: &ChatbotMessage, ) -> Result<Value>
通过 session webhook 回复文本消息
Sourcepub async fn reply_markdown(
&self,
title: &str,
text: &str,
incoming_message: &ChatbotMessage,
) -> Result<Value>
pub async fn reply_markdown( &self, title: &str, text: &str, incoming_message: &ChatbotMessage, ) -> Result<Value>
通过 session webhook 回复 markdown 消息
Sourcepub async fn reply_card(
&self,
card_data: &Value,
incoming_message: &ChatbotMessage,
at_sender: bool,
at_all: bool,
) -> Result<String>
pub async fn reply_card( &self, card_data: &Value, incoming_message: &ChatbotMessage, at_sender: bool, at_all: bool, ) -> Result<String>
发送互动卡片 (OpenAPI)
Sourcepub async fn update_card(
&self,
card_biz_id: &str,
card_data: &Value,
) -> Result<Value>
pub async fn update_card( &self, card_biz_id: &str, card_data: &Value, ) -> Result<Value>
更新互动卡片
Sourcepub fn create_ai_card_replier(
&self,
incoming_message: &ChatbotMessage,
) -> AICardReplier
pub fn create_ai_card_replier( &self, incoming_message: &ChatbotMessage, ) -> AICardReplier
创建 AI 卡片回复器,用于自定义模板场景
Sourcepub async fn reply_markdown_card(
&self,
markdown: &str,
incoming_message: &ChatbotMessage,
title: &str,
logo: &str,
at_sender: bool,
at_all: bool,
) -> Result<MarkdownCardInstance>
pub async fn reply_markdown_card( &self, markdown: &str, incoming_message: &ChatbotMessage, title: &str, logo: &str, at_sender: bool, at_all: bool, ) -> Result<MarkdownCardInstance>
回复 Markdown 卡片
Sourcepub async fn reply_rpa_plugin_card(
&self,
incoming_message: &ChatbotMessage,
plugin_id: &str,
plugin_version: &str,
plugin_name: &str,
ability_name: &str,
plugin_args: &Value,
goal: &str,
corp_id: &str,
recipients: Option<&[String]>,
) -> Result<RPAPluginCardInstance>
pub async fn reply_rpa_plugin_card( &self, incoming_message: &ChatbotMessage, plugin_id: &str, plugin_version: &str, plugin_name: &str, ability_name: &str, plugin_args: &Value, goal: &str, corp_id: &str, recipients: Option<&[String]>, ) -> Result<RPAPluginCardInstance>
回复 RPA 插件卡片
回复带按钮的 Markdown 卡片
回复带按钮的 AI Markdown 卡片
Sourcepub async fn reply_carousel_card(
&self,
incoming_message: &ChatbotMessage,
markdown: &str,
image_slider: &[(String, String)],
button_text: &str,
title: &str,
logo: &str,
) -> Result<CarouselCardInstance>
pub async fn reply_carousel_card( &self, incoming_message: &ChatbotMessage, markdown: &str, image_slider: &[(String, String)], button_text: &str, title: &str, logo: &str, ) -> Result<CarouselCardInstance>
回复轮播图卡片
Sourcepub async fn ai_markdown_card_start(
&self,
incoming_message: &ChatbotMessage,
title: &str,
logo: &str,
recipients: Option<&[String]>,
) -> Result<AIMarkdownCardInstance>
pub async fn ai_markdown_card_start( &self, incoming_message: &ChatbotMessage, title: &str, logo: &str, recipients: Option<&[String]>, ) -> Result<AIMarkdownCardInstance>
发起 AI 卡片
Sourcepub fn extract_text(incoming_message: &ChatbotMessage) -> Option<Vec<String>>
pub fn extract_text(incoming_message: &ChatbotMessage) -> Option<Vec<String>>
从消息中提取文本列表
Sourcepub async fn extract_and_reupload_images(
&self,
incoming_message: &ChatbotMessage,
) -> Result<Vec<String>>
pub async fn extract_and_reupload_images( &self, incoming_message: &ChatbotMessage, ) -> Result<Vec<String>>
从消息中提取图片,下载后重新上传到钉钉
Sourcepub async fn get_image_download_url(
&self,
download_code: &str,
) -> Result<String>
pub async fn get_image_download_url( &self, download_code: &str, ) -> Result<String>
根据 download_code 获取图片下载 URL
Sourcepub async fn upload_to_dingtalk(
&self,
content: &[u8],
filetype: &str,
filename: &str,
mimetype: &str,
) -> Result<String>
pub async fn upload_to_dingtalk( &self, content: &[u8], filetype: &str, filename: &str, mimetype: &str, ) -> Result<String>
上传文件到钉钉
Sourcepub async fn send_oto_message(
&self,
user_id: &str,
msg_key: &str,
msg_param: &str,
) -> Result<Value>
pub async fn send_oto_message( &self, user_id: &str, msg_key: &str, msg_param: &str, ) -> Result<Value>
通过 OpenAPI 向指定用户发送单聊消息(OTO = One-To-One)。
对应钉钉 OpenAPI:POST /v1.0/robot/oToMessages/batchSend
§Arguments
user_id– 接收者的 userId(即 staffId)msg_key– 消息模板 key,如"sampleFile","sampleText"等msg_param– 消息模板参数的 JSON 字符串
Trait Implementations§
Source§impl Clone for ChatbotReplier
impl Clone for ChatbotReplier
Source§fn clone(&self) -> ChatbotReplier
fn clone(&self) -> ChatbotReplier
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ChatbotReplier
impl !RefUnwindSafe for ChatbotReplier
impl Send for ChatbotReplier
impl Sync for ChatbotReplier
impl Unpin for ChatbotReplier
impl UnsafeUnpin for ChatbotReplier
impl !UnwindSafe for ChatbotReplier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more