TBA 5.3: Update methods

This commit is contained in:
Waffle 2021-07-04 15:38:22 +03:00
parent 27f5875b42
commit 120ed97e8c
14 changed files with 199 additions and 31 deletions

View file

@ -89,14 +89,14 @@ where
edit_message_live_location, edit_message_live_location_inline,
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, unban_chat_member, restrict_chat_member,
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,
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,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count,get_chat_member,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, answer_inline_query, edit_message_text,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,

View file

@ -96,14 +96,14 @@ where
edit_message_live_location, edit_message_live_location_inline,
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, unban_chat_member, restrict_chat_member,
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,
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,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count,get_chat_member,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, answer_inline_query, edit_message_text,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
@ -111,7 +111,8 @@ where
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
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, get_updates_fault_tolerant => f, fty
set_game_score, set_game_score_inline, get_game_high_scores,
get_updates_fault_tolerant => f, fty
}
}

View file

@ -107,14 +107,14 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
edit_message_live_location, edit_message_live_location_inline,
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, unban_chat_member, restrict_chat_member,
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,
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,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count,get_chat_member,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, answer_inline_query,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,
get_sticker_set, upload_sticker_file, create_new_sticker_set,

View file

@ -590,15 +590,15 @@ where
get_me, log_out, close, get_updates, set_webhook, delete_webhook, get_webhook_info,
edit_message_live_location, edit_message_live_location_inline,
stop_message_live_location, stop_message_live_location_inline,
send_chat_action, get_user_profile_photos, get_file, kick_chat_member,
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,
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,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count,
get_chat_member, set_chat_sticker_set, delete_chat_sticker_set,
answer_callback_query, set_my_commands, get_my_commands, answer_inline_query,
answer_callback_query, set_my_commands, get_my_commands, delete_my_commands, answer_inline_query,
edit_message_text, edit_message_text_inline, edit_message_caption,
edit_message_caption_inline, edit_message_media, edit_message_media_inline,
edit_message_reply_markup, edit_message_reply_markup_inline, stop_poll,

View file

@ -337,6 +337,15 @@ impl Requester for Bot {
)
}
type BanChatMember = JsonRequest<payloads::BanChatMember>;
fn ban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::BanChatMember
where
C: Into<ChatId>,
{
Self::BanChatMember::new(self.clone(), payloads::BanChatMember::new(chat_id, user_id))
}
type UnbanChatMember = JsonRequest<payloads::UnbanChatMember>;
fn unban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::UnbanChatMember
@ -557,6 +566,15 @@ impl Requester for Bot {
Self::GetChatMembersCount::new(self.clone(), payloads::GetChatMembersCount::new(chat_id))
}
type GetChatMemberCount = JsonRequest<payloads::GetChatMemberCount>;
fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount
where
C: Into<ChatId>,
{
Self::GetChatMemberCount::new(self.clone(), payloads::GetChatMemberCount::new(chat_id))
}
type GetChatMember = JsonRequest<payloads::GetChatMember>;
fn get_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::GetChatMember
@ -615,6 +633,12 @@ impl Requester for Bot {
Self::GetMyCommands::new(self.clone(), payloads::GetMyCommands::new())
}
type DeleteMyCommands = JsonRequest<payloads::DeleteMyCommands>;
fn delete_my_commands(&self) -> Self::DeleteMyCommands {
Self::DeleteMyCommands::new(self.clone(), payloads::DeleteMyCommands::new())
}
type AnswerInlineQuery = JsonRequest<payloads::AnswerInlineQuery>;
fn answer_inline_query<I, R>(&self, inline_query_id: I, results: R) -> Self::AnswerInlineQuery

View file

@ -684,6 +684,14 @@ macro_rules! requester_forward {
$body!(get_file this (file_id: F))
}
};
(@method ban_chat_member $body:ident $ty:ident) => {
type BanChatMember = $ty![BanChatMember];
fn ban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::BanChatMember where C: Into<ChatId> {
let this = self;
$body!(ban_chat_member this (chat_id: C, user_id: i64))
}
};
(@method kick_chat_member $body:ident $ty:ident) => {
type KickChatMember = $ty![KickChatMember];
@ -848,6 +856,14 @@ macro_rules! requester_forward {
$body!(get_chat_administrators this (chat_id: C))
}
};
(@method get_chat_member_count $body:ident $ty:ident) => {
type GetChatMemberCount = $ty![GetChatMemberCount];
fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount where C: Into<ChatId> {
let this = self;
$body!(get_chat_member_count this (chat_id: C))
}
};
(@method get_chat_members_count $body:ident $ty:ident) => {
type GetChatMembersCount = $ty![GetChatMembersCount];
@ -905,6 +921,14 @@ macro_rules! requester_forward {
$body!(get_my_commands this ())
}
};
(@method delete_my_commands $body:ident $ty:ident) => {
type DeleteMyCommands = $ty![DeleteMyCommands];
fn delete_my_commands(&self) -> Self::DeleteMyCommands {
let this = self;
$body!(delete_my_commands this ())
}
};
(@method answer_inline_query $body:ident $ty:ident) => {
type AnswerInlineQuery = $ty![AnswerInlineQuery];

View file

@ -25,6 +25,7 @@ mod answer_callback_query;
mod answer_inline_query;
mod answer_pre_checkout_query;
mod answer_shipping_query;
mod ban_chat_member;
mod close;
mod copy_message;
mod create_chat_invite_link;
@ -32,6 +33,7 @@ mod create_new_sticker_set;
mod delete_chat_photo;
mod delete_chat_sticker_set;
mod delete_message;
mod delete_my_commands;
mod delete_sticker_from_set;
mod delete_webhook;
mod edit_chat_invite_link;
@ -50,6 +52,7 @@ mod forward_message;
mod get_chat;
mod get_chat_administrators;
mod get_chat_member;
mod get_chat_member_count;
mod get_chat_members_count;
mod get_file;
mod get_game_high_scores;
@ -110,6 +113,7 @@ 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 ban_chat_member::{BanChatMember, BanChatMemberSetters};
pub use close::{Close, CloseSetters};
pub use copy_message::{CopyMessage, CopyMessageSetters};
pub use create_chat_invite_link::{CreateChatInviteLink, CreateChatInviteLinkSetters};
@ -117,6 +121,7 @@ pub use create_new_sticker_set::{CreateNewStickerSet, CreateNewStickerSetSetters
pub use delete_chat_photo::{DeleteChatPhoto, DeleteChatPhotoSetters};
pub use delete_chat_sticker_set::{DeleteChatStickerSet, DeleteChatStickerSetSetters};
pub use delete_message::{DeleteMessage, DeleteMessageSetters};
pub use delete_my_commands::{DeleteMyCommands, DeleteMyCommandsSetters};
pub use delete_sticker_from_set::{DeleteStickerFromSet, DeleteStickerFromSetSetters};
pub use delete_webhook::{DeleteWebhook, DeleteWebhookSetters};
pub use edit_chat_invite_link::{EditChatInviteLink, EditChatInviteLinkSetters};
@ -139,6 +144,7 @@ pub use forward_message::{ForwardMessage, ForwardMessageSetters};
pub use get_chat::{GetChat, GetChatSetters};
pub use get_chat_administrators::{GetChatAdministrators, GetChatAdministratorsSetters};
pub use get_chat_member::{GetChatMember, GetChatMemberSetters};
pub use get_chat_member_count::{GetChatMemberCount, GetChatMemberCountSetters};
pub use get_chat_members_count::{GetChatMembersCount, GetChatMembersCountSetters};
pub use get_file::{GetFile, GetFileSetters};
pub use get_game_high_scores::{GetGameHighScores, GetGameHighScoresSetters};

View file

@ -0,0 +1,32 @@
// 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 user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless [unbanned] first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns _True_ on success.
///
/// [unbanned]: crate::payloads::UnbanChatMember
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub BanChatMember (BanChatMemberSetters) => 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,
}
optional {
/// Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
pub until_date: u64,
/// Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.
pub revoke_messages: bool,
}
}
}

View file

@ -0,0 +1,27 @@
// 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::{BotCommandScope, True};
impl_payload! {
/// Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, [higher level commands] will be shown to affected users. Returns _True_ on success.
///
/// [higher level commands]: https://core.telegram.org/bots/api#determining-list-of-commands
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub DeleteMyCommands (DeleteMyCommandsSetters) => True {
optional {
/// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
pub scope: BotCommandScope,
/// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
pub language_code: String [into],
}
}
}

View file

@ -0,0 +1,22 @@
// 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;
impl_payload! {
/// Use this method to get the number of members in a chat. Returns _Int_ on success.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub GetChatMemberCount (GetChatMemberCountSetters) => u32 {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: ChatId [into],
}
}
}

View file

@ -8,7 +8,7 @@
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::BotCommand;
use crate::types::{BotCommand, BotCommandScope};
impl_payload! {
/// Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of [`BotCommand`] on success.
@ -17,5 +17,11 @@ impl_payload! {
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
pub GetMyCommands (GetMyCommandsSetters) => Vec<BotCommand> {
optional {
/// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
pub scope: BotCommandScope,
/// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
pub language_code: String [into],
}
}
}

View file

@ -8,7 +8,7 @@
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
use serde::Serialize;
use crate::types::{BotCommand, True};
use crate::types::{BotCommand, BotCommandScope, True};
impl_payload! {
/// Use this method to change the list of the bot's commands. Returns _True_ on success.
@ -18,5 +18,11 @@ impl_payload! {
/// A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
pub commands: Vec<BotCommand> [collect],
}
optional {
/// A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.
pub scope: BotCommandScope,
/// A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
pub language_code: String [into],
}
}
}

View file

@ -9,25 +9,26 @@
#[doc(no_inline)]
pub use crate::payloads::{
AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _,
AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _, CloseSetters as _,
CopyMessageSetters as _, CreateChatInviteLinkSetters as _, CreateNewStickerSetSetters as _,
DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _, DeleteMessageSetters as _,
DeleteStickerFromSetSetters as _, DeleteWebhookSetters as _, EditChatInviteLinkSetters 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 _,
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 _, GetChatMemberSetters as _, GetChatMembersCountSetters as _,
GetChatSetters as _, GetFileSetters as _, GetGameHighScoresSetters as _, GetMeSetters as _,
GetMyCommandsSetters as _, GetStickerSetSetters as _, GetUpdatesSetters as _,
GetUserProfilePhotosSetters as _, GetWebhookInfoSetters as _, KickChatMemberSetters as _,
LeaveChatSetters as _, LogOutSetters as _, PinChatMessageSetters as _,
PromoteChatMemberSetters as _, RestrictChatMemberSetters as _,
RevokeChatInviteLinkSetters as _, SendAnimationSetters as _, SendAudioSetters as _,
SendChatActionSetters as _, SendContactSetters as _, SendDiceSetters as _,
SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _,
GetChatAdministratorsSetters as _, GetChatMemberCountSetters as _, GetChatMemberSetters as _,
GetChatMembersCountSetters as _, GetChatSetters as _, GetFileSetters as _,
GetGameHighScoresSetters as _, GetMeSetters as _, GetMyCommandsSetters as _,
GetStickerSetSetters as _, GetUpdatesSetters as _, GetUserProfilePhotosSetters as _,
GetWebhookInfoSetters as _, KickChatMemberSetters as _, LeaveChatSetters as _,
LogOutSetters as _, PinChatMessageSetters as _, PromoteChatMemberSetters as _,
RestrictChatMemberSetters as _, RevokeChatInviteLinkSetters as _, SendAnimationSetters as _,
SendAudioSetters as _, SendChatActionSetters as _, SendContactSetters as _,
SendDiceSetters as _, SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters as _,
SendLocationSetters as _, SendMediaGroupSetters as _, SendMessageSetters as _,
SendPhotoSetters as _, SendPollSetters as _, SendStickerSetters as _, SendVenueSetters as _,
SendVideoNoteSetters as _, SendVideoSetters as _, SendVoiceSetters as _,

View file

@ -318,6 +318,13 @@ pub trait Requester {
where
F: Into<String>;
type BanChatMember: Request<Payload = BanChatMember, Err = Self::Err>;
/// For Telegram documentation see [`BanChatMember`].
fn ban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::BanChatMember
where
C: Into<ChatId>;
type KickChatMember: Request<Payload = KickChatMember, Err = Self::Err>;
/// For Telegram documentation see [`KickChatMember`].
@ -483,6 +490,13 @@ pub trait Requester {
where
C: Into<ChatId>;
type GetChatMemberCount: Request<Payload = GetChatMemberCount, Err = Self::Err>;
/// For Telegram documentation see [`GetChatMemberCount`].
fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount
where
C: Into<ChatId>;
type GetChatMembersCount: Request<Payload = GetChatMembersCount, Err = Self::Err>;
/// For Telegram documentation see [`GetChatMembersCount`].
@ -535,6 +549,11 @@ pub trait Requester {
/// For Telegram documentation see [`GetMyCommands`].
fn get_my_commands(&self) -> Self::GetMyCommands;
type DeleteMyCommands: Request<Payload = DeleteMyCommands, Err = Self::Err>;
/// For Telegram documentation see [`DeleteMyCommands`].
fn delete_my_commands(&self) -> Self::DeleteMyCommands;
type AnswerInlineQuery: Request<Payload = AnswerInlineQuery, Err = Self::Err>;
/// For Telegram documentation see [`AnswerInlineQuery`].
@ -831,14 +850,14 @@ macro_rules! forward_all {
edit_message_live_location, edit_message_live_location_inline,
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, unban_chat_member, restrict_chat_member,
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,
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,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count,get_chat_member,
leave_chat, get_chat, get_chat_administrators, get_chat_members_count, get_chat_member_count, get_chat_member,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,
set_my_commands, get_my_commands, answer_inline_query, edit_message_text,
set_my_commands, get_my_commands, delete_my_commands, answer_inline_query, edit_message_text,
edit_message_text_inline, edit_message_caption, edit_message_caption_inline,
edit_message_media, edit_message_media_inline, edit_message_reply_markup,
edit_message_reply_markup_inline, stop_poll, delete_message, send_sticker,