pub struct Options {
    pub address: SocketAddr,
    pub url: Url,
    pub certificate: Option<InputFile>,
    pub max_connections: Option<u8>,
    pub drop_pending_updates: bool,
    pub secret_token: Option<String>,
}
Available on crate feature webhooks only.
Expand description

Options related to setting up webhooks.

Fields§

§address: SocketAddr

Local address to listen to.

§url: Url

Public url that Telegram will send updates to.

Note:

  • At the time of writing only ports 443, 80, 88 and 8443 are supported
  • This url must be forwarded to the address in order for webhook to work
  • This url should be kept private, otherwise malicious actors can pretend to be Telegram and send fake updates to your bot
§certificate: Option<InputFile>

Upload your public key certificate so that the root certificate in use can be checked. See Telegram’s self-signed guide for details.

Default - None.

§max_connections: Option<u8>

Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot’s server, and higher values to increase your bot’s throughput.

Default - None.

§drop_pending_updates: bool

Pass true to drop all pending updates.

Default - false.

§secret_token: Option<String>

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.

Default - teloxide will generate a random token.

Implementations§

Construct a new webhook options, see Options::address and Options::url for details.

Upload your public key certificate so that the root certificate in use can be checked. See Telegram’s self-signed guide for details.

Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot’s server, and higher values to increase your bot’s throughput.

Drop all pending updates before setting up webhook.

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.

Panics

If the token is invalid.

Returns self.secret_token, generating a new one if it’s None.

After a call to this function self.secret_token is always Some(_).

Note: if you leave webhook setup to teloxide, it will automatically generate a secret token. Call this function only if you need to know the secret (for example because you are calling set_webhook by yourself).

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Unerase this erased pointer. Read more
Available on non-enforce_1_1_0_semantics only.
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Turn this erasable pointer into an erased pointer. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more