Struct tgbot::types::SetWebhook

source ·
pub struct SetWebhook { /* private fields */ }
Expand description

Specifies an url and returns incoming updates via an outgoing webhook.

Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.

If you’d like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token> Since nobody else knows your bot‘s token, you can be pretty sure it’s us.

Implementations§

source§

impl SetWebhook

source

pub fn new<T>(url: T) -> Self
where T: Into<String>,

Creates a new SetWebhook.

§Arguments
  • url - HTTPS url to send updates to; use an empty string to remove webhook integration.
source

pub fn add_allowed_update(self, value: AllowedUpdate) -> Self

Adds a type of update you want your bot to receive.

§Arguments
  • value - A type to add.
source

pub fn with_allowed_updates(self, value: HashSet<AllowedUpdate>) -> Self

Sets a new list of allowed update types.

§Arguments
  • value - List of types you want your bot to receive.

For example, specify [AllowedUpdate::Message] to only receive updates of these types. See AllowedUpdate for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used. Please note that this parameter doesn’t affect updates created before the call to the SetWebhook, so unwanted updates may be received for a short period of time.

source

pub fn with_certificate<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new certificate.

§Arguments
  • value - Public key certificate; so that the root certificate in use can be checked.
source

pub fn with_drop_pending_updates(self, value: bool) -> Self

Sets a new value for the drop_pending_updates flag.

§Arguments
  • value - Indicates whether to drop all pending updates.
source

pub fn with_ip_address<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new IP address.

§Arguments
  • value - The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS.
source

pub fn with_max_connections(self, value: Integer) -> Self

Sets a new number of max connections.

§Arguments
  • value - Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery; 1-100; default - 40.

Use lower values to limit the load on your bot‘s server, and higher values to increase your bot’s throughput.

source

pub fn with_secret_token<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new secret token.

§Arguments
  • value - A secret token to be sent in a header.

“X-Telegram-Bot-Api-Secret-Token” in every webhook request; 1-256 characters

Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

Trait Implementations§

source§

impl Clone for SetWebhook

source§

fn clone(&self) -> SetWebhook

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SetWebhook

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Method for SetWebhook

§

type Response = bool

The type representing a successful result in an API response.
source§

fn into_payload(self) -> Payload

Converts the method into a payload for an HTTP request.
source§

impl Serialize for SetWebhook

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
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