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
impl SetWebhook
sourcepub fn new<T>(url: T) -> Self
pub fn new<T>(url: T) -> Self
Creates a new SetWebhook
.
§Arguments
url
- HTTPS url to send updates to; use an empty string to remove webhook integration.
sourcepub fn add_allowed_update(self, value: AllowedUpdate) -> Self
pub fn add_allowed_update(self, value: AllowedUpdate) -> Self
sourcepub fn with_allowed_updates(self, value: HashSet<AllowedUpdate>) -> Self
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.
sourcepub fn with_certificate<T>(self, value: T) -> Self
pub fn with_certificate<T>(self, value: T) -> Self
Sets a new certificate.
§Arguments
value
- Public key certificate; so that the root certificate in use can be checked.
sourcepub fn with_drop_pending_updates(self, value: bool) -> Self
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.
sourcepub fn with_ip_address<T>(self, value: T) -> Self
pub fn with_ip_address<T>(self, value: T) -> Self
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.
sourcepub fn with_max_connections(self, value: Integer) -> Self
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.
sourcepub fn with_secret_token<T>(self, value: T) -> Self
pub fn with_secret_token<T>(self, value: T) -> Self
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
impl Clone for SetWebhook
source§fn clone(&self) -> SetWebhook
fn clone(&self) -> SetWebhook
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more