mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
commit
22de637798
18 changed files with 234 additions and 23 deletions
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- `ApiError::TooMuchInlineQueryResults` ([#135][pr135])
|
||||
- Support for 5.4 telegram bot API ([#133][pr133])
|
||||
- Support for 5.5 telegram bot API ([#143][pr143])
|
||||
- `EditedMessageIsTooLong` error ([#109][pr109])
|
||||
- `UntilDate` enum and use it for `{Restricted, Banned}::until_date` ([#116][pr116])
|
||||
- `Limits::messages_per_min_channel` ([#121][pr121])
|
||||
|
@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[pr135]: https://github.com/teloxide/teloxide-core/pull/135
|
||||
[pr139]: https://github.com/teloxide/teloxide-core/pull/139
|
||||
[pr140]: https://github.com/teloxide/teloxide-core/pull/140
|
||||
[pr143]: https://github.com/teloxide/teloxide-core/pull/143
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -90,7 +90,8 @@ where
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
|
|
@ -97,7 +97,8 @@ where
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
|
|
@ -166,7 +166,8 @@ where
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
@ -386,6 +387,18 @@ trait ErasableRequester<'a> {
|
|||
custom_title: String,
|
||||
) -> ErasedRequest<'a, SetChatAdministratorCustomTitle, Self::Err>;
|
||||
|
||||
fn ban_chat_sender_chat(
|
||||
&self,
|
||||
chat_id: ChatId,
|
||||
sender_chat_id: i64,
|
||||
) -> ErasedRequest<'a, BanChatSenderChat, Self::Err>;
|
||||
|
||||
fn unban_chat_sender_chat(
|
||||
&self,
|
||||
chat_id: ChatId,
|
||||
sender_chat_id: i64,
|
||||
) -> ErasedRequest<'a, UnbanChatSenderChat, Self::Err>;
|
||||
|
||||
fn set_chat_permissions(
|
||||
&self,
|
||||
chat_id: ChatId,
|
||||
|
@ -960,6 +973,22 @@ where
|
|||
Requester::set_chat_administrator_custom_title(self, chat_id, user_id, custom_title).erase()
|
||||
}
|
||||
|
||||
fn ban_chat_sender_chat(
|
||||
&self,
|
||||
chat_id: ChatId,
|
||||
sender_chat_id: i64,
|
||||
) -> ErasedRequest<'a, BanChatSenderChat, Self::Err> {
|
||||
Requester::ban_chat_sender_chat(self, chat_id, sender_chat_id).erase()
|
||||
}
|
||||
|
||||
fn unban_chat_sender_chat(
|
||||
&self,
|
||||
chat_id: ChatId,
|
||||
sender_chat_id: i64,
|
||||
) -> ErasedRequest<'a, UnbanChatSenderChat, Self::Err> {
|
||||
Requester::unban_chat_sender_chat(self, chat_id, sender_chat_id).erase()
|
||||
}
|
||||
|
||||
fn set_chat_permissions(
|
||||
&self,
|
||||
chat_id: ChatId,
|
||||
|
|
|
@ -102,7 +102,8 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
|
|
@ -605,7 +605,8 @@ where
|
|||
stop_message_live_location, stop_message_live_location_inline,
|
||||
send_chat_action, get_user_profile_photos, get_file, kick_chat_member, ban_chat_member,
|
||||
unban_chat_member, restrict_chat_member, promote_chat_member,
|
||||
set_chat_administrator_custom_title, set_chat_permissions,
|
||||
set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
|
|
@ -122,7 +122,8 @@ where
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
|
|
@ -399,6 +399,34 @@ impl Requester for Bot {
|
|||
)
|
||||
}
|
||||
|
||||
type BanChatSenderChat = JsonRequest<payloads::BanChatSenderChat>;
|
||||
|
||||
fn ban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::BanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self::BanChatSenderChat::new(
|
||||
self.clone(),
|
||||
payloads::BanChatSenderChat::new(chat_id, sender_chat_id),
|
||||
)
|
||||
}
|
||||
|
||||
type UnbanChatSenderChat = JsonRequest<payloads::UnbanChatSenderChat>;
|
||||
|
||||
fn unban_chat_sender_chat<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
sender_chat_id: i64,
|
||||
) -> Self::UnbanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
Self::UnbanChatSenderChat::new(
|
||||
self.clone(),
|
||||
payloads::UnbanChatSenderChat::new(chat_id, sender_chat_id),
|
||||
)
|
||||
}
|
||||
|
||||
type SetChatPermissions = JsonRequest<payloads::SetChatPermissions>;
|
||||
|
||||
fn set_chat_permissions<C>(
|
||||
|
|
|
@ -739,6 +739,22 @@ macro_rules! requester_forward {
|
|||
$body!(set_chat_administrator_custom_title this (chat_id: Ch, user_id: i64, custom_title: Cu))
|
||||
}
|
||||
};
|
||||
(@method ban_chat_sender_chat $body:ident $ty:ident) => {
|
||||
type BanChatSenderChat = $ty![BanChatSenderChat];
|
||||
|
||||
fn ban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::BanChatSenderChat where C: Into<ChatId> {
|
||||
let this = self;
|
||||
$body!(ban_chat_sender_chat this (chat_id: C, sender_chat_id: i64))
|
||||
}
|
||||
};
|
||||
(@method unban_chat_sender_chat $body:ident $ty:ident) => {
|
||||
type UnbanChatSenderChat = $ty![UnbanChatSenderChat];
|
||||
|
||||
fn unban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::UnbanChatSenderChat where C: Into<ChatId> {
|
||||
let this = self;
|
||||
$body!(unban_chat_sender_chat this (chat_id: C, sender_chat_id: i64))
|
||||
}
|
||||
};
|
||||
(@method set_chat_permissions $body:ident $ty:ident) => {
|
||||
type SetChatPermissions = $ty![SetChatPermissions];
|
||||
|
||||
|
@ -1187,4 +1203,5 @@ macro_rules! requester_forward {
|
|||
$body!(get_updates_fault_tolerant this ())
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ mod answer_pre_checkout_query;
|
|||
mod answer_shipping_query;
|
||||
mod approve_chat_join_request;
|
||||
mod ban_chat_member;
|
||||
mod ban_chat_sender_chat;
|
||||
mod close;
|
||||
mod copy_message;
|
||||
mod create_chat_invite_link;
|
||||
|
@ -106,6 +107,7 @@ mod stop_message_live_location;
|
|||
mod stop_message_live_location_inline;
|
||||
mod stop_poll;
|
||||
mod unban_chat_member;
|
||||
mod unban_chat_sender_chat;
|
||||
mod unpin_all_chat_messages;
|
||||
mod unpin_chat_message;
|
||||
mod upload_sticker_file;
|
||||
|
@ -117,6 +119,7 @@ pub use answer_pre_checkout_query::{AnswerPreCheckoutQuery, AnswerPreCheckoutQue
|
|||
pub use answer_shipping_query::{AnswerShippingQuery, AnswerShippingQuerySetters};
|
||||
pub use approve_chat_join_request::{ApproveChatJoinRequest, ApproveChatJoinRequestSetters};
|
||||
pub use ban_chat_member::{BanChatMember, BanChatMemberSetters};
|
||||
pub use ban_chat_sender_chat::{BanChatSenderChat, BanChatSenderChatSetters};
|
||||
pub use close::{Close, CloseSetters};
|
||||
pub use copy_message::{CopyMessage, CopyMessageSetters};
|
||||
pub use create_chat_invite_link::{CreateChatInviteLink, CreateChatInviteLinkSetters};
|
||||
|
@ -204,6 +207,7 @@ pub use stop_message_live_location_inline::{
|
|||
};
|
||||
pub use stop_poll::{StopPoll, StopPollSetters};
|
||||
pub use unban_chat_member::{UnbanChatMember, UnbanChatMemberSetters};
|
||||
pub use unban_chat_sender_chat::{UnbanChatSenderChat, UnbanChatSenderChatSetters};
|
||||
pub use unpin_all_chat_messages::{UnpinAllChatMessages, UnpinAllChatMessagesSetters};
|
||||
pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters};
|
||||
pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters};
|
||||
|
|
24
src/payloads/ban_chat_sender_chat.rs
Normal file
24
src/payloads/ban_chat_sender_chat.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// This file is auto generated by [`cg`] from [`schema`].
|
||||
//
|
||||
// **DO NOT EDIT THIS FILE**,
|
||||
//
|
||||
// Edit `cg` or `schema` instead.
|
||||
//
|
||||
// [cg]: https://github.com/teloxide/cg
|
||||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to ban a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
|
||||
pub BanChatSenderChat (BanChatSenderChatSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
/// Unique identifier of the target sender chat
|
||||
pub sender_chat_id: i64,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,17 +10,17 @@
|
|||
pub use crate::payloads::{
|
||||
AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _,
|
||||
AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _,
|
||||
ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _, CloseSetters as _,
|
||||
CopyMessageSetters as _, CreateChatInviteLinkSetters as _, CreateNewStickerSetSetters as _,
|
||||
DeclineChatJoinRequestSetters as _, DeleteChatPhotoSetters as _,
|
||||
DeleteChatStickerSetSetters as _, DeleteMessageSetters as _, DeleteMyCommandsSetters as _,
|
||||
DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _, EditChatInviteLinkSetters as _,
|
||||
EditMessageCaptionInlineSetters as _, EditMessageCaptionSetters as _,
|
||||
EditMessageLiveLocationInlineSetters as _, EditMessageLiveLocationSetters as _,
|
||||
EditMessageMediaInlineSetters as _, EditMessageMediaSetters as _,
|
||||
EditMessageReplyMarkupInlineSetters as _, EditMessageReplyMarkupSetters as _,
|
||||
EditMessageTextInlineSetters as _, EditMessageTextSetters as _,
|
||||
ExportChatInviteLinkSetters as _, ForwardMessageSetters as _,
|
||||
ApproveChatJoinRequestSetters as _, BanChatMemberSetters as _, BanChatSenderChatSetters as _,
|
||||
CloseSetters as _, CopyMessageSetters as _, CreateChatInviteLinkSetters as _,
|
||||
CreateNewStickerSetSetters as _, DeclineChatJoinRequestSetters as _,
|
||||
DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _, DeleteMessageSetters as _,
|
||||
DeleteMyCommandsSetters as _, DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _,
|
||||
EditChatInviteLinkSetters as _, EditMessageCaptionInlineSetters as _,
|
||||
EditMessageCaptionSetters as _, EditMessageLiveLocationInlineSetters as _,
|
||||
EditMessageLiveLocationSetters as _, EditMessageMediaInlineSetters as _,
|
||||
EditMessageMediaSetters as _, EditMessageReplyMarkupInlineSetters as _,
|
||||
EditMessageReplyMarkupSetters as _, EditMessageTextInlineSetters as _,
|
||||
EditMessageTextSetters as _, ExportChatInviteLinkSetters as _, ForwardMessageSetters as _,
|
||||
GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _,
|
||||
GetChatMembersCountSetters as _, GetChatSetters as _, GetFileSetters as _,
|
||||
GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
|
||||
|
@ -39,6 +39,6 @@ pub use crate::payloads::{
|
|||
SetMyCommandsSetters as _, SetPassportDataErrorsSetters as _,
|
||||
SetStickerPositionInSetSetters as _, SetStickerSetThumbSetters as _, SetWebhookSetters as _,
|
||||
StopMessageLiveLocationInlineSetters as _, StopMessageLiveLocationSetters as _,
|
||||
StopPollSetters as _, UnbanChatMemberSetters as _, UnpinAllChatMessagesSetters as _,
|
||||
UnpinChatMessageSetters as _, UploadStickerFileSetters as _,
|
||||
StopPollSetters as _, UnbanChatMemberSetters as _, UnbanChatSenderChatSetters as _,
|
||||
UnpinAllChatMessagesSetters as _, UnpinChatMessageSetters as _, UploadStickerFileSetters as _,
|
||||
};
|
||||
|
|
24
src/payloads/unban_chat_sender_chat.rs
Normal file
24
src/payloads/unban_chat_sender_chat.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// This file is auto generated by [`cg`] from [`schema`].
|
||||
//
|
||||
// **DO NOT EDIT THIS FILE**,
|
||||
//
|
||||
// Edit `cg` or `schema` instead.
|
||||
//
|
||||
// [cg]: https://github.com/teloxide/cg
|
||||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
|
||||
pub UnbanChatSenderChat (UnbanChatSenderChatSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
/// Unique identifier of the target sender chat
|
||||
pub sender_chat_id: i64,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -368,6 +368,24 @@ pub trait Requester {
|
|||
Ch: Into<ChatId>,
|
||||
Cu: Into<String>;
|
||||
|
||||
type BanChatSenderChat: Request<Payload = BanChatSenderChat, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`BanChatSenderChat`].
|
||||
fn ban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::BanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
|
||||
type UnbanChatSenderChat: Request<Payload = UnbanChatSenderChat, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`UnbanChatSenderChat`].
|
||||
fn unban_chat_sender_chat<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
sender_chat_id: i64,
|
||||
) -> Self::UnbanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
|
||||
type SetChatPermissions: Request<Payload = SetChatPermissions, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SetChatPermissions`].
|
||||
|
@ -867,7 +885,8 @@ macro_rules! forward_all {
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
@ -963,7 +982,8 @@ where
|
|||
stop_message_live_location, stop_message_live_location_inline, send_venue,
|
||||
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
|
||||
get_file, kick_chat_member, ban_chat_member, unban_chat_member, restrict_chat_member,
|
||||
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
|
||||
promote_chat_member, set_chat_administrator_custom_title,
|
||||
ban_chat_sender_chat, unban_chat_sender_chat, set_chat_permissions,
|
||||
export_chat_invite_link, create_chat_invite_link, edit_chat_invite_link,
|
||||
revoke_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
|
||||
set_chat_description, pin_chat_message, unpin_chat_message, unpin_all_chat_messages,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message};
|
||||
use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message, True};
|
||||
|
||||
/// This object represents a chat.
|
||||
///
|
||||
|
@ -95,6 +95,13 @@ pub struct ChatPrivate {
|
|||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub bio: Option<String>,
|
||||
|
||||
/// `True`, if privacy settings of the other party in the private chat
|
||||
/// allows to use tg://user?id=<user_id> links only in chats with the
|
||||
/// user. Returned only in [`GetChat`].
|
||||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub has_private_forwards: Option<True>,
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
|
@ -407,6 +414,18 @@ impl Chat {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// `True`, if privacy settings of the other party in the private chat
|
||||
/// allows to use tg://user?id=<user_id> links only in chats with the
|
||||
/// user. Returned only in [`GetChat`].
|
||||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub fn has_private_forwards(&self) -> Option<True> {
|
||||
match &self.kind {
|
||||
ChatKind::Private(this) => this.has_private_forwards,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -447,6 +466,7 @@ mod tests {
|
|||
first_name: Some("Anon".into()),
|
||||
last_name: None,
|
||||
bio: None,
|
||||
has_private_forwards: None
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
|
|
|
@ -41,7 +41,13 @@ impl InlineKeyboardButton {
|
|||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum InlineKeyboardButtonKind {
|
||||
/// HTTP or tg:// url to be opened when button is pressed.
|
||||
/// HTTP or `tg://` url to be opened when button is pressed.
|
||||
///
|
||||
/// Links in the form of `tg://user?id=<user_id>` can be used to mention a
|
||||
/// user by their ID without using a username, if this is allowed by
|
||||
/// their privacy settings. This will only work in Telegram versions
|
||||
/// released after December 7, 2021. Older clients will display _unsupported
|
||||
/// message_.
|
||||
Url(reqwest::Url),
|
||||
|
||||
/// An HTTP URL used to automatically authorize the user. Can be used as a
|
||||
|
|
|
@ -89,6 +89,15 @@ pub struct MessageCommon {
|
|||
/// Inline keyboard attached to the message. `login_url` buttons are
|
||||
/// represented as ordinary `url` buttons.
|
||||
pub reply_markup: Option<InlineKeyboardMarkup>,
|
||||
|
||||
/// `true`, if the message is a channel post that was automatically
|
||||
/// forwarded to the connected discussion group.
|
||||
#[serde(default)]
|
||||
pub is_automatic_forward: bool,
|
||||
|
||||
/// `true`, if the message can't be forwarded.
|
||||
#[serde(default)]
|
||||
pub has_protected_content: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -1026,6 +1035,26 @@ mod getters {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_automatic_forward(&self) -> bool {
|
||||
match &self.kind {
|
||||
Common(MessageCommon {
|
||||
is_automatic_forward,
|
||||
..
|
||||
}) => *is_automatic_forward,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_protected_content(&self) -> bool {
|
||||
match &self.kind {
|
||||
Common(MessageCommon {
|
||||
has_protected_content,
|
||||
..
|
||||
}) => *has_protected_content,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ mod test {
|
|||
first_name: Some(String::from("Waffle")),
|
||||
last_name: None,
|
||||
bio: None,
|
||||
has_private_forwards: None,
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
|
@ -218,6 +219,8 @@ mod test {
|
|||
reply_markup: None,
|
||||
sender_chat: None,
|
||||
author_signature: None,
|
||||
is_automatic_forward: false,
|
||||
has_protected_content: false,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue