diff --git a/telers/src/methods/copy_message.rs b/telers/src/methods/copy_message.rs index 2c5e153..861c2ee 100644 --- a/telers/src/methods/copy_message.rs +++ b/telers/src/methods/copy_message.rs @@ -36,6 +36,8 @@ pub struct CopyMessage { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Description of the message to reply to pub reply_parameters: Option, /// Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove reply keyboard or to force a reply from the user. @@ -60,6 +62,7 @@ impl CopyMessage { show_caption_above_media: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, reply_parameters: None, reply_markup: None, } @@ -165,6 +168,14 @@ impl CopyMessage { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn reply_parameters(self, val: ReplyParameters) -> Self { Self { @@ -248,6 +259,14 @@ impl CopyMessage { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn reply_parameters_option(self, val: Option) -> Self { Self { diff --git a/telers/src/methods/edit_message_media.rs b/telers/src/methods/edit_message_media.rs index 6dee15f..a7df695 100644 --- a/telers/src/methods/edit_message_media.rs +++ b/telers/src/methods/edit_message_media.rs @@ -8,9 +8,11 @@ use crate::{ use serde::Serialize; use serde_with::skip_serializing_none; -/// Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its `file_id` or specify a URL. +/// Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL /// # Documentation /// +/// # Notes +/// Business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. /// # Returns /// On success, if the edited message is not an inline message, the edited [`crate::types::Message`] is returned, otherwise `true` is returned #[skip_serializing_none] diff --git a/telers/src/methods/forward_message.rs b/telers/src/methods/forward_message.rs index b9382ac..3225ee7 100644 --- a/telers/src/methods/forward_message.rs +++ b/telers/src/methods/forward_message.rs @@ -28,6 +28,8 @@ pub struct ForwardMessage { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, } impl ForwardMessage { @@ -44,6 +46,7 @@ impl ForwardMessage { message_id, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, } } @@ -94,6 +97,14 @@ impl ForwardMessage { ..self } } + + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } } impl ForwardMessage { @@ -120,6 +131,14 @@ impl ForwardMessage { ..self } } + + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } } impl TelegramMethod for ForwardMessage { diff --git a/telers/src/methods/send_animation.rs b/telers/src/methods/send_animation.rs index 0c23ade..830a6d8 100644 --- a/telers/src/methods/send_animation.rs +++ b/telers/src/methods/send_animation.rs @@ -48,6 +48,8 @@ pub struct SendAnimation<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -76,6 +78,7 @@ impl<'a> SendAnimation<'a> { supports_streaming: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -230,6 +233,14 @@ impl<'a> SendAnimation<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -374,6 +385,14 @@ impl<'a> SendAnimation<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_audio.rs b/telers/src/methods/send_audio.rs index 0830af4..6c6b486 100644 --- a/telers/src/methods/send_audio.rs +++ b/telers/src/methods/send_audio.rs @@ -42,6 +42,8 @@ pub struct SendAudio<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -67,6 +69,7 @@ impl<'a> SendAudio<'a> { thumbnail: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -197,6 +200,14 @@ impl<'a> SendAudio<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -320,6 +331,14 @@ impl<'a> SendAudio<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_contact.rs b/telers/src/methods/send_contact.rs index b0bb67e..5f1f210 100644 --- a/telers/src/methods/send_contact.rs +++ b/telers/src/methods/send_contact.rs @@ -34,6 +34,8 @@ pub struct SendContact { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -59,6 +61,7 @@ impl SendContact { vcard: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -137,6 +140,14 @@ impl SendContact { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -211,6 +222,14 @@ impl SendContact { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_dice.rs b/telers/src/methods/send_dice.rs index 4acfd9f..767efe7 100644 --- a/telers/src/methods/send_dice.rs +++ b/telers/src/methods/send_dice.rs @@ -28,6 +28,8 @@ pub struct SendDice { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -46,6 +48,7 @@ impl SendDice { emoji: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -100,6 +103,14 @@ impl SendDice { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -166,6 +177,14 @@ impl SendDice { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_document.rs b/telers/src/methods/send_document.rs index 107373d..0fa0cf6 100644 --- a/telers/src/methods/send_document.rs +++ b/telers/src/methods/send_document.rs @@ -38,6 +38,8 @@ pub struct SendDocument<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -61,6 +63,7 @@ impl<'a> SendDocument<'a> { disable_content_type_detection: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -175,6 +178,14 @@ impl<'a> SendDocument<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -274,6 +285,14 @@ impl<'a> SendDocument<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_game.rs b/telers/src/methods/send_game.rs index 54cac5c..aca05ff 100644 --- a/telers/src/methods/send_game.rs +++ b/telers/src/methods/send_game.rs @@ -28,6 +28,8 @@ pub struct SendGame { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -46,6 +48,7 @@ impl SendGame { game_short_name: game_short_name.into(), disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -100,6 +103,14 @@ impl SendGame { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -158,6 +169,14 @@ impl SendGame { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_invoice.rs b/telers/src/methods/send_invoice.rs index 08e114e..ab0be87 100644 --- a/telers/src/methods/send_invoice.rs +++ b/telers/src/methods/send_invoice.rs @@ -66,6 +66,8 @@ pub struct SendInvoice { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -111,6 +113,7 @@ impl SendInvoice { is_flexible: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -337,6 +340,14 @@ impl SendInvoice { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -499,6 +510,14 @@ impl SendInvoice { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_location.rs b/telers/src/methods/send_location.rs index a21b9a1..6737006 100644 --- a/telers/src/methods/send_location.rs +++ b/telers/src/methods/send_location.rs @@ -38,6 +38,8 @@ pub struct SendLocation { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -61,6 +63,7 @@ impl SendLocation { proximity_alert_radius: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -155,6 +158,14 @@ impl SendLocation { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -245,6 +256,14 @@ impl SendLocation { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_media_group.rs b/telers/src/methods/send_media_group.rs index de311de..20ff447 100644 --- a/telers/src/methods/send_media_group.rs +++ b/telers/src/methods/send_media_group.rs @@ -28,6 +28,8 @@ pub struct SendMediaGroup<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -48,6 +50,7 @@ impl<'a> SendMediaGroup<'a> { media: media.into_iter().map(Into::into).collect(), disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, } @@ -117,6 +120,14 @@ impl<'a> SendMediaGroup<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -167,6 +178,14 @@ impl<'a> SendMediaGroup<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_message.rs b/telers/src/methods/send_message.rs index dd7235a..59cb21e 100644 --- a/telers/src/methods/send_message.rs +++ b/telers/src/methods/send_message.rs @@ -34,6 +34,8 @@ pub struct SendMessage { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -55,6 +57,7 @@ impl SendMessage { link_preview_options: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -153,6 +156,14 @@ impl SendMessage { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -235,6 +246,14 @@ impl SendMessage { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_paid_media.rs b/telers/src/methods/send_paid_media.rs index ae0c775..88e8b82 100644 --- a/telers/src/methods/send_paid_media.rs +++ b/telers/src/methods/send_paid_media.rs @@ -38,6 +38,8 @@ pub struct SendPaidMedia<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Description of the message to reply to pub reply_parameters: Option, /// Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove reply keyboard or to force a reply from the user. @@ -63,6 +65,7 @@ impl<'a> SendPaidMedia<'a> { show_caption_above_media: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, reply_parameters: None, reply_markup: None, } @@ -192,6 +195,14 @@ impl<'a> SendPaidMedia<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn reply_parameters(self, val: ReplyParameters) -> Self { Self { @@ -283,6 +294,14 @@ impl<'a> SendPaidMedia<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn reply_parameters_option(self, val: Option) -> Self { Self { diff --git a/telers/src/methods/send_photo.rs b/telers/src/methods/send_photo.rs index cee33a8..0cde28f 100644 --- a/telers/src/methods/send_photo.rs +++ b/telers/src/methods/send_photo.rs @@ -38,6 +38,8 @@ pub struct SendPhoto<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -61,6 +63,7 @@ impl<'a> SendPhoto<'a> { has_spoiler: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -175,6 +178,14 @@ impl<'a> SendPhoto<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -282,6 +293,14 @@ impl<'a> SendPhoto<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_poll.rs b/telers/src/methods/send_poll.rs index 1b36fe0..08dc560 100644 --- a/telers/src/methods/send_poll.rs +++ b/telers/src/methods/send_poll.rs @@ -55,6 +55,8 @@ pub struct SendPoll { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -94,6 +96,7 @@ impl SendPoll { is_closed: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -308,6 +311,14 @@ impl SendPoll { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -465,6 +476,14 @@ impl SendPoll { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_sticker.rs b/telers/src/methods/send_sticker.rs index aa523f5..1017758 100644 --- a/telers/src/methods/send_sticker.rs +++ b/telers/src/methods/send_sticker.rs @@ -30,6 +30,8 @@ pub struct SendSticker<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -49,6 +51,7 @@ impl<'a> SendSticker<'a> { emoji: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -111,6 +114,14 @@ impl<'a> SendSticker<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -177,6 +188,14 @@ impl<'a> SendSticker<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_venue.rs b/telers/src/methods/send_venue.rs index 75f46ac..99f0e09 100644 --- a/telers/src/methods/send_venue.rs +++ b/telers/src/methods/send_venue.rs @@ -42,6 +42,8 @@ pub struct SendVenue { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -73,6 +75,7 @@ impl SendVenue { google_place_type: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -183,6 +186,14 @@ impl SendVenue { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -273,6 +284,14 @@ impl SendVenue { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_video.rs b/telers/src/methods/send_video.rs index ee267e2..2774cbc 100644 --- a/telers/src/methods/send_video.rs +++ b/telers/src/methods/send_video.rs @@ -48,6 +48,8 @@ pub struct SendVideo<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -76,6 +78,7 @@ impl<'a> SendVideo<'a> { supports_streaming: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -230,6 +233,14 @@ impl<'a> SendVideo<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -374,6 +385,14 @@ impl<'a> SendVideo<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_video_note.rs b/telers/src/methods/send_video_note.rs index 227d949..c392150 100644 --- a/telers/src/methods/send_video_note.rs +++ b/telers/src/methods/send_video_note.rs @@ -34,6 +34,8 @@ pub struct SendVideoNote<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -55,6 +57,7 @@ impl<'a> SendVideoNote<'a> { thumbnail: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -133,6 +136,14 @@ impl<'a> SendVideoNote<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -215,6 +226,14 @@ impl<'a> SendVideoNote<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/methods/send_voice.rs b/telers/src/methods/send_voice.rs index 3e2a883..46df8fe 100644 --- a/telers/src/methods/send_voice.rs +++ b/telers/src/methods/send_voice.rs @@ -36,6 +36,8 @@ pub struct SendVoice<'a> { pub disable_notification: Option, /// Protects the contents of the sent message from forwarding and saving pub protect_content: Option, + /// Pass `true` to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance + pub allow_paid_broadcast: Option, /// Unique identifier of the message effect to be added to the message; for private chats only pub message_effect_id: Option, /// Description of the message to reply to @@ -58,6 +60,7 @@ impl<'a> SendVoice<'a> { duration: None, disable_notification: None, protect_content: None, + allow_paid_broadcast: None, message_effect_id: None, reply_parameters: None, reply_markup: None, @@ -164,6 +167,14 @@ impl<'a> SendVoice<'a> { } } + #[must_use] + pub fn allow_paid_broadcast(self, val: bool) -> Self { + Self { + allow_paid_broadcast: Some(val), + ..self + } + } + #[must_use] pub fn message_effect_id(self, val: impl Into) -> Self { Self { @@ -263,6 +274,14 @@ impl<'a> SendVoice<'a> { } } + #[must_use] + pub fn allow_paid_broadcast_option(self, val: Option) -> Self { + Self { + allow_paid_broadcast: val, + ..self + } + } + #[must_use] pub fn message_effect_id_option(self, val: Option>) -> Self { Self { diff --git a/telers/src/types.rs b/telers/src/types.rs index 8878d60..81e0c65 100644 --- a/telers/src/types.rs +++ b/telers/src/types.rs @@ -99,6 +99,7 @@ pub mod chat_photo; pub mod chat_shared; pub mod chosen_inline_result; pub mod contact; +pub mod copy_text_button; pub mod dice; pub mod document; pub mod encrypted_credentials; @@ -247,6 +248,7 @@ pub mod transaction_partner; pub mod transaction_partner_fragment; pub mod transaction_partner_other; pub mod transaction_partner_telegram_ads; +pub mod transaction_partner_telegram_api; pub mod transaction_partner_user; pub mod update; pub mod user; @@ -330,6 +332,7 @@ pub use chat_photo::ChatPhoto; pub use chat_shared::ChatShared; pub use chosen_inline_result::ChosenInlineResult; pub use contact::Contact; +pub use copy_text_button::CopyTextButton; pub use dice::Dice; pub use document::Document; pub use encrypted_credentials::EncryptedCredentials; @@ -555,6 +558,7 @@ pub use transaction_partner::TransactionPartner; pub use transaction_partner_fragment::TransactionPartnerFragment; pub use transaction_partner_other::TransactionPartnerOther; pub use transaction_partner_telegram_ads::TransactionPartnerTelegramAds; +pub use transaction_partner_telegram_api::TransactionPartnerTelegramApi; pub use transaction_partner_user::TransactionPartnerUser; pub use update::{Kind as UpdateKind, Update}; pub use user::User; diff --git a/telers/src/types/copy_text_button.rs b/telers/src/types/copy_text_button.rs new file mode 100644 index 0000000..5d09275 --- /dev/null +++ b/telers/src/types/copy_text_button.rs @@ -0,0 +1,22 @@ +use serde::{Deserialize, Serialize}; + +/// This object represents an inline keyboard button that copies specified text to the clipboard. +/// # Documentation +/// +#[derive(Debug, Clone, Hash, PartialEq, Eq, Deserialize, Serialize)] +pub struct CopyTextButton { + /// The text to be copied to the clipboard; 1-256 characters + pub text: String, +} + +impl CopyTextButton { + #[must_use] + pub fn new(text: impl Into) -> Self { + Self { text: text.into() } + } + + #[must_use] + pub fn text(self, val: impl Into) -> Self { + Self { text: val.into() } + } +} diff --git a/telers/src/types/inline_keyboard_button.rs b/telers/src/types/inline_keyboard_button.rs index ad35571..ff0f53d 100644 --- a/telers/src/types/inline_keyboard_button.rs +++ b/telers/src/types/inline_keyboard_button.rs @@ -1,9 +1,9 @@ -use super::{CallbackGame, LoginUrl, SwitchInlineQueryChosenChat, WebAppInfo}; +use super::{CallbackGame, CopyTextButton, LoginUrl, SwitchInlineQueryChosenChat, WebAppInfo}; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; -/// This object represents one button of an inline keyboard. You **must** use exactly one of the optional fields. +/// This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button. /// # Documentation /// #[skip_serializing_none] @@ -21,13 +21,16 @@ pub struct InlineKeyboardButton { pub login_url: Option, /// If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent on behalf of a Telegram Business account. pub switch_inline_query: Option, - /// If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent on behalf of a Telegram Business account. + /// If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. + /// This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent on behalf of a Telegram Business account. pub switch_inline_query_current_chat: Option, /// If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account. pub switch_inline_query_chosen_chat: Option, + /// Description of the button that copies the specified text to the clipboard. + pub copy_text: Option, /// Description of the game that will be launched when the user presses the button. This type of button **must** always be the first button in the first row. pub callback_game: Option, - /// Specify `true`, to send a [`Pay button`](https://core.telegram.org/bots/api#payments). + /// Specify `true`, to send a [`Pay button`](https://core.telegram.org/bots/api#payments). Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. This type of button **must** always be the first button in the first row and can only be used in invoice messages. pub pay: Option, } @@ -43,6 +46,7 @@ impl InlineKeyboardButton { switch_inline_query: None, switch_inline_query_current_chat: None, switch_inline_query_chosen_chat: None, + copy_text: None, callback_game: None, pay: None, } @@ -112,6 +116,14 @@ impl InlineKeyboardButton { } } + #[must_use] + pub fn copy_text(self, val: CopyTextButton) -> Self { + Self { + copy_text: Some(val), + ..self + } + } + #[must_use] pub fn callback_game(self, val: CallbackGame) -> Self { Self { @@ -189,6 +201,14 @@ impl InlineKeyboardButton { } } + #[must_use] + pub fn copy_text_option(self, val: Option) -> Self { + Self { + copy_text: val, + ..self + } + } + #[must_use] pub fn callback_game_option(self, val: Option) -> Self { Self { diff --git a/telers/src/types/transaction_partner.rs b/telers/src/types/transaction_partner.rs index 55d88ca..ce3ef51 100644 --- a/telers/src/types/transaction_partner.rs +++ b/telers/src/types/transaction_partner.rs @@ -1,6 +1,6 @@ use super::{ TransactionPartnerFragment, TransactionPartnerOther, TransactionPartnerTelegramAds, - TransactionPartnerUser, + TransactionPartnerTelegramApi, TransactionPartnerUser, }; use serde::{Deserialize, Serialize}; @@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize}; /// - [`TransactionPartnerUser`] /// - [`TransactionPartnerFragment`] /// - [`TransactionPartnerTelegramAds`] +/// - [`TransactionPartnerTelegramApi`] /// - [`TransactionPartnerOther`] /// # Documentation /// @@ -18,6 +19,7 @@ pub enum TransactionPartner { User(TransactionPartnerUser), Fragment(TransactionPartnerFragment), TelegramAds(TransactionPartnerTelegramAds), + TelegramApi(TransactionPartnerTelegramApi), Other(TransactionPartnerOther), } @@ -39,6 +41,12 @@ impl From for TransactionPartner { } } +impl From for TransactionPartner { + fn from(partner: TransactionPartnerTelegramApi) -> Self { + Self::TelegramApi(partner) + } +} + impl From for TransactionPartner { fn from(partner: TransactionPartnerOther) -> Self { Self::Other(partner) diff --git a/telers/src/types/transaction_partner_telegram_api.rs b/telers/src/types/transaction_partner_telegram_api.rs new file mode 100644 index 0000000..ee2f6cd --- /dev/null +++ b/telers/src/types/transaction_partner_telegram_api.rs @@ -0,0 +1,10 @@ +use serde::{Deserialize, Serialize}; + +/// Describes a transaction with payment for [paid broadcasting](https://core.telegram.org/bots/api#paid-broadcasts) +/// # Documentation +/// +#[derive(Debug, Default, Clone, Hash, PartialEq, Eq, Deserialize, Serialize)] +pub struct TransactionPartnerTelegramApi { + /// The number of successful requests that exceeded regular limits and were therefore billed + pub request_count: i64, +} diff --git a/telers/src/utils/text/markdown_formatter.rs b/telers/src/utils/text/markdown_formatter.rs index aaaa594..2c11e80 100644 --- a/telers/src/utils/text/markdown_formatter.rs +++ b/telers/src/utils/text/markdown_formatter.rs @@ -109,9 +109,12 @@ impl TextFormatter for Formatter { T: AsRef, E: AsRef, { - self.text_link( - emoji, - format!("tg://emoji?id={emoji_id}", emoji_id = emoji_id.as_ref()), + format!( + "!{}", + self.text_link( + emoji, + format!("tg://emoji?id={emoji_id}", emoji_id = emoji_id.as_ref()), + ) ) } @@ -347,6 +350,15 @@ mod tests { assert_eq!(formatter.text_mention("text", 1), "[text](tg://user?id=1)"); } + #[test] + fn test_custom_emoji() { + let formatter = Formatter::default(); + assert_eq!( + formatter.custom_emoji("text", "1"), + "![text](tg://emoji?id=1)" + ); + } + #[test] fn test_code() { let formatter = Formatter::default();