Struct mobot::api::api::API

source ·
pub struct API {
    pub client: Client,
}
Expand description

This is the main Telegram API client. Requires an instance of Client initialized with a valid API token.

Fields§

§client: Client

The underlying HTTP client.

Implementations§

source§

impl API

source

pub fn new(client: Client) -> Self

Returns a new Telegram API client.

source§

impl API

API methods for sending, editing, and deleting messages.

source

pub async fn send_chat_action( &self, req: &SendChatActionRequest ) -> Result<bool>

Send a message.

source§

impl API

API methods for sending, editing, and deleting messages.

source

pub async fn send_message(&self, req: &SendMessageRequest) -> Result<Message>

Send a message to a chat or channel.

Example
   api.send_message(&api::SendMessageRequest::new(chat_id, "Hello!")).await;
source

pub async fn edit_message_text( &self, req: &EditMessageTextRequest ) -> Result<Message>

Edit the text of a previously sent message.

Example
api.edit_message_text(
  &api::EditMessageTextRequest::new(String::from("Changed my mind: Goodbye world!"))
     .with_chat_id(chat_id)
     .with_message_id(message_id)
).await;
source

pub async fn edit_message_caption( &self, req: &EditMessageCaptionRequest ) -> Result<Message>

Edit the caption of a message.

source

pub async fn edit_message_reply_markup( &self, req: &EditMessageReplyMarkupRequest ) -> Result<Message>

Edit the reply markup of a message.

source

pub async fn delete_message(&self, req: &DeleteMessageRequest) -> Result<()>

Delete a message.

source

pub async fn remove_reply_keyboard( &self, chat_id: i64, text: String ) -> Result<Message>

source§

impl API

source§

impl API

source

pub async fn send_sticker(&self, req: &SendStickerRequest) -> Result<Message>

source§

impl API

source

pub async fn get_updates(&self, req: &GetUpdatesRequest) -> Result<Vec<Update>>

Use this method to receive incoming updates using long polling. An Array of Update objects is returned. See the official docs for more information.

source§

impl API

source

pub async fn get_me(&self) -> Result<User>

Auto Trait Implementations§

§

impl !RefUnwindSafe for API

§

impl Send for API

§

impl Sync for API

§

impl Unpin for API

§

impl !UnwindSafe for API

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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