Merge pull request #63 from teloxide/apiup

Update API to version 5.1
This commit is contained in:
Waffle Lapkin 2021-03-16 14:09:57 +03:00 committed by GitHub
commit df30d92b6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 482 additions and 116 deletions

View file

@ -56,7 +56,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: beta #nightly
toolchain: nightly
override: true
components: clippy
@ -64,8 +64,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --features full -- -D warnings
#args: --all-targets --all-features -- -D warnings
args: --all-targets --all-features -- -D warnings
style:
runs-on: ubuntu-latest

View file

@ -9,9 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Support telegram bot API version 5.1 (see it's [changelog](https://core.telegram.org/bots/api#march-9-2021)) ([#pr63][pr63]) (**BC**)
- Support telegram bot API version 5.0 (see it's [changelog](https://core.telegram.org/bots/api#november-4-2020)) ([#pr62][pr62]) (**BC**)
[pr62]: https://github.com/teloxide/teloxide-core/pull/62
[pr63]: https://github.com/teloxide/teloxide-core/pull/63
### Added

View file

@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
</a>
<a href="https://core.telegram.org/bots/api">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%200.5.0%20(inclusively)-green.svg">
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%200.5.1%20(inclusively)-green.svg">
</a>
<a href="https://crates.io/crates/teloxide_core">
<img src="https://img.shields.io/crates/v/teloxide_core.svg">

View file

@ -90,7 +90,8 @@ where
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
export_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
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,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,

View file

@ -96,7 +96,8 @@ where
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
export_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
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,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,

View file

@ -101,7 +101,8 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
send_contact, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
export_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
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,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,

View file

@ -458,7 +458,8 @@ where
send_chat_action, get_user_profile_photos, get_file, kick_chat_member,
unban_chat_member, restrict_chat_member, promote_chat_member,
set_chat_administrator_custom_title, set_chat_permissions,
export_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
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, set_chat_sticker_set, delete_chat_sticker_set,

View file

@ -313,7 +313,7 @@ impl Requester for Bot {
type GetUserProfilePhotos = JsonRequest<payloads::GetUserProfilePhotos>;
fn get_user_profile_photos(&self, user_id: i32) -> Self::GetUserProfilePhotos {
fn get_user_profile_photos(&self, user_id: i64) -> Self::GetUserProfilePhotos {
Self::GetUserProfilePhotos::new(self.clone(), payloads::GetUserProfilePhotos::new(user_id))
}
@ -328,7 +328,7 @@ impl Requester for Bot {
type KickChatMember = JsonRequest<payloads::KickChatMember>;
fn kick_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::KickChatMember
fn kick_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::KickChatMember
where
C: Into<ChatId>,
{
@ -340,7 +340,7 @@ impl Requester for Bot {
type UnbanChatMember = JsonRequest<payloads::UnbanChatMember>;
fn unban_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::UnbanChatMember
fn unban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::UnbanChatMember
where
C: Into<ChatId>,
{
@ -355,7 +355,7 @@ impl Requester for Bot {
fn restrict_chat_member<C>(
&self,
chat_id: C,
user_id: i32,
user_id: i64,
permissions: ChatPermissions,
) -> Self::RestrictChatMember
where
@ -369,7 +369,7 @@ impl Requester for Bot {
type PromoteChatMember = JsonRequest<payloads::PromoteChatMember>;
fn promote_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::PromoteChatMember
fn promote_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::PromoteChatMember
where
C: Into<ChatId>,
{
@ -384,7 +384,7 @@ impl Requester for Bot {
fn set_chat_administrator_custom_title<Ch, Cu>(
&self,
chat_id: Ch,
user_id: i32,
user_id: i64,
custom_title: Cu,
) -> Self::SetChatAdministratorCustomTitle
where
@ -422,6 +422,45 @@ impl Requester for Bot {
Self::ExportChatInviteLink::new(self.clone(), payloads::ExportChatInviteLink::new(chat_id))
}
type CreateChatInviteLink = JsonRequest<payloads::CreateChatInviteLink>;
fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink
where
C: Into<ChatId>,
{
Self::CreateChatInviteLink::new(self.clone(), payloads::CreateChatInviteLink::new(chat_id))
}
type EditChatInviteLink = JsonRequest<payloads::EditChatInviteLink>;
fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink
where
C: Into<ChatId>,
I: Into<String>,
{
Self::EditChatInviteLink::new(
self.clone(),
payloads::EditChatInviteLink::new(chat_id, invite_link),
)
}
type RevokeChatInviteLink = JsonRequest<payloads::RevokeChatInviteLink>;
fn revoke_chat_invite_link<C, I>(
&self,
chat_id: C,
invite_link: I,
) -> Self::RevokeChatInviteLink
where
C: Into<ChatId>,
I: Into<String>,
{
Self::RevokeChatInviteLink::new(
self.clone(),
payloads::RevokeChatInviteLink::new(chat_id, invite_link),
)
}
type SetChatPhoto = MultipartRequest<payloads::SetChatPhoto>;
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
@ -521,7 +560,7 @@ impl Requester for Bot {
type GetChatMember = JsonRequest<payloads::GetChatMember>;
fn get_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::GetChatMember
fn get_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::GetChatMember
where
C: Into<ChatId>,
{
@ -749,7 +788,7 @@ impl Requester for Bot {
type UploadStickerFile = MultipartRequest<payloads::UploadStickerFile>;
fn upload_sticker_file(&self, user_id: i32, png_sticker: InputFile) -> Self::UploadStickerFile where
fn upload_sticker_file(&self, user_id: i64, png_sticker: InputFile) -> Self::UploadStickerFile where
{
Self::UploadStickerFile::new(
self.clone(),
@ -761,7 +800,7 @@ impl Requester for Bot {
fn create_new_sticker_set<N, T, E>(
&self,
user_id: i32,
user_id: i64,
name: N,
title: T,
sticker: InputSticker,
@ -782,7 +821,7 @@ impl Requester for Bot {
fn add_sticker_to_set<N, E>(
&self,
user_id: i32,
user_id: i64,
name: N,
sticker: InputSticker,
emojis: E,
@ -824,7 +863,7 @@ impl Requester for Bot {
type SetStickerSetThumb = MultipartRequest<payloads::SetStickerSetThumb>;
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i32) -> Self::SetStickerSetThumb
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i64) -> Self::SetStickerSetThumb
where
N: Into<String>,
{
@ -901,7 +940,7 @@ impl Requester for Bot {
type SetPassportDataErrors = JsonRequest<payloads::SetPassportDataErrors>;
fn set_passport_data_errors<E>(&self, user_id: i32, errors: E) -> Self::SetPassportDataErrors
fn set_passport_data_errors<E>(&self, user_id: i64, errors: E) -> Self::SetPassportDataErrors
where
E: IntoIterator<Item = crate::types::PassportElementError>,
{
@ -927,7 +966,7 @@ impl Requester for Bot {
fn set_game_score(
&self,
user_id: u32,
user_id: i64,
score: u64,
chat_id: u32,
message_id: i64,
@ -942,7 +981,7 @@ impl Requester for Bot {
fn set_game_score_inline<I>(
&self,
user_id: u32,
user_id: i64,
score: u64,
inline_message_id: I,
) -> Self::SetGameScoreInline
@ -957,7 +996,7 @@ impl Requester for Bot {
type GetGameHighScores = JsonRequest<payloads::GetGameHighScores>;
fn get_game_high_scores<T>(&self, user_id: u32, target: T) -> Self::GetGameHighScores
fn get_game_high_scores<T>(&self, user_id: i64, target: T) -> Self::GetGameHighScores
where
T: Into<crate::types::TargetMessage>,
{

View file

@ -1,7 +1,7 @@
//! Core part of the [`teloxide`] library.
//!
//! This library provides tools for making requests to the [Telegram Bot API]
//! (Currently, version `5.0` is supported) with ease. The library is fully
//! (Currently, version `5.` is supported) with ease. The library is fully
//! asynchronouns and built using [`tokio`].
//!
//!```toml
@ -74,7 +74,7 @@
// ```
#![cfg_attr(all(docsrs, feature = "nightly"), feature(doc_cfg, doc_spotlight))]
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
#![cfg_attr(feature = "full", deny(broken_intra_doc_links))]
#![cfg_attr(all(feature = "full", docsrs), deny(rustdoc::broken_intra_doc_links))]
//#![deny(missing_docs)]
// The internal helper macros.

View file

@ -640,9 +640,9 @@ macro_rules! requester_forward {
(@method get_user_profile_photos $body:ident $ty:ident) => {
type GetUserProfilePhotos = $ty![GetUserProfilePhotos];
fn get_user_profile_photos(&self, user_id: i32) -> Self::GetUserProfilePhotos {
fn get_user_profile_photos(&self, user_id: i64) -> Self::GetUserProfilePhotos {
let this = self;
$body!(get_user_profile_photos this (user_id: i32))
$body!(get_user_profile_photos this (user_id: i64))
}
};
(@method get_file $body:ident $ty:ident) => {
@ -656,42 +656,42 @@ macro_rules! requester_forward {
(@method kick_chat_member $body:ident $ty:ident) => {
type KickChatMember = $ty![KickChatMember];
fn kick_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::KickChatMember where C: Into<ChatId> {
fn kick_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::KickChatMember where C: Into<ChatId> {
let this = self;
$body!(kick_chat_member this (chat_id: C, user_id: i32))
$body!(kick_chat_member this (chat_id: C, user_id: i64))
}
};
(@method unban_chat_member $body:ident $ty:ident) => {
type UnbanChatMember = $ty![UnbanChatMember];
fn unban_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::UnbanChatMember where C: Into<ChatId> {
fn unban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::UnbanChatMember where C: Into<ChatId> {
let this = self;
$body!(unban_chat_member this (chat_id: C, user_id: i32))
$body!(unban_chat_member this (chat_id: C, user_id: i64))
}
};
(@method restrict_chat_member $body:ident $ty:ident) => {
type RestrictChatMember = $ty![RestrictChatMember];
fn restrict_chat_member<C>(&self, chat_id: C, user_id: i32, permissions: ChatPermissions) -> Self::RestrictChatMember where C: Into<ChatId> {
fn restrict_chat_member<C>(&self, chat_id: C, user_id: i64, permissions: ChatPermissions) -> Self::RestrictChatMember where C: Into<ChatId> {
let this = self;
$body!(restrict_chat_member this (chat_id: C, user_id: i32, permissions: ChatPermissions))
$body!(restrict_chat_member this (chat_id: C, user_id: i64, permissions: ChatPermissions))
}
};
(@method promote_chat_member $body:ident $ty:ident) => {
type PromoteChatMember = $ty![PromoteChatMember];
fn promote_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::PromoteChatMember where C: Into<ChatId> {
fn promote_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::PromoteChatMember where C: Into<ChatId> {
let this = self;
$body!(promote_chat_member this (chat_id: C, user_id: i32))
$body!(promote_chat_member this (chat_id: C, user_id: i64))
}
};
(@method set_chat_administrator_custom_title $body:ident $ty:ident) => {
type SetChatAdministratorCustomTitle = $ty![SetChatAdministratorCustomTitle];
fn set_chat_administrator_custom_title<Ch, Cu>(&self, chat_id: Ch, user_id: i32, custom_title: Cu) -> Self::SetChatAdministratorCustomTitle where Ch: Into<ChatId>,
fn set_chat_administrator_custom_title<Ch, Cu>(&self, chat_id: Ch, user_id: i64, custom_title: Cu) -> Self::SetChatAdministratorCustomTitle where Ch: Into<ChatId>,
Cu: Into<String> {
let this = self;
$body!(set_chat_administrator_custom_title this (chat_id: Ch, user_id: i32, custom_title: Cu))
$body!(set_chat_administrator_custom_title this (chat_id: Ch, user_id: i64, custom_title: Cu))
}
};
(@method set_chat_permissions $body:ident $ty:ident) => {
@ -710,6 +710,32 @@ macro_rules! requester_forward {
$body!(export_chat_invite_link this (chat_id: C))
}
};
(@method create_chat_invite_link $body:ident $ty:ident) => {
type CreateChatInviteLink = $ty![CreateChatInviteLink];
fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink where C: Into<ChatId> {
let this = self;
$body!(create_chat_invite_link this (chat_id: C))
}
};
(@method edit_chat_invite_link $body:ident $ty:ident) => {
type EditChatInviteLink = $ty![EditChatInviteLink];
fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink where C: Into<ChatId>,
I: Into<String> {
let this = self;
$body!(edit_chat_invite_link this (chat_id: C, invite_link: I))
}
};
(@method revoke_chat_invite_link $body:ident $ty:ident) => {
type RevokeChatInviteLink = $ty![RevokeChatInviteLink];
fn revoke_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::RevokeChatInviteLink where C: Into<ChatId>,
I: Into<String> {
let this = self;
$body!(revoke_chat_invite_link this (chat_id: C, invite_link: I))
}
};
(@method set_chat_photo $body:ident $ty:ident) => {
type SetChatPhoto = $ty![SetChatPhoto];
@ -802,9 +828,9 @@ macro_rules! requester_forward {
(@method get_chat_member $body:ident $ty:ident) => {
type GetChatMember = $ty![GetChatMember];
fn get_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::GetChatMember where C: Into<ChatId> {
fn get_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::GetChatMember where C: Into<ChatId> {
let this = self;
$body!(get_chat_member this (chat_id: C, user_id: i32))
$body!(get_chat_member this (chat_id: C, user_id: i64))
}
};
(@method set_chat_sticker_set $body:ident $ty:ident) => {
@ -958,28 +984,28 @@ macro_rules! requester_forward {
(@method upload_sticker_file $body:ident $ty:ident) => {
type UploadStickerFile = $ty![UploadStickerFile];
fn upload_sticker_file(&self, user_id: i32, png_sticker: InputFile) -> Self::UploadStickerFile {
fn upload_sticker_file(&self, user_id: i64, png_sticker: InputFile) -> Self::UploadStickerFile {
let this = self;
$body!(upload_sticker_file this (user_id: i32, png_sticker: InputFile))
$body!(upload_sticker_file this (user_id: i64, png_sticker: InputFile))
}
};
(@method create_new_sticker_set $body:ident $ty:ident) => {
type CreateNewStickerSet = $ty![CreateNewStickerSet];
fn create_new_sticker_set<N, T, E>(&self, user_id: i32, name: N, title: T, sticker: InputSticker, emojis: E) -> Self::CreateNewStickerSet where N: Into<String>,
fn create_new_sticker_set<N, T, E>(&self, user_id: i64, name: N, title: T, sticker: InputSticker, emojis: E) -> Self::CreateNewStickerSet where N: Into<String>,
T: Into<String>,
E: Into<String> {
let this = self;
$body!(create_new_sticker_set this (user_id: i32, name: N, title: T, sticker: InputSticker, emojis: E))
$body!(create_new_sticker_set this (user_id: i64, name: N, title: T, sticker: InputSticker, emojis: E))
}
};
(@method add_sticker_to_set $body:ident $ty:ident) => {
type AddStickerToSet = $ty![AddStickerToSet];
fn add_sticker_to_set<N, E>(&self, user_id: i32, name: N, sticker: InputSticker, emojis: E) -> Self::AddStickerToSet where N: Into<String>,
fn add_sticker_to_set<N, E>(&self, user_id: i64, name: N, sticker: InputSticker, emojis: E) -> Self::AddStickerToSet where N: Into<String>,
E: Into<String> {
let this = self;
$body!(add_sticker_to_set this (user_id: i32, name: N, sticker: InputSticker, emojis: E))
$body!(add_sticker_to_set this (user_id: i64, name: N, sticker: InputSticker, emojis: E))
}
};
(@method set_sticker_position_in_set $body:ident $ty:ident) => {
@ -1001,9 +1027,9 @@ macro_rules! requester_forward {
(@method set_sticker_set_thumb $body:ident $ty:ident) => {
type SetStickerSetThumb = $ty![SetStickerSetThumb];
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i32) -> Self::SetStickerSetThumb where N: Into<String> {
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i64) -> Self::SetStickerSetThumb where N: Into<String> {
let this = self;
$body!(set_sticker_set_thumb this (name: N, user_id: i32))
$body!(set_sticker_set_thumb this (name: N, user_id: i64))
}
};
(@method send_invoice $body:ident $ty:ident) => {
@ -1039,9 +1065,9 @@ macro_rules! requester_forward {
(@method set_passport_data_errors $body:ident $ty:ident) => {
type SetPassportDataErrors = $ty![SetPassportDataErrors];
fn set_passport_data_errors<E>(&self, user_id: i32, errors: E) -> Self::SetPassportDataErrors where E: IntoIterator<Item = PassportElementError> {
fn set_passport_data_errors<E>(&self, user_id: i64, errors: E) -> Self::SetPassportDataErrors where E: IntoIterator<Item = PassportElementError> {
let this = self;
$body!(set_passport_data_errors this (user_id: i32, errors: E))
$body!(set_passport_data_errors this (user_id: i64, errors: E))
}
};
(@method send_game $body:ident $ty:ident) => {
@ -1055,25 +1081,25 @@ macro_rules! requester_forward {
(@method set_game_score $body:ident $ty:ident) => {
type SetGameScore = $ty![SetGameScore];
fn set_game_score(&self, user_id: u32, score: u64, chat_id: u32, message_id: i64) -> Self::SetGameScore {
fn set_game_score(&self, user_id: i64, score: u64, chat_id: u32, message_id: i64) -> Self::SetGameScore {
let this = self;
$body!(set_game_score this (user_id: u32, score: u64, chat_id: u32, message_id: i64))
$body!(set_game_score this (user_id: i64, score: u64, chat_id: u32, message_id: i64))
}
};
(@method set_game_score_inline $body:ident $ty:ident) => {
type SetGameScoreInline = $ty![SetGameScoreInline];
fn set_game_score_inline<I>(&self, user_id: u32, score: u64, inline_message_id: I) -> Self::SetGameScoreInline where I: Into<String> {
fn set_game_score_inline<I>(&self, user_id: i64, score: u64, inline_message_id: I) -> Self::SetGameScoreInline where I: Into<String> {
let this = self;
$body!(set_game_score_inline this (user_id: u32, score: u64, inline_message_id: I))
$body!(set_game_score_inline this (user_id: i64, score: u64, inline_message_id: I))
}
};
(@method get_game_high_scores $body:ident $ty:ident) => {
type GetGameHighScores = $ty![GetGameHighScores];
fn get_game_high_scores<T>(&self, user_id: u32, target: T) -> Self::GetGameHighScores where T: Into<TargetMessage> {
fn get_game_high_scores<T>(&self, user_id: i64, target: T) -> Self::GetGameHighScores where T: Into<TargetMessage> {
let this = self;
$body!(get_game_high_scores this (user_id: u32, target: T))
$body!(get_game_high_scores this (user_id: i64, target: T))
}
};
(@method get_updates_fault_tolerant $body:ident $ty:ident) => {

View file

@ -22,12 +22,14 @@ mod answer_pre_checkout_query;
mod answer_shipping_query;
mod close;
mod copy_message;
mod create_chat_invite_link;
mod create_new_sticker_set;
mod delete_chat_photo;
mod delete_chat_sticker_set;
mod delete_message;
mod delete_sticker_from_set;
mod delete_webhook;
mod edit_chat_invite_link;
mod edit_message_caption;
mod edit_message_caption_inline;
mod edit_message_live_location;
@ -58,6 +60,7 @@ mod log_out;
mod pin_chat_message;
mod promote_chat_member;
mod restrict_chat_member;
mod revoke_chat_invite_link;
mod send_animation;
mod send_audio;
mod send_chat_action;
@ -104,12 +107,14 @@ pub use answer_pre_checkout_query::{AnswerPreCheckoutQuery, AnswerPreCheckoutQue
pub use answer_shipping_query::{AnswerShippingQuery, AnswerShippingQuerySetters};
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 delete_chat_photo::{DeleteChatPhoto, DeleteChatPhotoSetters};
pub use delete_chat_sticker_set::{DeleteChatStickerSet, DeleteChatStickerSetSetters};
pub use delete_message::{DeleteMessage, DeleteMessageSetters};
pub use delete_sticker_from_set::{DeleteStickerFromSet, DeleteStickerFromSetSetters};
pub use delete_webhook::{DeleteWebhook, DeleteWebhookSetters};
pub use edit_chat_invite_link::{EditChatInviteLink, EditChatInviteLinkSetters};
pub use edit_message_caption::{EditMessageCaption, EditMessageCaptionSetters};
pub use edit_message_caption_inline::{EditMessageCaptionInline, EditMessageCaptionInlineSetters};
pub use edit_message_live_location::{EditMessageLiveLocation, EditMessageLiveLocationSetters};
@ -144,6 +149,7 @@ pub use log_out::{LogOut, LogOutSetters};
pub use pin_chat_message::{PinChatMessage, PinChatMessageSetters};
pub use promote_chat_member::{PromoteChatMember, PromoteChatMemberSetters};
pub use restrict_chat_member::{RestrictChatMember, RestrictChatMemberSetters};
pub use revoke_chat_invite_link::{RevokeChatInviteLink, RevokeChatInviteLinkSetters};
pub use send_animation::{SendAnimation, SendAnimationSetters};
pub use send_audio::{SendAudio, SendAudioSetters};
pub use send_chat_action::{SendChatAction, SendChatActionSetters};

View file

@ -12,7 +12,7 @@ impl_payload! {
pub AddStickerToSet (AddStickerToSetSetters) => True {
required {
/// User identifier of sticker file owner
pub user_id: i32,
pub user_id: i64,
/// Sticker set name
pub name: String [into],
/// **PNG** or **TGS** image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a _file\_id_ as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. [More info on Sending Files »]

View file

@ -0,0 +1,26 @@
// This file is auto generated by `cg` <https://github.com/teloxide/cg> (24572cd + local changes).
// **DO NOT EDIT THIS FILE**,
// edit `cg` instead.
use serde::Serialize;
use crate::types::{ChatId, ChatInviteLink};
impl_payload! {
/// Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the method [`RevokeChatInviteLink`]. Returns the new invite link as [`ChatInviteLink`] object.
///
/// [`ChatInviteLink`]: crate::types::ChatInviteLink
/// [`RevokeChatInviteLink`]: crate::payloads::RevokeChatInviteLink
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub CreateChatInviteLink (CreateChatInviteLinkSetters) => ChatInviteLink {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: ChatId [into],
}
optional {
/// Point in time (Unix timestamp) when the link will expire
pub expire_date: i64,
/// 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,
}
}
}

View file

@ -12,7 +12,7 @@ impl_payload! {
pub CreateNewStickerSet (CreateNewStickerSetSetters) => True {
required {
/// User identifier of sticker file owner
pub user_id: i32,
pub user_id: i64,
/// Short name of sticker set, to be used in `t.me/addstickers/` URLs (e.g., _animals_). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in _“\_by\_<bot username>”. <bot\_username>_ is case insensitive. 1-64 characters.
pub name: String [into],
/// Sticker set title, 1-64 characters

View file

@ -0,0 +1,27 @@
// This file is auto generated by `cg` <https://github.com/teloxide/cg> (24572cd + local changes).
// **DO NOT EDIT THIS FILE**,
// edit `cg` instead.
use serde::Serialize;
use crate::types::ChatId;
impl_payload! {
/// Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the edited invite link as a [`ChatInviteLink`] object.
///
/// [`ChatInviteLink`]: crate::types::ChatInviteLink
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub EditChatInviteLink (EditChatInviteLinkSetters) => String {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: ChatId [into],
/// The invite link to edit
pub invite_link: String [into],
}
optional {
/// Point in time (Unix timestamp) when the link will expire
pub expire_date: i64,
/// 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,
}
}
}

View file

@ -15,7 +15,7 @@ impl_payload! {
/// 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: i32,
pub user_id: i64,
}
}
}

View file

@ -15,7 +15,7 @@ impl_payload! {
pub GetGameHighScores (GetGameHighScoresSetters) => True {
required {
/// User identifier
pub user_id: u32,
pub user_id: i64,
/// Target message
#[serde(flatten)]
pub target: TargetMessage [into],

View file

@ -22,7 +22,7 @@ impl_payload! {
pub limit: u8,
/// Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
pub timeout: u32,
/// A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See [`Update`] for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.
/// A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See [`Update`] for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the previous setting will be used.
///
/// Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.
///

View file

@ -13,7 +13,7 @@ impl_payload! {
pub GetUserProfilePhotos (GetUserProfilePhotosSetters) => UserProfilePhotos {
required {
/// Unique identifier of the target user
pub user_id: i32,
pub user_id: i64,
}
optional {
/// Sequential number of the first photo to be returned. By default, all photos are returned.

View file

@ -15,11 +15,13 @@ impl_payload! {
/// 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: i32,
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

@ -13,11 +13,13 @@ impl_payload! {
/// 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: i32,
pub user_id: i64,
}
optional {
/// Pass True, if the administrator's presence in the chat is hidden
pub is_anonymous: bool,
/// Pass True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
pub can_manage_chat: bool,
/// Pass True, if the administrator can change chat title, photo and other settings
pub can_change_info: bool,
/// Pass True, if the administrator can create channel posts, channels only
@ -26,6 +28,8 @@ impl_payload! {
pub can_edit_messages: bool,
/// Pass True, if the administrator can delete messages of other users
pub can_delete_messages: bool,
/// Pass True, if the administrator can manage voice chats, supergroups only
pub can_manage_voice_chats: bool,
/// Pass True, if the administrator can invite new users to the chat
pub can_invite_users: bool,
/// Pass True, if the administrator can restrict, ban or unban chat members

View file

@ -13,7 +13,7 @@ impl_payload! {
/// 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: i32,
pub user_id: i64,
/// A JSON-serialized object for new user permissions
pub permissions: ChatPermissions,
}

View file

@ -0,0 +1,21 @@
// This file is auto generated by `cg` <https://github.com/teloxide/cg> (24572cd + local changes).
// **DO NOT EDIT THIS FILE**,
// edit `cg` instead.
use serde::Serialize;
use crate::types::ChatId;
impl_payload! {
/// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the revoked invite link as [`ChatInviteLink`] object.
///
/// [`ChatInviteLink`]: crate::types::ChatInviteLink
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub RevokeChatInviteLink (RevokeChatInviteLinkSetters) => String {
required {
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
pub chat_id: ChatId [into],
/// The invite link to revoke
pub invite_link: String [into],
}
}
}

View file

@ -16,7 +16,7 @@ impl_payload! {
pub chat_id: ChatId [into],
}
optional {
/// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, or “🏀”. Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”. Defaults to “🎲”
/// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
pub emoji: DiceEmoji,
/// Sends the message [silently]. Users will receive a notification with no sound.
///

View file

@ -6,9 +6,9 @@ use serde::Serialize;
use crate::types::{ChatId, InputMedia, Message};
impl_payload! {
/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [`Messages`] that were sent is returned.
/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [`Message`]s that were sent is returned.
///
/// [`Messages`]: crate::types::Messages
/// [`Message`]: crate::types::Message
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize)]
pub SendMediaGroup (SendMediaGroupSetters) => Vec<Message> {
required {

View file

@ -13,7 +13,7 @@ impl_payload! {
/// 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: i32,
pub user_id: i64,
/// New custom title for the administrator; 0-16 characters, emoji are not allowed
pub custom_title: String [into],
}

View file

@ -15,7 +15,7 @@ impl_payload! {
pub SetGameScore (SetGameScoreSetters) => Message {
required {
/// User identifier
pub user_id: u32,
pub user_id: i64,
/// New score
pub score: u64,
/// Unique identifier for the target chat

View file

@ -13,7 +13,7 @@ impl_payload! {
pub SetGameScoreInline (SetGameScoreInlineSetters) => Message {
required {
/// User identifier
pub user_id: u32,
pub user_id: i64,
/// New score
pub score: u64,
/// Identifier of the inline message

View file

@ -13,7 +13,7 @@ impl_payload! {
pub SetPassportDataErrors (SetPassportDataErrorsSetters) => True {
required {
/// User identifier
pub user_id: i32,
pub user_id: i64,
/// A JSON-serialized array describing the errors
pub errors: Vec<PassportElementError> [collect],
}

View file

@ -14,7 +14,7 @@ impl_payload! {
/// Name of the sticker set
pub name: String [into],
/// User identifier of sticker file owner
pub user_id: i32,
pub user_id: i64,
}
optional {
/// A **PNG** image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a **TGS** animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. Pass a _file\_id_ as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. [More info on Sending Files »]. Animated sticker set thumbnail can't be uploaded via HTTP URL.

View file

@ -6,22 +6,24 @@
pub use crate::payloads::{
AddStickerToSetSetters as _, AnswerCallbackQuerySetters as _, AnswerInlineQuerySetters as _,
AnswerPreCheckoutQuerySetters as _, AnswerShippingQuerySetters as _, CloseSetters as _,
CopyMessageSetters as _, CreateNewStickerSetSetters as _, DeleteChatPhotoSetters as _,
DeleteChatStickerSetSetters as _, DeleteMessageSetters as _, DeleteStickerFromSetSetters as _,
DeleteWebhookSetters 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 _,
CopyMessageSetters as _, CreateChatInviteLinkSetters as _, CreateNewStickerSetSetters as _,
DeleteChatPhotoSetters as _, DeleteChatStickerSetSetters as _, DeleteMessageSetters 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 _, SendAnimationSetters as _,
SendAudioSetters as _, SendChatActionSetters as _, SendContactSetters as _,
SendDiceSetters as _, SendDocumentSetters as _, SendGameSetters as _, SendInvoiceSetters 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

@ -13,7 +13,7 @@ impl_payload! {
/// 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: i32,
pub user_id: i64,
}
optional {
/// Do nothing if the user is not banned

View file

@ -12,7 +12,7 @@ impl_payload! {
pub UploadStickerFile (UploadStickerFileSetters) => File {
required {
/// User identifier of sticker file owner
pub user_id: i32,
pub user_id: i64,
/// PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. [More info on Sending Files »]
///
/// [More info on Sending Files »]: crate::types::InputFile

View file

@ -304,7 +304,7 @@ pub trait Requester {
type GetUserProfilePhotos: Request<Payload = GetUserProfilePhotos, Err = Self::Err>;
/// For Telegram documentation see [`GetUserProfilePhotos`].
fn get_user_profile_photos(&self, user_id: i32) -> Self::GetUserProfilePhotos;
fn get_user_profile_photos(&self, user_id: i64) -> Self::GetUserProfilePhotos;
type GetFile: Request<Payload = GetFile, Err = Self::Err>;
@ -316,14 +316,14 @@ pub trait Requester {
type KickChatMember: Request<Payload = KickChatMember, Err = Self::Err>;
/// For Telegram documentation see [`KickChatMember`].
fn kick_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::KickChatMember
fn kick_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::KickChatMember
where
C: Into<ChatId>;
type UnbanChatMember: Request<Payload = UnbanChatMember, Err = Self::Err>;
/// For Telegram documentation see [`UnbanChatMember`].
fn unban_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::UnbanChatMember
fn unban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::UnbanChatMember
where
C: Into<ChatId>;
@ -333,7 +333,7 @@ pub trait Requester {
fn restrict_chat_member<C>(
&self,
chat_id: C,
user_id: i32,
user_id: i64,
permissions: ChatPermissions,
) -> Self::RestrictChatMember
where
@ -342,7 +342,7 @@ pub trait Requester {
type PromoteChatMember: Request<Payload = PromoteChatMember, Err = Self::Err>;
/// For Telegram documentation see [`PromoteChatMember`].
fn promote_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::PromoteChatMember
fn promote_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::PromoteChatMember
where
C: Into<ChatId>;
@ -355,7 +355,7 @@ pub trait Requester {
fn set_chat_administrator_custom_title<Ch, Cu>(
&self,
chat_id: Ch,
user_id: i32,
user_id: i64,
custom_title: Cu,
) -> Self::SetChatAdministratorCustomTitle
where
@ -380,6 +380,33 @@ pub trait Requester {
where
C: Into<ChatId>;
type CreateChatInviteLink: Request<Payload = CreateChatInviteLink, Err = Self::Err>;
/// For Telegram documentation see [`CreateChatInviteLink`].
fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink
where
C: Into<ChatId>;
type EditChatInviteLink: Request<Payload = EditChatInviteLink, Err = Self::Err>;
/// For Telegram documentation see [`EditChatInviteLink`].
fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink
where
C: Into<ChatId>,
I: Into<String>;
type RevokeChatInviteLink: Request<Payload = RevokeChatInviteLink, Err = Self::Err>;
/// For Telegram documentation see [`RevokeChatInviteLink`].
fn revoke_chat_invite_link<C, I>(
&self,
chat_id: C,
invite_link: I,
) -> Self::RevokeChatInviteLink
where
C: Into<ChatId>,
I: Into<String>;
type SetChatPhoto: Request<Payload = SetChatPhoto, Err = Self::Err>;
/// For Telegram documentation see [`SetChatPhoto`].
@ -461,7 +488,7 @@ pub trait Requester {
type GetChatMember: Request<Payload = GetChatMember, Err = Self::Err>;
/// For Telegram documentation see [`GetChatMember`].
fn get_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::GetChatMember
fn get_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::GetChatMember
where
C: Into<ChatId>;
@ -631,14 +658,14 @@ pub trait Requester {
type UploadStickerFile: Request<Payload = UploadStickerFile, Err = Self::Err>;
/// For Telegram documentation see [`UploadStickerFile`].
fn upload_sticker_file(&self, user_id: i32, png_sticker: InputFile) -> Self::UploadStickerFile;
fn upload_sticker_file(&self, user_id: i64, png_sticker: InputFile) -> Self::UploadStickerFile;
type CreateNewStickerSet: Request<Payload = CreateNewStickerSet, Err = Self::Err>;
/// For Telegram documentation see [`CreateNewStickerSet`].
fn create_new_sticker_set<N, T, E>(
&self,
user_id: i32,
user_id: i64,
name: N,
title: T,
sticker: InputSticker,
@ -654,7 +681,7 @@ pub trait Requester {
/// For Telegram documentation see [`AddStickerToSet`].
fn add_sticker_to_set<N, E>(
&self,
user_id: i32,
user_id: i64,
name: N,
sticker: InputSticker,
emojis: E,
@ -684,7 +711,7 @@ pub trait Requester {
type SetStickerSetThumb: Request<Payload = SetStickerSetThumb, Err = Self::Err>;
/// For Telegram documentation see [`SetStickerSetThumb`].
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i32) -> Self::SetStickerSetThumb
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i64) -> Self::SetStickerSetThumb
where
N: Into<String>;
@ -732,7 +759,7 @@ pub trait Requester {
type SetPassportDataErrors: Request<Payload = SetPassportDataErrors, Err = Self::Err>;
/// For Telegram documentation see [`SetPassportDataErrors`].
fn set_passport_data_errors<E>(&self, user_id: i32, errors: E) -> Self::SetPassportDataErrors
fn set_passport_data_errors<E>(&self, user_id: i64, errors: E) -> Self::SetPassportDataErrors
where
E: IntoIterator<Item = PassportElementError>;
@ -748,7 +775,7 @@ pub trait Requester {
/// For Telegram documentation see [`SetGameScore`].
fn set_game_score(
&self,
user_id: u32,
user_id: i64,
score: u64,
chat_id: u32,
message_id: i64,
@ -759,7 +786,7 @@ pub trait Requester {
/// For Telegram documentation see [`SetGameScoreInline`].
fn set_game_score_inline<I>(
&self,
user_id: u32,
user_id: i64,
score: u64,
inline_message_id: I,
) -> Self::SetGameScoreInline
@ -769,7 +796,7 @@ pub trait Requester {
type GetGameHighScores: Request<Payload = GetGameHighScores, Err = Self::Err>;
/// For Telegram documentation see [`GetGameHighScores`].
fn get_game_high_scores<T>(&self, user_id: u32, target: T) -> Self::GetGameHighScores
fn get_game_high_scores<T>(&self, user_id: i64, target: T) -> Self::GetGameHighScores
where
T: Into<TargetMessage>;
@ -802,7 +829,8 @@ macro_rules! forward_all {
send_contact, send_poll, send_dice, send_chat_action, get_user_profile_photos,
get_file, kick_chat_member, unban_chat_member, restrict_chat_member,
promote_chat_member, set_chat_administrator_custom_title, set_chat_permissions,
export_chat_invite_link, set_chat_photo, delete_chat_photo, set_chat_title,
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,
set_chat_sticker_set, delete_chat_sticker_set, answer_callback_query,

View file

@ -9,8 +9,10 @@ pub use callback_query::*;
pub use chat::*;
pub use chat_action::*;
pub use chat_id::*;
pub use chat_invite_link::*;
pub use chat_location::*;
pub use chat_member::*;
pub use chat_member_updated::*;
pub use chat_permissions::*;
pub use chat_photo::*;
pub use chosen_inline_result::*;
@ -61,6 +63,7 @@ pub use login_url::*;
pub use mask_position::*;
pub use me::*;
pub use message::*;
pub use message_auto_delete_timer_changed::*;
pub use message_entity::*;
pub use message_id::*;
pub use order_info::*;
@ -94,6 +97,9 @@ pub use venue::*;
pub use video::*;
pub use video_note::*;
pub use voice::*;
pub use voice_chat_ended::*;
pub use voice_chat_participants_invited::*;
pub use voice_chat_started::*;
pub use webhook_info::*;
mod allowed_update;
@ -105,8 +111,10 @@ mod callback_query;
mod chat;
mod chat_action;
mod chat_id;
mod chat_invite_link;
mod chat_location;
mod chat_member;
mod chat_member_updated;
mod chat_permissions;
mod chat_photo;
mod chosen_inline_result;
@ -133,6 +141,7 @@ mod login_url;
mod mask_position;
mod me;
mod message;
mod message_auto_delete_timer_changed;
mod message_entity;
mod message_id;
mod order_info;
@ -163,6 +172,9 @@ mod venue;
mod video;
mod video_note;
mod voice;
mod voice_chat_ended;
mod voice_chat_participants_invited;
mod voice_chat_started;
mod webhook_info;
mod inline_query;

View file

@ -10,4 +10,10 @@ pub enum AllowedUpdate {
InlineQuery,
ChosenInlineResult,
CallbackQuery,
ShippingQuery,
PreCheckoutQuery,
Poll,
PollAnswer,
MyChatMember,
ChatMember,
}

View file

@ -0,0 +1,22 @@
use serde::{Deserialize, Serialize};
use crate::types::User;
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct ChatInviteLink {
/// The invite link. If the link was created by another chat administrator,
/// then the second part of the link will be replaced with “…”.
pub invite_link: String,
/// Creator of the link
pub creator: User,
/// `true`, if the link is primary
pub is_primary: bool,
/// `true`, if the link is revoked
pub is_revoked: bool,
/// Point in time (Unix timestamp) when the link will expire or has been
/// expired
pub expire_date: Option<i64>,
/// 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: Option<u32>,
}

View file

@ -51,6 +51,12 @@ pub struct Administrator {
/// administrator privileges of that user.
pub can_be_edited: bool,
/// `true`, if the administrator can access the chat event log, chat
/// statistics, message statistics in channels, see channel members, see
/// anonymous administrators in supergroups and ignore slow mode. Implied by
/// any other administrator privilege
pub can_manage_chat: bool,
/// `true`, if the administrator can change the chat
/// title, photo and other settings.
pub can_change_info: bool,
@ -67,6 +73,9 @@ pub struct Administrator {
/// of other users.
pub can_delete_messages: bool,
/// `true`, if the administrator can manage voice chats.
pub can_manage_voice_chats: bool,
/// `true`, if the administrator can invite new users
/// to the chat.
pub can_invite_users: bool,
@ -166,6 +175,20 @@ impl ChatMemberKind {
}
}
/// Getter for [`Administrator::can_manage_chat`] field.
pub fn can_manage_chat(&self) -> Option<bool> {
match &self {
Self::Administrator(Administrator {
can_manage_chat, ..
}) => Some(*can_manage_chat),
Self::Creator(_)
| Self::Member
| Self::Restricted(_)
| Self::Left
| Self::Kicked(_) => None,
}
}
/// Getter for [`Administrator::can_change_info`] field.
pub fn can_change_info(&self) -> Option<bool> {
match &self {
@ -223,6 +246,21 @@ impl ChatMemberKind {
}
}
/// Getter for [`Administrator::can_manage_voice_chats`] field.
pub fn can_manage_voice_chats(&self) -> Option<bool> {
match &self {
Self::Administrator(Administrator {
can_manage_voice_chats,
..
}) => Some(*can_manage_voice_chats),
Self::Creator(_)
| Self::Member
| Self::Restricted(_)
| Self::Left
| Self::Kicked(_) => None,
}
}
/// Getter for [`Administrator::can_invite_users`] field.
pub fn can_invite_users(&self) -> Option<bool> {
match &self {
@ -368,14 +406,16 @@ mod tests {
"language_code":"en"
},
"status":"administrator",
"can_be_edited":false,
"can_change_info":true,
"can_delete_messages":true,
"can_invite_users":true,
"can_restrict_members":true,
"can_pin_messages":true,
"can_promote_members":true,
"is_anonymous":false
"is_anonymous": false,
"can_be_edited": false,
"can_manage_chat": true,
"can_change_info": true,
"can_delete_messages": true,
"can_manage_voice_chats": true,
"can_invite_users": true,
"can_restrict_members": true,
"can_pin_messages": true,
"can_promote_members": true
}"#;
let expected = ChatMember {
user: User {
@ -388,16 +428,18 @@ mod tests {
},
kind: ChatMemberKind::Administrator(Administrator {
custom_title: None,
is_anonymous: false,
can_be_edited: false,
can_manage_chat: true,
can_change_info: true,
can_post_messages: None,
can_edit_messages: None,
can_delete_messages: true,
can_manage_voice_chats: true,
can_invite_users: true,
can_restrict_members: true,
can_pin_messages: Some(true),
can_promote_members: true,
is_anonymous: false,
}),
};
let actual = serde_json::from_str::<ChatMember>(&json).unwrap();

View file

@ -0,0 +1,20 @@
use serde::{Deserialize, Serialize};
use crate::types::{Chat, ChatInviteLink, ChatMember, User};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ChatMemberUpdated {
/// Chat the user belongs to
pub chat: Chat,
/// Performer of the action, which resulted in the change
pub from: User,
/// Date the change was done in Unix time
pub date: i64,
/// Previous information about the chat member
pub old_chat_member: ChatMember,
/// New information about the chat member
pub new_chat_member: ChatMember,
/// Chat invite link, which was used by the user to join the chat; for
/// joining by invite link events only.
pub invite_link: Option<ChatInviteLink>,
}

View file

@ -18,6 +18,10 @@ pub enum DiceEmoji {
#[serde(rename = "")]
Football,
/// Values 1-5
#[serde(rename = "🎳")]
Bowling,
/// Values 1-64
#[serde(rename = "🎰")]
SlotMachine,

View file

@ -5,9 +5,10 @@ use serde::{Deserialize, Serialize};
use crate::types::{
chat::{ChatKind, PublicChatKind},
Animation, Audio, Chat, ChatPublic, Contact, Dice, Document, Game, InlineKeyboardMarkup,
Invoice, Location, MessageEntity, PassportData, PhotoSize, Poll, ProximityAlertTriggered,
PublicChatChannel, PublicChatSupergroup, Sticker, SuccessfulPayment, True, User, Venue, Video,
VideoNote, Voice,
Invoice, Location, MessageAutoDeleteTimerChanged, MessageEntity, PassportData, PhotoSize, Poll,
ProximityAlertTriggered, PublicChatChannel, PublicChatSupergroup, Sticker, SuccessfulPayment,
True, User, Venue, Video, VideoNote, Voice, VoiceChatEnded, VoiceChatParticipantsInvited,
VoiceChatStarted,
};
/// This object represents a message.
@ -44,6 +45,7 @@ pub enum MessageKind {
GroupChatCreated(MessageGroupChatCreated),
SupergroupChatCreated(MessageSupergroupChatCreated),
ChannelChatCreated(MessageChannelChatCreated),
MessageAutoDeleteTimerChanged(MessageMessageAutoDeleteTimerChanged),
Migrate(MessageMigrate),
Pinned(MessagePinned),
Invoice(MessageInvoice),
@ -52,6 +54,9 @@ pub enum MessageKind {
PassportData(MessagePassportData),
Dice(MessageDice),
ProximityAlertTriggered(MessageProximityAlertTriggered),
VoiceChatStarted(MessageVoiceChatStarted),
VoiceChatEnded(MessageVoiceChatEnded),
VoiceChatParticipantsInvited(MessageVoiceChatParticipantsInvited),
}
#[serde_with_macros::skip_serializing_none]
@ -143,6 +148,12 @@ pub struct MessageChannelChatCreated {
pub channel_chat_created: True,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageMessageAutoDeleteTimerChanged {
/// Service message: auto-delete timer settings changed in the chat.
message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageMigrate {
/// The group has been migrated to a supergroup with the specified
@ -445,6 +456,24 @@ pub struct MessageProximityAlertTriggered {
pub proximity_alert_triggered: ProximityAlertTriggered,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatStarted {
/// Service message: voice chat started.
pub voice_chat_started: VoiceChatStarted,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatEnded {
/// Service message: voice chat ended.
pub voice_chat_ended: VoiceChatEnded,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVoiceChatParticipantsInvited {
/// Service message: new participants invited to a voice chat.
pub voice_chat_participants_invited: VoiceChatParticipantsInvited,
}
mod getters {
use std::ops::Deref;

View file

@ -0,0 +1,9 @@
use serde::{Deserialize, Serialize};
/// This object represents a service message about a change in auto-delete timer
/// settings.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct MessageAutoDeleteTimerChanged {
/// New auto-delete time for messages in the chat
pub message_auto_delete_time: u32,
}

View file

@ -3,8 +3,8 @@
use serde::{Deserialize, Serialize};
use crate::types::{
CallbackQuery, Chat, ChosenInlineResult, InlineQuery, Message, Poll, PollAnswer,
PreCheckoutQuery, ShippingQuery, User,
CallbackQuery, Chat, ChatMemberUpdated, ChosenInlineResult, InlineQuery, Message, Poll,
PollAnswer, PreCheckoutQuery, ShippingQuery, User,
};
use serde_json::Value;
@ -95,6 +95,19 @@ pub enum UpdateKind {
/// A user changed their answer in a non-anonymous poll. Bots receive new
/// votes only in polls that were sent by the bot itself.
PollAnswer(PollAnswer),
/// The bot's chat member status was updated in a chat. For private chats,
/// this update is received only when the bot is blocked or unblocked by the
/// user.
MyChatMember(ChatMemberUpdated),
/// A chat member's status was updated in a chat. The bot must be an
/// administrator in the chat and must explicitly specify
/// [`AllowedUpdate::ChatMember`] in the list of `allowed_updates` to
/// receive these updates.
///
/// [`AllowedUpdate::ChatMember`]: crate::types::AllowedUpdate::ChatMember
ChatMember(ChatMemberUpdated),
}
impl Update {

View file

@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct User {
/// Unique identifier for this user or bot.
pub id: i32,
pub id: i64,
/// `true`, if this user is a bot.
pub is_bot: bool,

View file

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat ended in the
/// chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatEnded;

View file

@ -0,0 +1,11 @@
use serde::{Deserialize, Serialize};
use crate::types::User;
/// This object represents a service message about new members invited to a
/// voice chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatParticipantsInvited {
/// New members that were invited to the voice chat
pub users: Option<Vec<User>>,
}

View file

@ -0,0 +1,6 @@
use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat started in the
/// chat. Currently holds no information.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatStarted;