Add TBA v5.4 methods and params

(schema update)
This commit is contained in:
Maybe Waffle 2021-11-06 14:32:16 +03:00
parent 9fb6c20f23
commit 094211e6a1
16 changed files with 173 additions and 7 deletions

View file

@ -105,6 +105,7 @@ where
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => f, fty
}
}

View file

@ -112,6 +112,7 @@ where
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => f, fty
}
}

View file

@ -181,6 +181,7 @@ where
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => fwd_erased, fty
}
}
@ -413,6 +414,20 @@ trait ErasableRequester<'a> {
invite_link: String,
) -> ErasedRequest<'a, RevokeChatInviteLink, Self::Err>;
/// For Telegram documentation see [`ApproveChatJoinRequest`].
fn approve_chat_join_request(
&self,
chat_id: ChatId,
user_id: i64,
) -> ErasedRequest<'a, ApproveChatJoinRequest, Self::Err>;
/// For Telegram documentation see [`DeclineChatJoinRequest`].
fn decline_chat_join_request(
&self,
chat_id: ChatId,
user_id: i64,
) -> ErasedRequest<'a, DeclineChatJoinRequest, Self::Err>;
fn set_chat_photo(
&self,
chat_id: ChatId,
@ -983,6 +998,24 @@ where
Requester::revoke_chat_invite_link(self, chat_id, invite_link).erase()
}
/// For Telegram documentation see [`ApproveChatJoinRequest`].
fn approve_chat_join_request(
&self,
chat_id: ChatId,
user_id: i64,
) -> ErasedRequest<'a, ApproveChatJoinRequest, Self::Err> {
Requester::approve_chat_join_request(self, chat_id, user_id).erase()
}
/// For Telegram documentation see [`DeclineChatJoinRequest`].
fn decline_chat_join_request(
&self,
chat_id: ChatId,
user_id: i64,
) -> ErasedRequest<'a, DeclineChatJoinRequest, Self::Err> {
Requester::decline_chat_join_request(self, chat_id, user_id).erase()
}
fn set_chat_photo(
&self,
chat_id: ChatId,

View file

@ -116,6 +116,7 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => fid, fty
}
}

View file

@ -619,6 +619,7 @@ where
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, answer_shipping_query, answer_pre_checkout_query,
set_passport_data_errors, send_game, set_game_score, set_game_score_inline,
approve_chat_join_request, decline_chat_join_request,
get_game_high_scores, get_updates_fault_tolerant => fid, ftyid
}
}

View file

@ -137,6 +137,7 @@ where
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => fwd_inner, fty
}
}

View file

@ -463,6 +463,32 @@ impl Requester for Bot {
)
}
type ApproveChatJoinRequest = JsonRequest<payloads::ApproveChatJoinRequest>;
/// For Telegram documentation see [`ApproveChatJoinRequest`].
fn approve_chat_join_request<C>(&self, chat_id: C, user_id: i64) -> Self::ApproveChatJoinRequest
where
C: Into<ChatId>,
{
Self::ApproveChatJoinRequest::new(
self.clone(),
payloads::ApproveChatJoinRequest::new(chat_id, user_id),
)
}
type DeclineChatJoinRequest = JsonRequest<payloads::DeclineChatJoinRequest>;
/// For Telegram documentation see [`DeclineChatJoinRequest`].
fn decline_chat_join_request<C>(&self, chat_id: C, user_id: i64) -> Self::DeclineChatJoinRequest
where
C: Into<ChatId>,
{
Self::DeclineChatJoinRequest::new(
self.clone(),
payloads::DeclineChatJoinRequest::new(chat_id, user_id),
)
}
type SetChatPhoto = MultipartRequest<payloads::SetChatPhoto>;
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto

View file

@ -781,6 +781,22 @@ macro_rules! requester_forward {
$body!(revoke_chat_invite_link this (chat_id: C, invite_link: I))
}
};
(@method approve_chat_join_request $body:ident $ty:ident) => {
type ApproveChatJoinRequest = $ty![ApproveChatJoinRequest];
fn approve_chat_join_request<C>(&self, chat_id: C, user_id: i64) -> Self::ApproveChatJoinRequest where C: Into<ChatId> {
let this = self;
$body!(approve_chat_join_request this (chat_id: C, user_id: i64))
}
};
(@method decline_chat_join_request $body:ident $ty:ident) => {
type DeclineChatJoinRequest = $ty![DeclineChatJoinRequest];
fn decline_chat_join_request<C>(&self, chat_id: C, user_id: i64) -> Self::DeclineChatJoinRequest where C: Into<ChatId> {
let this = self;
$body!(decline_chat_join_request this (chat_id: C, user_id: i64))
}
};
(@method set_chat_photo $body:ident $ty:ident) => {
type SetChatPhoto = $ty![SetChatPhoto];

View file

@ -25,11 +25,13 @@ mod answer_callback_query;
mod answer_inline_query;
mod answer_pre_checkout_query;
mod answer_shipping_query;
mod approve_chat_join_request;
mod ban_chat_member;
mod close;
mod copy_message;
mod create_chat_invite_link;
mod create_new_sticker_set;
mod decline_chat_join_request;
mod delete_chat_photo;
mod delete_chat_sticker_set;
mod delete_message;
@ -113,11 +115,13 @@ pub use answer_callback_query::{AnswerCallbackQuery, AnswerCallbackQuerySetters}
pub use answer_inline_query::{AnswerInlineQuery, AnswerInlineQuerySetters};
pub use answer_pre_checkout_query::{AnswerPreCheckoutQuery, AnswerPreCheckoutQuerySetters};
pub use answer_shipping_query::{AnswerShippingQuery, AnswerShippingQuerySetters};
pub use approve_chat_join_request::{ApproveChatJoinRequest, ApproveChatJoinRequestSetters};
pub use ban_chat_member::{BanChatMember, BanChatMemberSetters};
pub use close::{Close, CloseSetters};
pub use copy_message::{CopyMessage, CopyMessageSetters};
pub use create_chat_invite_link::{CreateChatInviteLink, CreateChatInviteLinkSetters};
pub use create_new_sticker_set::{CreateNewStickerSet, CreateNewStickerSetSetters};
pub use decline_chat_join_request::{DeclineChatJoinRequest, DeclineChatJoinRequestSetters};
pub use delete_chat_photo::{DeleteChatPhoto, DeleteChatPhotoSetters};
pub use delete_chat_sticker_set::{DeleteChatStickerSet, DeleteChatStickerSetSetters};
pub use delete_message::{DeleteMessage, DeleteMessageSetters};

View 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 approve a chat join request. The bot must be an administrator in the chat for this to work and must have the _can_invite_users_ administrator right. Returns _True_ on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub ApproveChatJoinRequest (ApproveChatJoinRequestSetters) => 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 user
pub user_id: i64,
}
}
}

View file

@ -23,11 +23,15 @@ impl_payload! {
pub chat_id: ChatId [into],
}
optional {
/// Invite link name; 0-32 characters
pub name: String [into],
/// Point in time (Unix timestamp) when the link will expire
#[serde(with = "crate::types::serde_opt_date_from_unix_timestamp")]
pub expire_date: DateTime<Utc> [into],
/// Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
pub member_limit: u32,
/// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
pub creates_join_request: bool,
}
}
}

View 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 decline a chat join request. The bot must be an administrator in the chat for this to work and must have the _can_invite_users_ administrator right. Returns _True_ on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub DeclineChatJoinRequest (DeclineChatJoinRequestSetters) => 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 user
pub user_id: i64,
}
}
}

View file

@ -24,11 +24,15 @@ impl_payload! {
pub invite_link: String [into],
}
optional {
/// Invite link name; 0-32 characters
pub name: String [into],
/// Point in time (Unix timestamp) when the link will expire
#[serde(with = "crate::types::serde_opt_date_from_unix_timestamp")]
pub expire_date: DateTime<Utc> [into],
/// Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
pub member_limit: u32,
/// True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
pub creates_join_request: bool,
}
}
}

View file

@ -23,15 +23,16 @@ impl_payload! {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: ChatId [into],
/// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for [text messages], upload_photo for [photos], record_video or upload_video for [videos], record_audio or upload_audio for [audio files], upload_document for [general files], find_location for [location data], record_video_note or upload_video_note for [video notes].
/// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for [text messages], upload_photo for [photos], record_video or upload_video for [videos], record_audio or upload_audio for [audio files], upload_document for [general files], choose_sticker for [`Stickers`], find_location for [location data], record_video_note or upload_video_note for [video notes].
///
/// [text messages]: crate::payloads::SendMessage
/// [photos]: crate::payloads::SendPhoto
/// [videos]: crate::payloads::SendVideo
/// [audio files]: crate::payloads::SendAudio
/// [general files]: crate::payloads::SendDocument
/// [location data]: crate::payloads::SendLocation
/// [video notes]: crate::payloads::SendVideoNote
/// [location data]: crate::payloads::SendLocation
/// [`Stickers`]: crate::payloads::Stickers
pub action: ChatAction,
}
}

View file

@ -9,11 +9,12 @@
#[doc(no_inline)]
pub use crate::payloads::{
AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _,
AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _, BanChatMemberSetters as _,
CloseSetters as _, CopyMessageSetters as _, CreateChatInviteLinkSetters as _,
CreateNewStickerSetSetters as _, DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _,
DeleteMessageSetters as _, DeleteMyCommandsSetters as _, DeleteStickerFromSetSetters as _,
DeleteWebhookSetters as _, EditChatInviteLinkSetters 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 _,

View file

@ -413,6 +413,28 @@ pub trait Requester {
C: Into<ChatId>,
I: Into<String>;
type ApproveChatJoinRequest: Request<Payload = ApproveChatJoinRequest, Err = Self::Err>;
/// For Telegram documentation see [`ApproveChatJoinRequest`].
fn approve_chat_join_request<C>(
&self,
chat_id: C,
user_id: i64,
) -> Self::ApproveChatJoinRequest
where
C: Into<ChatId>;
type DeclineChatJoinRequest: Request<Payload = DeclineChatJoinRequest, Err = Self::Err>;
/// For Telegram documentation see [`DeclineChatJoinRequest`].
fn decline_chat_join_request<C>(
&self,
chat_id: C,
user_id: i64,
) -> Self::DeclineChatJoinRequest
where
C: Into<ChatId>;
type SetChatPhoto: Request<Payload = SetChatPhoto, Err = Self::Err>;
/// For Telegram documentation see [`SetChatPhoto`].
@ -860,6 +882,7 @@ macro_rules! forward_all {
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => fwd_deref, fty
}
};
@ -955,6 +978,7 @@ where
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores,
approve_chat_join_request, decline_chat_join_request,
get_updates_fault_tolerant => fwd_either, fty_either
}
}