Skip to content

Commit

Permalink
Bot api 6.8 (#112)
Browse files Browse the repository at this point in the history
* api 6.8 and some fixes that i have seen

* fix clippy

* adresss comments from ayrat
  • Loading branch information
pxp9 authored Aug 21, 2023
1 parent 28cbf96 commit a107b53
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/api_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ pub struct InlineQueryResultsButton {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct SendInvoiceParams {
pub chat_id: i64,
pub chat_id: ChatId,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
Expand Down Expand Up @@ -2524,3 +2524,8 @@ pub struct GetChatMenuButtonParams {
#[builder(setter(into, strip_option), default)]
pub chat_id: Option<i64>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
pub struct UnpinAllGeneralForumTopicMessagesParams {
pub chat_id: ChatId,
}
9 changes: 9 additions & 0 deletions src/api_traits/async_telegram_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ use crate::objects::User;
use crate::objects::UserProfilePhotos;
use crate::objects::WebhookInfo;
use crate::Sticker;
use crate::UnpinAllGeneralForumTopicMessagesParams;
use async_trait::async_trait;
use std::path::PathBuf;

Expand Down Expand Up @@ -1266,6 +1267,14 @@ pub trait AsyncTelegramApi {
self.request("getChatMenuButton", Some(params)).await
}

async fn unpin_all_general_forum_topic_messages(
&self,
params: UnpinAllGeneralForumTopicMessagesParams,
) -> Result<MethodResponse<bool>, Self::Error> {
self.request("unpinAllGeneralForumTopicMessages", Some(params))
.await
}

async fn request_without_body<T: serde::de::DeserializeOwned>(
&self,
method: &str,
Expand Down
8 changes: 8 additions & 0 deletions src/api_traits/telegram_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ use crate::objects::UserProfilePhotos;
use crate::objects::WebhookInfo;
use crate::GetCustomEmojiStickersParams;
use crate::Sticker;
use crate::UnpinAllGeneralForumTopicMessagesParams;
use std::path::PathBuf;

pub trait TelegramApi {
Expand Down Expand Up @@ -1204,6 +1205,13 @@ pub trait TelegramApi {
self.request("getChatMenuButton", Some(params))
}

fn unpin_all_general_forum_topic_messages(
&self,
params: UnpinAllGeneralForumTopicMessagesParams,
) -> Result<MethodResponse<bool>, Self::Error> {
self.request("unpinAllGeneralForumTopicMessages", Some(params))
}

fn request_without_body<T: serde::de::DeserializeOwned>(
&self,
method: &str,
Expand Down
25 changes: 23 additions & 2 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ pub struct Chat {
#[builder(setter(into, strip_option), default)]
pub emoji_status_custom_emoji_id: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub emoji_status_expiration_date: Option<u32>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub bio: Option<String>,
Expand Down Expand Up @@ -660,6 +664,10 @@ pub struct Message {
#[builder(setter(into, strip_option), default)]
pub sticker: Option<Box<Sticker>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub story: Option<Box<Story>>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub video: Option<Box<Video>>,
Expand Down Expand Up @@ -1084,12 +1092,18 @@ pub struct PollOption {
pub voter_count: u32,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Builder)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct PollAnswer {
#[builder(setter(into))]
pub poll_id: String,

pub user: User,
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub voter_chat: Option<Chat>,

#[serde(skip_serializing_if = "Option::is_none")]
#[builder(setter(into, strip_option), default)]
pub user: Option<Box<User>>,

pub option_ids: Vec<u8>,
}
Expand Down Expand Up @@ -1787,6 +1801,13 @@ pub struct InputSticker {
pub keywords: Option<Vec<String>>,
}

// https://core.telegram.org/bots/api#story
// This object represents a message about a forwarded story in the chat.
// Currently holds no information.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct Story {}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder)]
pub struct StickerSet {
#[builder(setter(into))]
Expand Down

0 comments on commit a107b53

Please sign in to comment.