Struct teloxide::update_listeners::webhooks::Options
source · 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>,
}
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§
source§impl Options
impl Options
sourcepub fn new(address: SocketAddr, url: Url) -> Self
pub fn new(address: SocketAddr, url: Url) -> Self
Construct a new webhook options, see Options::address
and
Options::url
for details.
sourcepub fn certificate(self, v: InputFile) -> Self
pub fn certificate(self, v: InputFile) -> Self
Upload your public key certificate so that the root certificate in use can be checked. See Telegram’s self-signed guide for details.
sourcepub fn max_connections(self, v: u8) -> Self
pub fn max_connections(self, v: u8) -> Self
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.
sourcepub fn drop_pending_updates(self) -> Self
pub fn drop_pending_updates(self) -> Self
Drop all pending updates before setting up webhook.
sourcepub fn secret_token(self, token: String) -> Self
pub fn secret_token(self, token: String) -> Self
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.
sourcepub fn get_or_gen_secret_token(&mut self) -> &str
pub fn get_or_gen_secret_token(&mut self) -> &str
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).