diff --git a/CHANGELOG.md b/CHANGELOG.md index c02531c..2e0e7e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 0.18.0 (2022-06-21) +### [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022) - [#73](https://github.com/ayrat555/frankenstein/pull/73) + + * Added the fields `join_to_send_messages` and `join_by_request` to the struct `Chat`. + * Added the method `create_invoice_link` to generate an HTTP link for an invoice + * Added the field `is_premium` to the struct `User`. + * Added the field `premium_animation` to the struct `Sticker`. + * Added the field `added_to_attachment_menu` to the struct `User`. + * Added the parameter `secret_token` to the method `set_webhook`. + ## 0.17.0 (2022-06-16) * Change type of file_size from u32 to u64 by @ayrat555 in [#70](https://github.com/ayrat555/frankenstein/pull/70) diff --git a/Cargo.toml b/Cargo.toml index 9364a07..8db7a51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frankenstein" -version = "0.17.0" +version = "0.18.0" authors = ["Ayrat Badykov "] description = "Telegram bot API client for Rust" edition = "2018" diff --git a/README.md b/README.md index 49a7dbc..8030ee2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Telegram bot API client for Rust. -It's a complete wrapper for Telegram bot API and it's up to date with version 6 of the API. +It's a complete wrapper for Telegram bot API and it's up to date with version 6.1 of the API. Frankenstein data structures (rust structs and enums) are mapped one-to-one from Telegram bot API objects and method params. @@ -17,7 +17,7 @@ Add this to your Cargo.toml ```toml [dependencies] -frankenstein = "0.17" +frankenstein = "0.18" ``` ## Features @@ -35,13 +35,13 @@ frankenstein = "0.17" To use the async client add the following line to your `Cargo.toml` file: ```toml -frankenstein = { version = "0.17", default-features = false, features = ["async-http-client"] } +frankenstein = { version = "0.18", default-features = false, features = ["async-http-client"] } ``` You can also disable all features: ```toml -frankenstein = { version = "0.17", default-features = false } +frankenstein = { version = "0.18", default-features = false } ``` In this case the crate will ship only with telegram types @@ -158,7 +158,7 @@ It has two variants: ### Documentation -Frankenstein implements all telegram bot api methods. To see which parameters you should pass, check [docs.rs](https://docs.rs/frankenstein/0.17.0/frankenstein/api_traits/telegram_api/trait.TelegramApi.html#provided-methods) +Frankenstein implements all telegram bot api methods. To see which parameters you should pass, check [docs.rs](https://docs.rs/frankenstein/0.18.0/frankenstein/api_traits/telegram_api/trait.TelegramApi.html#provided-methods) You can check out a real world bot created using this library - [El Monitorro](https://github.com/ayrat555/el_monitorro). El Monitorro is a feed reader bot. @@ -170,7 +170,7 @@ The library uses `ureq` http client by default, but it can be easily replaced wi 1. `ureq` comes with a default feature (`impl`). So the feature should be disabled: ```toml -frankenstein = { version = "0.17", default-features = false, features = ["telegram-trait"] } +frankenstein = { version = "0.18", default-features = false, features = ["telegram-trait"] } ``` 2. Implement `TelegramApi` trait which requires two functions: diff --git a/src/api_params.rs b/src/api_params.rs index 33aa43f..a61c889 100644 --- a/src/api_params.rs +++ b/src/api_params.rs @@ -272,6 +272,10 @@ pub struct SetWebhookParams { #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub drop_pending_updates: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub secret_token: Option, } #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Builder)] @@ -1836,6 +1840,82 @@ pub struct SendInvoiceParams { pub reply_markup: Option, } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] +pub struct CreateInvoiceLinkParams { + #[builder(setter(into))] + pub title: String, + + #[builder(setter(into))] + pub description: String, + + #[builder(setter(into))] + pub payload: String, + + #[builder(setter(into))] + pub provider_token: String, + + #[builder(setter(into))] + pub currency: String, + + pub prices: Vec, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub max_tip_amount: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub suggested_tip_amounts: Option>, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub provider_data: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub photo_url: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub photo_size: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub photo_width: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub photo_height: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub need_name: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub need_phone_number: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub need_email: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub need_shipping_address: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub send_phone_number_to_provider: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub send_email_to_provider: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub is_flexible: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)] pub struct AnswerShippingQueryParams { #[builder(setter(into))] diff --git a/src/api_traits/async_telegram_api.rs b/src/api_traits/async_telegram_api.rs index 338d476..8380339 100644 --- a/src/api_traits/async_telegram_api.rs +++ b/src/api_traits/async_telegram_api.rs @@ -11,6 +11,7 @@ use crate::api_params::BanChatMemberParams; use crate::api_params::BanChatSenderChatParams; use crate::api_params::CopyMessageParams; use crate::api_params::CreateChatInviteLinkParams; +use crate::api_params::CreateInvoiceLinkParams; use crate::api_params::CreateNewStickerSetParams; use crate::api_params::DeclineChatJoinRequestParams; use crate::api_params::DeleteChatPhotoParams; @@ -967,6 +968,13 @@ pub trait AsyncTelegramApi { self.request("sendInvoice", Some(params)).await } + async fn create_invoice_link( + &self, + params: &CreateInvoiceLinkParams, + ) -> Result, Self::Error> { + self.request("createInvoiceLink", Some(params)).await + } + async fn answer_shipping_query( &self, params: &AnswerShippingQueryParams, diff --git a/src/api_traits/telegram_api.rs b/src/api_traits/telegram_api.rs index ed1ae71..183327d 100644 --- a/src/api_traits/telegram_api.rs +++ b/src/api_traits/telegram_api.rs @@ -11,6 +11,7 @@ use crate::api_params::BanChatMemberParams; use crate::api_params::BanChatSenderChatParams; use crate::api_params::CopyMessageParams; use crate::api_params::CreateChatInviteLinkParams; +use crate::api_params::CreateInvoiceLinkParams; use crate::api_params::CreateNewStickerSetParams; use crate::api_params::DeclineChatJoinRequestParams; use crate::api_params::DeleteChatPhotoParams; @@ -916,6 +917,13 @@ pub trait TelegramApi { self.request("sendInvoice", Some(params)) } + fn create_invoice_link( + &self, + params: &CreateInvoiceLinkParams, + ) -> Result, Self::Error> { + self.request("createInvoiceLink", Some(params)) + } + fn answer_shipping_query( &self, params: &AnswerShippingQueryParams, diff --git a/src/objects.rs b/src/objects.rs index 45a2833..051ca1c 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -377,6 +377,14 @@ pub struct User { #[builder(setter(into, strip_option), default)] pub language_code: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub is_premium: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub added_to_attachment_menu: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub can_join_groups: Option, @@ -425,6 +433,14 @@ pub struct Chat { #[builder(setter(into, strip_option), default)] pub has_private_forwards: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub join_to_send_messages: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub join_by_request: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub description: Option, @@ -1429,6 +1445,10 @@ pub struct Sticker { #[builder(setter(into, strip_option), default)] pub set_name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(setter(into, strip_option), default)] + pub premium_animation: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[builder(setter(into, strip_option), default)] pub mask_position: Option,