Skip to main content

WechatIlinkClient

Struct WechatIlinkClient 

Source
pub struct WechatIlinkClient { /* private fields */ }
Expand description

WechatIlinkClient is the main entry point for the WeChat iLink protocol.

Implementations§

Source§

impl WechatIlinkClient

Source

pub fn new() -> Self

Create a default client instance.

Source

pub fn builder() -> WechatIlinkClientBuilder

Create a client builder.

Source

pub async fn set_credentials(&self, creds: Credentials)

Install externally loaded credentials into this client.

Source

pub async fn credentials(&self) -> Option<Credentials>

Return the currently installed credentials, if any.

Source

pub fn login_qr(&self) -> LoginQrStream<'_>

Start QR login and return a stream of login events.

Applications display LoginQrEvent::QrCode, optionally answer LoginQrEvent::NeedVerifyCode, and persist credentials from LoginQrEvent::Confirmed.

Source

pub fn events_from_cursor( self: Arc<Self>, cursor: Option<String>, ) -> WechatEventStream<'static>

Start polling from an externally persisted cursor and stream resulting events.

Source

pub async fn reply( &self, msg: &IncomingMessage, text: &str, ) -> Result<SendReceipt>

Reply to an incoming message using its observed context.

Returns an error if the incoming message has no context (e.g. the context_token was empty in the wire message).

Source

pub async fn send_text_with_context( &self, context: &WechatContext, text: &str, ) -> Result<SendReceipt>

Send text using an explicit WechatContext.

The caller is responsible for supplying a valid context. This is the preferred way to send a reply when you already hold the context from an IncomingMessage.

Source

pub async fn send_media_with_context( &self, context: &WechatContext, content: SendContent, ) -> Result<SendReceipt>

Send media content using an explicit WechatContext.

The caller is responsible for supplying a valid context.

Source

pub async fn send_typing_with_context( &self, context: &WechatContext, ) -> Result<()>

Show “typing…” indicator using an explicit WechatContext.

The caller is responsible for supplying a valid context.

Source

pub async fn reply_media( &self, msg: &IncomingMessage, content: SendContent, ) -> Result<SendReceipt>

Reply with media content using the incoming message’s observed context.

Returns an error if the incoming message has no context.

Source

pub async fn download( &self, msg: &IncomingMessage, ) -> Result<Option<DownloadedMedia>>

Download media from an incoming message. Returns None if the message has no media. Priority: image > file > video > voice.

Source

pub async fn download_raw( &self, media: &CDNMedia, aeskey_override: Option<&str>, ) -> Result<Vec<u8>>

Download and decrypt a raw CDN media reference.

Source

pub async fn upload( &self, data: &[u8], user_id: &str, media_type: i32, ) -> Result<UploadResult>

Upload data to WeChat CDN without sending a message.

Source

pub async fn stop(&self)

Stop the bot.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more