Skip to content

Commit

Permalink
Merge pull request #36 from Desiders/add-support-bot-api-7.6
Browse files Browse the repository at this point in the history
Add support Bot API 7.6
  • Loading branch information
Desiders authored Aug 14, 2024
2 parents 6950b0a + c8b9f72 commit f5e9037
Show file tree
Hide file tree
Showing 24 changed files with 965 additions and 22 deletions.
6 changes: 5 additions & 1 deletion telers/src/enums/content_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub enum ContentType {
Audio,
#[strum(serialize = "document")]
Document,
#[strum(serialize = "paid_media")]
PaidMedia,
#[strum(serialize = "photo")]
Photo,
#[strum(serialize = "sticker")]
Expand Down Expand Up @@ -117,12 +119,13 @@ pub enum ContentType {

impl ContentType {
#[must_use]
pub const fn all() -> [ContentType; 53] {
pub const fn all() -> [ContentType; 54] {
[
ContentType::Text,
ContentType::Animation,
ContentType::Audio,
ContentType::Document,
ContentType::PaidMedia,
ContentType::Photo,
ContentType::Sticker,
ContentType::Story,
Expand Down Expand Up @@ -201,6 +204,7 @@ impl From<&Message> for ContentType {
Message::Animation(_) => ContentType::Animation,
Message::Audio(_) => ContentType::Audio,
Message::Document(_) => ContentType::Document,
Message::PaidMedia(_) => ContentType::PaidMedia,
Message::Photo(_) => ContentType::Photo,
Message::Sticker(_) => ContentType::Sticker,
Message::Story(_) => ContentType::Story,
Expand Down
2 changes: 2 additions & 0 deletions telers/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub mod send_invoice;
pub mod send_location;
pub mod send_media_group;
pub mod send_message;
pub mod send_paid_media;
pub mod send_photo;
pub mod send_poll;
pub mod send_sticker;
Expand Down Expand Up @@ -225,6 +226,7 @@ pub use send_invoice::SendInvoice;
pub use send_location::SendLocation;
pub use send_media_group::SendMediaGroup;
pub use send_message::SendMessage;
pub use send_paid_media::SendPaidMedia;
pub use send_photo::SendPhoto;
pub use send_poll::SendPoll;
pub use send_sticker::SendSticker;
Expand Down
25 changes: 24 additions & 1 deletion telers/src/methods/base.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
client::Bot,
types::{InputFile, InputMedia, InputSticker, ResponseParameters},
types::{InputFile, InputMedia, InputPaidMedia, InputSticker, ResponseParameters},
};

use serde::{de::DeserializeOwned, Deserialize, Serialize};
Expand Down Expand Up @@ -131,3 +131,26 @@ pub(super) fn prepare_input_stickers<'a>(
prepare_input_sticker(files, input_sticker);
}
}

pub(super) fn prepare_input_paid_media<'a>(
files: &mut Vec<&'a InputFile<'a>>,
input_paid_media: &'a InputPaidMedia<'a>,
) {
match input_paid_media {
InputPaidMedia::Photo(inner) => {
prepare_file(files, &inner.media);
}
InputPaidMedia::Video(inner) => {
prepare_file(files, &inner.media);
}
}
}

pub(super) fn prepare_input_paid_media_group<'a>(
files: &mut Vec<&'a InputFile<'a>>,
input_paid_media_group: &'a [InputPaidMedia<'a>],
) {
for input_paid_media in input_paid_media_group {
prepare_input_paid_media(files, input_paid_media);
}
}
2 changes: 1 addition & 1 deletion telers/src/methods/copy_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
use serde::Serialize;
use serde_with::skip_serializing_none;

/// Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. A quiz [`poll`](crate::types::Poll) can be copied only if the value of the field `correct_option_id` is known to the bot. The method is analogous to the method [`ForwardMessage`](crate::methods::ForwardMessage), but the copied message doesn't have a link to the original message.
/// Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [`poll`](crate::types::Poll) can be copied only if the value of the field `correct_option_id` is known to the bot. The method is analogous to the method [`ForwardMessage`](crate::methods::ForwardMessage), but the copied message doesn't have a link to the original message.
/// # Documentation
/// <https://core.telegram.org/bots/api#copymessage>
/// # Returns
Expand Down
2 changes: 1 addition & 1 deletion telers/src/methods/copy_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
use serde::Serialize;
use serde_with::skip_serializing_none;

/// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [`poll`](crate::types::Poll) can be copied only if the value of the field `correct_option_id` is known to the bot. The method is analogous to the method [`ForwardMessages`](crate::methods::ForwardMessages), but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.
/// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [`poll`](crate::types::Poll) can be copied only if the value of the field `correct_option_id` is known to the bot. The method is analogous to the method [`ForwardMessages`](crate::methods::ForwardMessages), but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.
/// # Documentation
/// <https://core.telegram.org/bots/api#copymessages>
/// # Returns
Expand Down
Loading

0 comments on commit f5e9037

Please sign in to comment.