pub struct RobotClient {
pub key: String,
pub client: Client,
}
Expand description
企业微信群机器人客户端
Fields§
§key: String
§client: Client
Implementations§
Source§impl RobotClient
impl RobotClient
Sourcepub fn new(key: &str) -> Self
pub fn new(key: &str) -> Self
创建一个新的机器人客户端实例
§Arguments
webhook_key
- 机器人的 Webhook Key (从 webhook_url 中提取,例如: 693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa)
Sourcepub async fn send_message(&self, message: &RobotMessage) -> Result<()>
pub async fn send_message(&self, message: &RobotMessage) -> Result<()>
发送消息到群机器人
Sourcepub async fn upload_media(
&self,
file_path: &str,
file_type: FileType,
) -> Result<SendRobotMessage>
pub async fn upload_media( &self, file_path: &str, file_type: FileType, ) -> Result<SendRobotMessage>
上传文件到企业微信,用于发送文件或语音消息
§Arguments
file_path
- 本地文件的路径file_type
- 文件类型,根据企业微信文档,此处应为 “file” (文件), “voice” (语音), “image” (图片)0
Sourcepub async fn send_file_message(&self, file_path: &str) -> Result<()>
pub async fn send_file_message(&self, file_path: &str) -> Result<()>
发送文件消息 (通过先上传文件获取media_id)
Trait Implementations§
Source§impl ClientTrait for RobotClient
impl ClientTrait for RobotClient
async fn access_token(&self) -> Result<String>
async fn refresh_access_token(&mut self) -> Result<()>
fn http_client(&self) -> &Client
fn url_with_query<I, K, V>( &self, url: &str, queries: I, ) -> Result<Url, WechatError>
fn get_empty<R, U>( &self, url: U, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn get<R, U, T>( &self, url: U, query: &T, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn post_empty<R, U>( &self, url: U, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn post<R, U, T>( &self, url: U, data: &T, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn upload<R, U>( &self, url: U, multipart: Form, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn upload_with<R, U, T>( &self, url: U, data: &T, multipart: Form, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn json<R, U, T>( &self, url: U, data: &T, ) -> impl Future<Output = Result<R, WechatError>> + Send
fn download<U, T>( &self, url: U, query: &T, ) -> impl Future<Output = Result<Vec<u8>, WechatError>> + Send
Source§impl Clone for RobotClient
impl Clone for RobotClient
Source§fn clone(&self) -> RobotClient
fn clone(&self) -> RobotClient
Returns a copy 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 RobotClient
impl !RefUnwindSafe for RobotClient
impl Send for RobotClient
impl Sync for RobotClient
impl Unpin for RobotClient
impl !UnwindSafe for RobotClient
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