mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
Merge branch 'master' into hide_token_in_errors
This commit is contained in:
commit
d1cf0e4f52
93 changed files with 863 additions and 698 deletions
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
|
@ -39,10 +39,13 @@ jobs:
|
|||
|
||||
include:
|
||||
- rust: stable
|
||||
toolchain: stable
|
||||
features: "--features full"
|
||||
- rust: beta
|
||||
toolchain: beta
|
||||
features: "--features full"
|
||||
- rust: nightly
|
||||
toolchain: nightly-2022-01-17
|
||||
features: "--all-features"
|
||||
|
||||
steps:
|
||||
|
@ -51,7 +54,7 @@ jobs:
|
|||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ matrix.rust }}
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
override: true
|
||||
|
||||
- name: build
|
||||
|
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- `user.id` now uses `UserId` type, `ChatId` now represents only _chat id_, not channel username, all `chat_id` function parameters now accept `Recipient` [**BC**]
|
||||
|
||||
## 0.4.5 - 2022-04-03
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -3,3 +3,4 @@ wrap_comments = true
|
|||
format_strings = true
|
||||
imports_granularity = "Crate"
|
||||
use_field_init_shorthand = true
|
||||
merge_derives = false
|
||||
|
|
|
@ -12,7 +12,7 @@ use url::Url;
|
|||
use crate::{
|
||||
payloads::GetMe,
|
||||
requests::{HasPayload, Request, Requester},
|
||||
types::{ChatId, Me, *},
|
||||
types::{Me, Recipient, *},
|
||||
};
|
||||
|
||||
/// `get_me` cache.
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@ use url::Url;
|
|||
use crate::{
|
||||
prelude::Requester,
|
||||
requests::HasPayload,
|
||||
types::{ChatId, InputFile, ParseMode, *},
|
||||
types::{InputFile, ParseMode, Recipient, *},
|
||||
};
|
||||
|
||||
/// Default parse mode adaptor, see
|
||||
|
@ -86,7 +86,7 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
|
|||
|
||||
fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
Q: Into<String>,
|
||||
O: IntoIterator<Item = String>,
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ impl<B> Throttle<B> {
|
|||
///
|
||||
/// [`RequesterExt::throttle`]: crate::requests::RequesterExt::throttle
|
||||
pub fn new_spawn(bot: B, limits: Limits) -> Self {
|
||||
// new/with_settings copypasted here to avoid [rust-lang/#76882]
|
||||
// new/with_settings copy-pasted here to avoid [rust-lang/#76882]
|
||||
//
|
||||
// [rust-lang/#76882]: https://github.com/rust-lang/rust/issues/76882
|
||||
|
||||
|
@ -132,7 +132,7 @@ impl<B> Throttle<B> {
|
|||
|
||||
/// Creates new [`Throttle`] spawning the worker with `tokio::spawn`
|
||||
pub fn spawn_with_settings(bot: B, settings: Settings) -> Self {
|
||||
// with_settings copypasted here to avoid [rust-lang/#76882]
|
||||
// with_settings copy-pasted here to avoid [rust-lang/#76882]
|
||||
//
|
||||
// [rust-lang/#76882]: https://github.com/rust-lang/rust/issues/76882
|
||||
|
||||
|
@ -174,7 +174,7 @@ impl<B> Throttle<B> {
|
|||
|
||||
/// Sets new limits.
|
||||
///
|
||||
/// Note: changes may not be applied imidiately.
|
||||
/// Note: changes may not be applied immediately.
|
||||
pub async fn set_limits(&self, new: Limits) {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
|
@ -286,7 +286,7 @@ const SECOND: Duration = Duration::from_secs(1);
|
|||
// want to change this.
|
||||
const DELAY: Duration = Duration::from_millis(250);
|
||||
|
||||
/// Minimal time beetween calls to queue_full function
|
||||
/// Minimal time between calls to queue_full function
|
||||
const QUEUE_FULL_DELAY: Duration = Duration::from_secs(4);
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -375,12 +375,12 @@ async fn worker(
|
|||
while !rx_is_closed || !queue.is_empty() {
|
||||
// FIXME(waffle):
|
||||
// 1. If the `queue` is empty, `read_from_rx` call down below will 'block'
|
||||
// execution untill a request is sent. While the execution is 'blocked' no
|
||||
// execution until a request is sent. While the execution is 'blocked' no
|
||||
// `InfoMessage`s could be answered.
|
||||
//
|
||||
// 2. If limits are descreased, ideally we want to shrink queue.
|
||||
// 2. If limits are decreased, ideally we want to shrink queue.
|
||||
//
|
||||
// *blocked in asyncronous way
|
||||
// *blocked in asynchronous way
|
||||
answer_info(&mut info_rx, &mut limits);
|
||||
|
||||
read_from_rx(&mut rx, &mut queue, &mut rx_is_closed).await;
|
||||
|
@ -428,7 +428,7 @@ async fn worker(
|
|||
let min_back = now - MINUTE;
|
||||
let sec_back = now - SECOND;
|
||||
|
||||
// make history and hchats up-to-date
|
||||
// make history and requests_sent up-to-date
|
||||
while let Some((_, time)) = history.front() {
|
||||
// history is sorted, we found first up-to-date thing
|
||||
if time >= &min_back {
|
||||
|
@ -529,7 +529,7 @@ async fn read_from_rx<T>(rx: &mut mpsc::Receiver<T>, queue: &mut Vec<T>, rx_is_c
|
|||
}
|
||||
}
|
||||
|
||||
// Don't grow queue bigger than the capacity to limit DOS posibility
|
||||
// Don't grow queue bigger than the capacity to limit DOS possibility
|
||||
while queue.len() < queue.capacity() {
|
||||
// FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350
|
||||
match tokio::task::unconstrained(rx.recv()).now_or_never() {
|
||||
|
@ -638,24 +638,24 @@ download_forward! {
|
|||
/// usernames. (It is just a hashed username.)
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
|
||||
enum ChatIdHash {
|
||||
Id(i64),
|
||||
Id(ChatId),
|
||||
ChannelUsernameHash(u64),
|
||||
}
|
||||
|
||||
impl ChatIdHash {
|
||||
fn is_channel(&self) -> bool {
|
||||
match self {
|
||||
&Self::Id(id) => ChatId::Id(id).is_channel(),
|
||||
&Self::Id(id) => id.is_channel(),
|
||||
Self::ChannelUsernameHash(_) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&ChatId> for ChatIdHash {
|
||||
fn from(value: &ChatId) -> Self {
|
||||
impl From<&Recipient> for ChatIdHash {
|
||||
fn from(value: &Recipient) -> Self {
|
||||
match value {
|
||||
ChatId::Id(id) => ChatIdHash::Id(*id),
|
||||
ChatId::ChannelUsername(username) => {
|
||||
Recipient::Id(id) => ChatIdHash::Id(*id),
|
||||
Recipient::ChannelUsername(username) => {
|
||||
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
||||
username.hash(&mut hasher);
|
||||
let hash = hasher.finish();
|
||||
|
|
177
src/bot/api.rs
177
src/bot/api.rs
|
@ -6,7 +6,7 @@ use crate::{
|
|||
requests::{JsonRequest, MultipartRequest},
|
||||
types::{
|
||||
BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
|
||||
InputSticker, LabeledPrice,
|
||||
InputSticker, LabeledPrice, Recipient, UserId,
|
||||
},
|
||||
Bot,
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
{
|
||||
Self::SendMessage::new(self.clone(), payloads::SendMessage::new(chat_id, text))
|
||||
|
@ -63,8 +63,8 @@ impl Requester for Bot {
|
|||
message_id: i32,
|
||||
) -> Self::ForwardMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
F: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
F: Into<Recipient>,
|
||||
{
|
||||
Self::ForwardMessage::new(
|
||||
self.clone(),
|
||||
|
@ -76,7 +76,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SendPhoto
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendPhoto::new(self.clone(), payloads::SendPhoto::new(chat_id, photo))
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_audio<C>(&self, chat_id: C, audio: InputFile) -> Self::SendAudio
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendAudio::new(self.clone(), payloads::SendAudio::new(chat_id, audio))
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_document<C>(&self, chat_id: C, document: InputFile) -> Self::SendDocument
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendDocument::new(self.clone(), payloads::SendDocument::new(chat_id, document))
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_video<C>(&self, chat_id: C, video: InputFile) -> Self::SendVideo
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendVideo::new(self.clone(), payloads::SendVideo::new(chat_id, video))
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_animation<C>(&self, chat_id: C, animation: InputFile) -> Self::SendAnimation
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendAnimation::new(
|
||||
self.clone(),
|
||||
|
@ -124,7 +124,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_voice<C>(&self, chat_id: C, voice: InputFile) -> Self::SendVoice
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendVoice::new(self.clone(), payloads::SendVoice::new(chat_id, voice))
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendVideoNote::new(
|
||||
self.clone(),
|
||||
|
@ -145,7 +145,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
M: IntoIterator<Item = InputMedia>,
|
||||
{
|
||||
Self::SendMediaGroup::new(self.clone(), payloads::SendMediaGroup::new(chat_id, media))
|
||||
|
@ -155,7 +155,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_location<C>(&self, chat_id: C, latitude: f64, longitude: f64) -> Self::SendLocation
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendLocation::new(
|
||||
self.clone(),
|
||||
|
@ -173,7 +173,7 @@ impl Requester for Bot {
|
|||
longitude: f64,
|
||||
) -> Self::EditMessageLiveLocation
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::EditMessageLiveLocation::new(
|
||||
self.clone(),
|
||||
|
@ -208,7 +208,7 @@ impl Requester for Bot {
|
|||
longitude: f64,
|
||||
) -> Self::StopMessageLiveLocation
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::StopMessageLiveLocation::new(
|
||||
self.clone(),
|
||||
|
@ -244,7 +244,7 @@ impl Requester for Bot {
|
|||
address: A,
|
||||
) -> Self::SendVenue
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
A: Into<String>,
|
||||
{
|
||||
|
@ -258,7 +258,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_contact<C, P, F>(&self, chat_id: C, phone_number: P, first_name: F) -> Self::SendContact
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
P: Into<String>,
|
||||
F: Into<String>,
|
||||
{
|
||||
|
@ -272,7 +272,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
Q: Into<String>,
|
||||
O: IntoIterator<Item = String>,
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_dice<C>(&self, chat_id: C) -> Self::SendDice
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendDice::new(self.clone(), payloads::SendDice::new(chat_id))
|
||||
}
|
||||
|
@ -299,14 +299,14 @@ impl Requester for Bot {
|
|||
action: crate::types::ChatAction,
|
||||
) -> Self::SendChatAction
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendChatAction::new(self.clone(), payloads::SendChatAction::new(chat_id, action))
|
||||
}
|
||||
|
||||
type GetUserProfilePhotos = JsonRequest<payloads::GetUserProfilePhotos>;
|
||||
|
||||
fn get_user_profile_photos(&self, user_id: i64) -> Self::GetUserProfilePhotos {
|
||||
fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos {
|
||||
Self::GetUserProfilePhotos::new(self.clone(), payloads::GetUserProfilePhotos::new(user_id))
|
||||
}
|
||||
|
||||
|
@ -321,9 +321,9 @@ impl Requester for Bot {
|
|||
|
||||
type KickChatMember = JsonRequest<payloads::KickChatMember>;
|
||||
|
||||
fn kick_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::KickChatMember
|
||||
fn kick_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::KickChatMember
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::KickChatMember::new(
|
||||
self.clone(),
|
||||
|
@ -333,18 +333,18 @@ impl Requester for Bot {
|
|||
|
||||
type BanChatMember = JsonRequest<payloads::BanChatMember>;
|
||||
|
||||
fn ban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::BanChatMember
|
||||
fn ban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::BanChatMember
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
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
|
||||
fn unban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::UnbanChatMember
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::UnbanChatMember::new(
|
||||
self.clone(),
|
||||
|
@ -357,11 +357,11 @@ impl Requester for Bot {
|
|||
fn restrict_chat_member<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
permissions: ChatPermissions,
|
||||
) -> Self::RestrictChatMember
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::RestrictChatMember::new(
|
||||
self.clone(),
|
||||
|
@ -371,9 +371,9 @@ impl Requester for Bot {
|
|||
|
||||
type PromoteChatMember = JsonRequest<payloads::PromoteChatMember>;
|
||||
|
||||
fn promote_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::PromoteChatMember
|
||||
fn promote_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::PromoteChatMember
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::PromoteChatMember::new(
|
||||
self.clone(),
|
||||
|
@ -386,11 +386,11 @@ impl Requester for Bot {
|
|||
fn set_chat_administrator_custom_title<Ch, Cu>(
|
||||
&self,
|
||||
chat_id: Ch,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
custom_title: Cu,
|
||||
) -> Self::SetChatAdministratorCustomTitle
|
||||
where
|
||||
Ch: Into<ChatId>,
|
||||
Ch: Into<Recipient>,
|
||||
Cu: Into<String>,
|
||||
{
|
||||
Self::SetChatAdministratorCustomTitle::new(
|
||||
|
@ -401,9 +401,10 @@ impl Requester for Bot {
|
|||
|
||||
type BanChatSenderChat = JsonRequest<payloads::BanChatSenderChat>;
|
||||
|
||||
fn ban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::BanChatSenderChat
|
||||
fn ban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::BanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
S: Into<ChatId>,
|
||||
{
|
||||
Self::BanChatSenderChat::new(
|
||||
self.clone(),
|
||||
|
@ -413,13 +414,14 @@ impl Requester for Bot {
|
|||
|
||||
type UnbanChatSenderChat = JsonRequest<payloads::UnbanChatSenderChat>;
|
||||
|
||||
fn unban_chat_sender_chat<C>(
|
||||
fn unban_chat_sender_chat<C, S>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
sender_chat_id: i64,
|
||||
sender_chat_id: S,
|
||||
) -> Self::UnbanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
S: Into<ChatId>,
|
||||
{
|
||||
Self::UnbanChatSenderChat::new(
|
||||
self.clone(),
|
||||
|
@ -435,7 +437,7 @@ impl Requester for Bot {
|
|||
permissions: ChatPermissions,
|
||||
) -> Self::SetChatPermissions
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SetChatPermissions::new(
|
||||
self.clone(),
|
||||
|
@ -447,7 +449,7 @@ impl Requester for Bot {
|
|||
|
||||
fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::ExportChatInviteLink::new(self.clone(), payloads::ExportChatInviteLink::new(chat_id))
|
||||
}
|
||||
|
@ -456,7 +458,7 @@ impl Requester for Bot {
|
|||
|
||||
fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::CreateChatInviteLink::new(self.clone(), payloads::CreateChatInviteLink::new(chat_id))
|
||||
}
|
||||
|
@ -465,7 +467,7 @@ impl Requester for Bot {
|
|||
|
||||
fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
I: Into<String>,
|
||||
{
|
||||
Self::EditChatInviteLink::new(
|
||||
|
@ -482,7 +484,7 @@ impl Requester for Bot {
|
|||
invite_link: I,
|
||||
) -> Self::RevokeChatInviteLink
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
I: Into<String>,
|
||||
{
|
||||
Self::RevokeChatInviteLink::new(
|
||||
|
@ -493,9 +495,13 @@ impl Requester for Bot {
|
|||
|
||||
type ApproveChatJoinRequest = JsonRequest<payloads::ApproveChatJoinRequest>;
|
||||
|
||||
fn approve_chat_join_request<C>(&self, chat_id: C, user_id: i64) -> Self::ApproveChatJoinRequest
|
||||
fn approve_chat_join_request<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
user_id: UserId,
|
||||
) -> Self::ApproveChatJoinRequest
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::ApproveChatJoinRequest::new(
|
||||
self.clone(),
|
||||
|
@ -505,9 +511,13 @@ impl Requester for Bot {
|
|||
|
||||
type DeclineChatJoinRequest = JsonRequest<payloads::DeclineChatJoinRequest>;
|
||||
|
||||
fn decline_chat_join_request<C>(&self, chat_id: C, user_id: i64) -> Self::DeclineChatJoinRequest
|
||||
fn decline_chat_join_request<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
user_id: UserId,
|
||||
) -> Self::DeclineChatJoinRequest
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::DeclineChatJoinRequest::new(
|
||||
self.clone(),
|
||||
|
@ -519,7 +529,7 @@ impl Requester for Bot {
|
|||
|
||||
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SetChatPhoto::new(self.clone(), payloads::SetChatPhoto::new(chat_id, photo))
|
||||
}
|
||||
|
@ -528,7 +538,7 @@ impl Requester for Bot {
|
|||
|
||||
fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::DeleteChatPhoto::new(self.clone(), payloads::DeleteChatPhoto::new(chat_id))
|
||||
}
|
||||
|
@ -537,7 +547,7 @@ impl Requester for Bot {
|
|||
|
||||
fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
{
|
||||
Self::SetChatTitle::new(self.clone(), payloads::SetChatTitle::new(chat_id, title))
|
||||
|
@ -547,7 +557,7 @@ impl Requester for Bot {
|
|||
|
||||
fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SetChatDescription::new(self.clone(), payloads::SetChatDescription::new(chat_id))
|
||||
}
|
||||
|
@ -556,7 +566,7 @@ impl Requester for Bot {
|
|||
|
||||
fn pin_chat_message<C>(&self, chat_id: C, message_id: i32) -> Self::PinChatMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::PinChatMessage::new(
|
||||
self.clone(),
|
||||
|
@ -568,7 +578,7 @@ impl Requester for Bot {
|
|||
|
||||
fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::UnpinChatMessage::new(self.clone(), payloads::UnpinChatMessage::new(chat_id))
|
||||
}
|
||||
|
@ -577,7 +587,7 @@ impl Requester for Bot {
|
|||
|
||||
fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::LeaveChat::new(self.clone(), payloads::LeaveChat::new(chat_id))
|
||||
}
|
||||
|
@ -586,7 +596,7 @@ impl Requester for Bot {
|
|||
|
||||
fn get_chat<C>(&self, chat_id: C) -> Self::GetChat
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::GetChat::new(self.clone(), payloads::GetChat::new(chat_id))
|
||||
}
|
||||
|
@ -595,7 +605,7 @@ impl Requester for Bot {
|
|||
|
||||
fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::GetChatAdministrators::new(
|
||||
self.clone(),
|
||||
|
@ -607,7 +617,7 @@ impl Requester for Bot {
|
|||
|
||||
fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::GetChatMembersCount::new(self.clone(), payloads::GetChatMembersCount::new(chat_id))
|
||||
}
|
||||
|
@ -616,16 +626,16 @@ impl Requester for Bot {
|
|||
|
||||
fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
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
|
||||
fn get_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::GetChatMember
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::GetChatMember::new(self.clone(), payloads::GetChatMember::new(chat_id, user_id))
|
||||
}
|
||||
|
@ -634,7 +644,7 @@ impl Requester for Bot {
|
|||
|
||||
fn set_chat_sticker_set<C, S>(&self, chat_id: C, sticker_set_name: S) -> Self::SetChatStickerSet
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
S: Into<String>,
|
||||
{
|
||||
Self::SetChatStickerSet::new(
|
||||
|
@ -647,7 +657,7 @@ impl Requester for Bot {
|
|||
|
||||
fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::DeleteChatStickerSet::new(self.clone(), payloads::DeleteChatStickerSet::new(chat_id))
|
||||
}
|
||||
|
@ -702,7 +712,7 @@ impl Requester for Bot {
|
|||
|
||||
fn edit_message_text<C, T>(&self, chat_id: C, message_id: i32, text: T) -> Self::EditMessageText
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
{
|
||||
Self::EditMessageText::new(
|
||||
|
@ -732,7 +742,7 @@ impl Requester for Bot {
|
|||
|
||||
fn edit_message_caption<C>(&self, chat_id: C, message_id: i32) -> Self::EditMessageCaption
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::EditMessageCaption::new(
|
||||
self.clone(),
|
||||
|
@ -761,7 +771,7 @@ impl Requester for Bot {
|
|||
media: InputMedia,
|
||||
) -> Self::EditMessageMedia
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::EditMessageMedia::new(
|
||||
self.clone(),
|
||||
|
@ -793,7 +803,7 @@ impl Requester for Bot {
|
|||
message_id: i32,
|
||||
) -> Self::EditMessageReplyMarkup
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::EditMessageReplyMarkup::new(
|
||||
self.clone(),
|
||||
|
@ -820,7 +830,7 @@ impl Requester for Bot {
|
|||
|
||||
fn stop_poll<C>(&self, chat_id: C, message_id: i32) -> Self::StopPoll
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::StopPoll::new(self.clone(), payloads::StopPoll::new(chat_id, message_id))
|
||||
}
|
||||
|
@ -829,7 +839,7 @@ impl Requester for Bot {
|
|||
|
||||
fn delete_message<C>(&self, chat_id: C, message_id: i32) -> Self::DeleteMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::DeleteMessage::new(
|
||||
self.clone(),
|
||||
|
@ -841,7 +851,7 @@ impl Requester for Bot {
|
|||
|
||||
fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::SendSticker::new(self.clone(), payloads::SendSticker::new(chat_id, sticker))
|
||||
}
|
||||
|
@ -857,8 +867,11 @@ impl Requester for Bot {
|
|||
|
||||
type UploadStickerFile = MultipartRequest<payloads::UploadStickerFile>;
|
||||
|
||||
fn upload_sticker_file(&self, user_id: i64, png_sticker: InputFile) -> Self::UploadStickerFile where
|
||||
{
|
||||
fn upload_sticker_file(
|
||||
&self,
|
||||
user_id: UserId,
|
||||
png_sticker: InputFile,
|
||||
) -> Self::UploadStickerFile where {
|
||||
Self::UploadStickerFile::new(
|
||||
self.clone(),
|
||||
payloads::UploadStickerFile::new(user_id, png_sticker),
|
||||
|
@ -869,7 +882,7 @@ impl Requester for Bot {
|
|||
|
||||
fn create_new_sticker_set<N, T, E>(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
name: N,
|
||||
title: T,
|
||||
sticker: InputSticker,
|
||||
|
@ -890,7 +903,7 @@ impl Requester for Bot {
|
|||
|
||||
fn add_sticker_to_set<N, E>(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
name: N,
|
||||
sticker: InputSticker,
|
||||
emojis: E,
|
||||
|
@ -932,7 +945,7 @@ impl Requester for Bot {
|
|||
|
||||
type SetStickerSetThumb = MultipartRequest<payloads::SetStickerSetThumb>;
|
||||
|
||||
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i64) -> Self::SetStickerSetThumb
|
||||
fn set_sticker_set_thumb<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumb
|
||||
where
|
||||
N: Into<String>,
|
||||
{
|
||||
|
@ -955,7 +968,7 @@ impl Requester for Bot {
|
|||
prices: Pri,
|
||||
) -> Self::SendInvoice
|
||||
where
|
||||
Ch: Into<ChatId>,
|
||||
Ch: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
D: Into<String>,
|
||||
Pa: Into<String>,
|
||||
|
@ -1007,7 +1020,7 @@ impl Requester for Bot {
|
|||
|
||||
type SetPassportDataErrors = JsonRequest<payloads::SetPassportDataErrors>;
|
||||
|
||||
fn set_passport_data_errors<E>(&self, user_id: i64, errors: E) -> Self::SetPassportDataErrors
|
||||
fn set_passport_data_errors<E>(&self, user_id: UserId, errors: E) -> Self::SetPassportDataErrors
|
||||
where
|
||||
E: IntoIterator<Item = crate::types::PassportElementError>,
|
||||
{
|
||||
|
@ -1033,7 +1046,7 @@ impl Requester for Bot {
|
|||
|
||||
fn set_game_score(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
score: u64,
|
||||
chat_id: u32,
|
||||
message_id: i64,
|
||||
|
@ -1048,7 +1061,7 @@ impl Requester for Bot {
|
|||
|
||||
fn set_game_score_inline<I>(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
score: u64,
|
||||
inline_message_id: I,
|
||||
) -> Self::SetGameScoreInline
|
||||
|
@ -1063,7 +1076,7 @@ impl Requester for Bot {
|
|||
|
||||
type GetGameHighScores = JsonRequest<payloads::GetGameHighScores>;
|
||||
|
||||
fn get_game_high_scores<T>(&self, user_id: i64, target: T) -> Self::GetGameHighScores
|
||||
fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores
|
||||
where
|
||||
T: Into<crate::types::TargetMessage>,
|
||||
{
|
||||
|
@ -1089,8 +1102,8 @@ impl Requester for Bot {
|
|||
|
||||
fn copy_message<C, F>(&self, chat_id: C, from_chat_id: F, message_id: i32) -> Self::CopyMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
F: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
F: Into<Recipient>,
|
||||
{
|
||||
Self::CopyMessage::new(
|
||||
self.clone(),
|
||||
|
@ -1102,7 +1115,7 @@ impl Requester for Bot {
|
|||
|
||||
fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
Self::UnpinAllChatMessages::new(self.clone(), payloads::UnpinAllChatMessages::new(chat_id))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! This library provides tools for making requests to the [Telegram Bot API]
|
||||
//! (Currently, version `5.3` is supported) with ease. The library is fully
|
||||
//! asynchronouns and built using [`tokio`].
|
||||
//! asynchronous and built using [`tokio`].
|
||||
//!
|
||||
//!```toml
|
||||
//! teloxide_core = "0.4"
|
||||
|
@ -12,7 +12,7 @@
|
|||
//! ```
|
||||
//! # #[cfg(feature = "auto_send")]
|
||||
//! # async {
|
||||
//! # let chat_id = 0;
|
||||
//! # let chat_id = teloxide_core::types::ChatId(-1);
|
||||
//! use teloxide_core::{
|
||||
//! prelude::*,
|
||||
//! types::{DiceEmoji, ParseMode},
|
||||
|
@ -51,8 +51,8 @@
|
|||
//! - `erased` — enables [`ErasedRequester`] bot adaptor
|
||||
//! - `throttle` — enables [`Throttle`] bot adaptor
|
||||
//! - `cache_me` — enables [`CacheMe`] bot adaptor
|
||||
//! - `full` — enables all features except `nigthly` and tls-related
|
||||
//! - `nightly` — enables nigthly-only features, currently:
|
||||
//! - `full` — enables all features except `nightly` and tls-related
|
||||
//! - `nightly` — enables nightly-only features, currently:
|
||||
//! - Removes some future boxing using `#![feature(type_alias_impl_trait)]`
|
||||
//! - Used to built docs (`#![feature(doc_cfg, doc_notable_trait)]`)
|
||||
//!
|
||||
|
|
|
@ -481,7 +481,7 @@ macro_rules! requester_forward {
|
|||
(@method send_message $body:ident $ty:ident) => {
|
||||
type SendMessage = $ty![SendMessage];
|
||||
|
||||
fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage where C: Into<ChatId>,
|
||||
fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage where C: Into<Recipient>,
|
||||
T: Into<String> {
|
||||
let this = self;
|
||||
$body!(send_message this (chat_id: C, text: T))
|
||||
|
@ -490,8 +490,8 @@ macro_rules! requester_forward {
|
|||
(@method forward_message $body:ident $ty:ident) => {
|
||||
type ForwardMessage = $ty![ForwardMessage];
|
||||
|
||||
fn forward_message<C, F>(&self, chat_id: C, from_chat_id: F, message_id: i32) -> Self::ForwardMessage where C: Into<ChatId>,
|
||||
F: Into<ChatId> {
|
||||
fn forward_message<C, F>(&self, chat_id: C, from_chat_id: F, message_id: i32) -> Self::ForwardMessage where C: Into<Recipient>,
|
||||
F: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(forward_message this (chat_id: C, from_chat_id: F, message_id: i32))
|
||||
}
|
||||
|
@ -499,8 +499,8 @@ macro_rules! requester_forward {
|
|||
(@method copy_message $body:ident $ty:ident) => {
|
||||
type CopyMessage = $ty![CopyMessage];
|
||||
|
||||
fn copy_message<C, F>(&self, chat_id: C, from_chat_id: F, message_id: i32) -> Self::CopyMessage where C: Into<ChatId>,
|
||||
F: Into<ChatId> {
|
||||
fn copy_message<C, F>(&self, chat_id: C, from_chat_id: F, message_id: i32) -> Self::CopyMessage where C: Into<Recipient>,
|
||||
F: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(copy_message this (chat_id: C, from_chat_id: F, message_id: i32))
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ macro_rules! requester_forward {
|
|||
(@method send_photo $body:ident $ty:ident) => {
|
||||
type SendPhoto = $ty![SendPhoto];
|
||||
|
||||
fn send_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SendPhoto where C: Into<ChatId> {
|
||||
fn send_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SendPhoto where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_photo this (chat_id: C, photo: InputFile))
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ macro_rules! requester_forward {
|
|||
(@method send_audio $body:ident $ty:ident) => {
|
||||
type SendAudio = $ty![SendAudio];
|
||||
|
||||
fn send_audio<C>(&self, chat_id: C, audio: InputFile) -> Self::SendAudio where C: Into<ChatId> {
|
||||
fn send_audio<C>(&self, chat_id: C, audio: InputFile) -> Self::SendAudio where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_audio this (chat_id: C, audio: InputFile))
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ macro_rules! requester_forward {
|
|||
(@method send_document $body:ident $ty:ident) => {
|
||||
type SendDocument = $ty![SendDocument];
|
||||
|
||||
fn send_document<C>(&self, chat_id: C, document: InputFile) -> Self::SendDocument where C: Into<ChatId> {
|
||||
fn send_document<C>(&self, chat_id: C, document: InputFile) -> Self::SendDocument where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_document this (chat_id: C, document: InputFile))
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ macro_rules! requester_forward {
|
|||
(@method send_video $body:ident $ty:ident) => {
|
||||
type SendVideo = $ty![SendVideo];
|
||||
|
||||
fn send_video<C>(&self, chat_id: C, video: InputFile) -> Self::SendVideo where C: Into<ChatId> {
|
||||
fn send_video<C>(&self, chat_id: C, video: InputFile) -> Self::SendVideo where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_video this (chat_id: C, video: InputFile))
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ macro_rules! requester_forward {
|
|||
(@method send_animation $body:ident $ty:ident) => {
|
||||
type SendAnimation = $ty![SendAnimation];
|
||||
|
||||
fn send_animation<C>(&self, chat_id: C, animation: InputFile) -> Self::SendAnimation where C: Into<ChatId> {
|
||||
fn send_animation<C>(&self, chat_id: C, animation: InputFile) -> Self::SendAnimation where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_animation this (chat_id: C, animation: InputFile))
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ macro_rules! requester_forward {
|
|||
(@method send_voice $body:ident $ty:ident) => {
|
||||
type SendVoice = $ty![SendVoice];
|
||||
|
||||
fn send_voice<C>(&self, chat_id: C, voice: InputFile) -> Self::SendVoice where C: Into<ChatId> {
|
||||
fn send_voice<C>(&self, chat_id: C, voice: InputFile) -> Self::SendVoice where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_voice this (chat_id: C, voice: InputFile))
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ macro_rules! requester_forward {
|
|||
(@method send_video_note $body:ident $ty:ident) => {
|
||||
type SendVideoNote = $ty![SendVideoNote];
|
||||
|
||||
fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote where C: Into<ChatId> {
|
||||
fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_video_note this (chat_id: C, video_note: InputFile))
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ macro_rules! requester_forward {
|
|||
(@method send_media_group $body:ident $ty:ident) => {
|
||||
type SendMediaGroup = $ty![SendMediaGroup];
|
||||
|
||||
fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup where C: Into<ChatId>,
|
||||
fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup where C: Into<Recipient>,
|
||||
M: IntoIterator<Item = InputMedia> {
|
||||
let this = self;
|
||||
$body!(send_media_group this (chat_id: C, media: M))
|
||||
|
@ -573,7 +573,7 @@ macro_rules! requester_forward {
|
|||
(@method send_location $body:ident $ty:ident) => {
|
||||
type SendLocation = $ty![SendLocation];
|
||||
|
||||
fn send_location<C>(&self, chat_id: C, latitude: f64, longitude: f64) -> Self::SendLocation where C: Into<ChatId> {
|
||||
fn send_location<C>(&self, chat_id: C, latitude: f64, longitude: f64) -> Self::SendLocation where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_location this (chat_id: C, latitude: f64, longitude: f64))
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ macro_rules! requester_forward {
|
|||
(@method edit_message_live_location $body:ident $ty:ident) => {
|
||||
type EditMessageLiveLocation = $ty![EditMessageLiveLocation];
|
||||
|
||||
fn edit_message_live_location<C>(&self, chat_id: C, message_id: i32, latitude: f64, longitude: f64) -> Self::EditMessageLiveLocation where C: Into<ChatId> {
|
||||
fn edit_message_live_location<C>(&self, chat_id: C, message_id: i32, latitude: f64, longitude: f64) -> Self::EditMessageLiveLocation where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(edit_message_live_location this (chat_id: C, message_id: i32, latitude: f64, longitude: f64))
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ macro_rules! requester_forward {
|
|||
(@method stop_message_live_location $body:ident $ty:ident) => {
|
||||
type StopMessageLiveLocation = $ty![StopMessageLiveLocation];
|
||||
|
||||
fn stop_message_live_location<C>(&self, chat_id: C, message_id: i32, latitude: f64, longitude: f64) -> Self::StopMessageLiveLocation where C: Into<ChatId> {
|
||||
fn stop_message_live_location<C>(&self, chat_id: C, message_id: i32, latitude: f64, longitude: f64) -> Self::StopMessageLiveLocation where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(stop_message_live_location this (chat_id: C, message_id: i32, latitude: f64, longitude: f64))
|
||||
}
|
||||
|
@ -613,7 +613,7 @@ macro_rules! requester_forward {
|
|||
(@method send_venue $body:ident $ty:ident) => {
|
||||
type SendVenue = $ty![SendVenue];
|
||||
|
||||
fn send_venue<C, T, A>(&self, chat_id: C, latitude: f64, longitude: f64, title: T, address: A) -> Self::SendVenue where C: Into<ChatId>,
|
||||
fn send_venue<C, T, A>(&self, chat_id: C, latitude: f64, longitude: f64, title: T, address: A) -> Self::SendVenue where C: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
A: Into<String> {
|
||||
let this = self;
|
||||
|
@ -623,7 +623,7 @@ macro_rules! requester_forward {
|
|||
(@method send_contact $body:ident $ty:ident) => {
|
||||
type SendContact = $ty![SendContact];
|
||||
|
||||
fn send_contact<C, P, F>(&self, chat_id: C, phone_number: P, first_name: F) -> Self::SendContact where C: Into<ChatId>,
|
||||
fn send_contact<C, P, F>(&self, chat_id: C, phone_number: P, first_name: F) -> Self::SendContact where C: Into<Recipient>,
|
||||
P: Into<String>,
|
||||
F: Into<String> {
|
||||
let this = self;
|
||||
|
@ -633,7 +633,7 @@ macro_rules! requester_forward {
|
|||
(@method send_poll $body:ident $ty:ident) => {
|
||||
type SendPoll = $ty![SendPoll];
|
||||
|
||||
fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll where C: Into<ChatId>,
|
||||
fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll where C: Into<Recipient>,
|
||||
Q: Into<String>,
|
||||
O: IntoIterator<Item = String> {
|
||||
let this = self;
|
||||
|
@ -643,7 +643,7 @@ macro_rules! requester_forward {
|
|||
(@method send_dice $body:ident $ty:ident) => {
|
||||
type SendDice = $ty![SendDice];
|
||||
|
||||
fn send_dice<C>(&self, chat_id: C) -> Self::SendDice where C: Into<ChatId> {
|
||||
fn send_dice<C>(&self, chat_id: C) -> Self::SendDice where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_dice this (chat_id: C))
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ macro_rules! requester_forward {
|
|||
(@method send_chat_action $body:ident $ty:ident) => {
|
||||
type SendChatAction = $ty![SendChatAction];
|
||||
|
||||
fn send_chat_action<C>(&self, chat_id: C, action: ChatAction) -> Self::SendChatAction where C: Into<ChatId> {
|
||||
fn send_chat_action<C>(&self, chat_id: C, action: ChatAction) -> Self::SendChatAction where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_chat_action this (chat_id: C, action: ChatAction))
|
||||
}
|
||||
|
@ -659,9 +659,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: i64) -> Self::GetUserProfilePhotos {
|
||||
fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos {
|
||||
let this = self;
|
||||
$body!(get_user_profile_photos this (user_id: i64))
|
||||
$body!(get_user_profile_photos this (user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method get_file $body:ident $ty:ident) => {
|
||||
|
@ -675,72 +675,74 @@ macro_rules! requester_forward {
|
|||
(@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> {
|
||||
fn ban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::BanChatMember where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(ban_chat_member this (chat_id: C, user_id: i64))
|
||||
$body!(ban_chat_member this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method kick_chat_member $body:ident $ty:ident) => {
|
||||
type KickChatMember = $ty![KickChatMember];
|
||||
|
||||
fn kick_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::KickChatMember where C: Into<ChatId> {
|
||||
fn kick_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::KickChatMember where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(kick_chat_member this (chat_id: C, user_id: i64))
|
||||
$body!(kick_chat_member this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method unban_chat_member $body:ident $ty:ident) => {
|
||||
type UnbanChatMember = $ty![UnbanChatMember];
|
||||
|
||||
fn unban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::UnbanChatMember where C: Into<ChatId> {
|
||||
fn unban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::UnbanChatMember where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(unban_chat_member this (chat_id: C, user_id: i64))
|
||||
$body!(unban_chat_member this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method restrict_chat_member $body:ident $ty:ident) => {
|
||||
type RestrictChatMember = $ty![RestrictChatMember];
|
||||
|
||||
fn restrict_chat_member<C>(&self, chat_id: C, user_id: i64, permissions: ChatPermissions) -> Self::RestrictChatMember where C: Into<ChatId> {
|
||||
fn restrict_chat_member<C>(&self, chat_id: C, user_id: UserId, permissions: ChatPermissions) -> Self::RestrictChatMember where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(restrict_chat_member this (chat_id: C, user_id: i64, permissions: ChatPermissions))
|
||||
$body!(restrict_chat_member this (chat_id: C, user_id: UserId, 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: i64) -> Self::PromoteChatMember where C: Into<ChatId> {
|
||||
fn promote_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::PromoteChatMember where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(promote_chat_member this (chat_id: C, user_id: i64))
|
||||
$body!(promote_chat_member this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@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: i64, custom_title: Cu) -> Self::SetChatAdministratorCustomTitle where Ch: Into<ChatId>,
|
||||
fn set_chat_administrator_custom_title<Ch, Cu>(&self, chat_id: Ch, user_id: UserId, custom_title: Cu) -> Self::SetChatAdministratorCustomTitle where Ch: Into<Recipient>,
|
||||
Cu: Into<String> {
|
||||
let this = self;
|
||||
$body!(set_chat_administrator_custom_title this (chat_id: Ch, user_id: i64, custom_title: Cu))
|
||||
$body!(set_chat_administrator_custom_title this (chat_id: Ch, user_id: UserId, custom_title: Cu))
|
||||
}
|
||||
};
|
||||
(@method ban_chat_sender_chat $body:ident $ty:ident) => {
|
||||
type BanChatSenderChat = $ty![BanChatSenderChat];
|
||||
|
||||
fn ban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::BanChatSenderChat where C: Into<ChatId> {
|
||||
fn ban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::BanChatSenderChat where C: Into<Recipient>,
|
||||
S: Into<ChatId> {
|
||||
let this = self;
|
||||
$body!(ban_chat_sender_chat this (chat_id: C, sender_chat_id: i64))
|
||||
$body!(ban_chat_sender_chat this (chat_id: C, sender_chat_id: S))
|
||||
}
|
||||
};
|
||||
(@method unban_chat_sender_chat $body:ident $ty:ident) => {
|
||||
type UnbanChatSenderChat = $ty![UnbanChatSenderChat];
|
||||
|
||||
fn unban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::UnbanChatSenderChat where C: Into<ChatId> {
|
||||
fn unban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::UnbanChatSenderChat where C: Into<Recipient>,
|
||||
S: Into<ChatId> {
|
||||
let this = self;
|
||||
$body!(unban_chat_sender_chat this (chat_id: C, sender_chat_id: i64))
|
||||
$body!(unban_chat_sender_chat this (chat_id: C, sender_chat_id: S))
|
||||
}
|
||||
};
|
||||
(@method set_chat_permissions $body:ident $ty:ident) => {
|
||||
type SetChatPermissions = $ty![SetChatPermissions];
|
||||
|
||||
fn set_chat_permissions<C>(&self, chat_id: C, permissions: ChatPermissions) -> Self::SetChatPermissions where C: Into<ChatId> {
|
||||
fn set_chat_permissions<C>(&self, chat_id: C, permissions: ChatPermissions) -> Self::SetChatPermissions where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(set_chat_permissions this (chat_id: C, permissions: ChatPermissions))
|
||||
}
|
||||
|
@ -748,7 +750,7 @@ macro_rules! requester_forward {
|
|||
(@method export_chat_invite_link $body:ident $ty:ident) => {
|
||||
type ExportChatInviteLink = $ty![ExportChatInviteLink];
|
||||
|
||||
fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink where C: Into<ChatId> {
|
||||
fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(export_chat_invite_link this (chat_id: C))
|
||||
}
|
||||
|
@ -756,7 +758,7 @@ macro_rules! requester_forward {
|
|||
(@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> {
|
||||
fn create_chat_invite_link<C>(&self, chat_id: C) -> Self::CreateChatInviteLink where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(create_chat_invite_link this (chat_id: C))
|
||||
}
|
||||
|
@ -764,7 +766,7 @@ macro_rules! requester_forward {
|
|||
(@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>,
|
||||
fn edit_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::EditChatInviteLink where C: Into<Recipient>,
|
||||
I: Into<String> {
|
||||
let this = self;
|
||||
$body!(edit_chat_invite_link this (chat_id: C, invite_link: I))
|
||||
|
@ -773,7 +775,7 @@ macro_rules! requester_forward {
|
|||
(@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>,
|
||||
fn revoke_chat_invite_link<C, I>(&self, chat_id: C, invite_link: I) -> Self::RevokeChatInviteLink where C: Into<Recipient>,
|
||||
I: Into<String> {
|
||||
let this = self;
|
||||
$body!(revoke_chat_invite_link this (chat_id: C, invite_link: I))
|
||||
|
@ -782,23 +784,23 @@ macro_rules! requester_forward {
|
|||
(@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> {
|
||||
fn approve_chat_join_request<C>(&self, chat_id: C, user_id: UserId) -> Self::ApproveChatJoinRequest where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(approve_chat_join_request this (chat_id: C, user_id: i64))
|
||||
$body!(approve_chat_join_request this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@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> {
|
||||
fn decline_chat_join_request<C>(&self, chat_id: C, user_id: UserId) -> Self::DeclineChatJoinRequest where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(decline_chat_join_request this (chat_id: C, user_id: i64))
|
||||
$body!(decline_chat_join_request this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method set_chat_photo $body:ident $ty:ident) => {
|
||||
type SetChatPhoto = $ty![SetChatPhoto];
|
||||
|
||||
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto where C: Into<ChatId> {
|
||||
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(set_chat_photo this (chat_id: C, photo: InputFile))
|
||||
}
|
||||
|
@ -806,7 +808,7 @@ macro_rules! requester_forward {
|
|||
(@method delete_chat_photo $body:ident $ty:ident) => {
|
||||
type DeleteChatPhoto = $ty![DeleteChatPhoto];
|
||||
|
||||
fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto where C: Into<ChatId> {
|
||||
fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(delete_chat_photo this (chat_id: C))
|
||||
}
|
||||
|
@ -814,7 +816,7 @@ macro_rules! requester_forward {
|
|||
(@method set_chat_title $body:ident $ty:ident) => {
|
||||
type SetChatTitle = $ty![SetChatTitle];
|
||||
|
||||
fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle where C: Into<ChatId>,
|
||||
fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle where C: Into<Recipient>,
|
||||
T: Into<String> {
|
||||
let this = self;
|
||||
$body!(set_chat_title this (chat_id: C, title: T))
|
||||
|
@ -823,7 +825,7 @@ macro_rules! requester_forward {
|
|||
(@method set_chat_description $body:ident $ty:ident) => {
|
||||
type SetChatDescription = $ty![SetChatDescription];
|
||||
|
||||
fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription where C: Into<ChatId> {
|
||||
fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(set_chat_description this (chat_id: C))
|
||||
}
|
||||
|
@ -831,7 +833,7 @@ macro_rules! requester_forward {
|
|||
(@method pin_chat_message $body:ident $ty:ident) => {
|
||||
type PinChatMessage = $ty![PinChatMessage];
|
||||
|
||||
fn pin_chat_message<C>(&self, chat_id: C, message_id: i32) -> Self::PinChatMessage where C: Into<ChatId> {
|
||||
fn pin_chat_message<C>(&self, chat_id: C, message_id: i32) -> Self::PinChatMessage where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(pin_chat_message this (chat_id: C, message_id: i32))
|
||||
}
|
||||
|
@ -839,7 +841,7 @@ macro_rules! requester_forward {
|
|||
(@method unpin_chat_message $body:ident $ty:ident) => {
|
||||
type UnpinChatMessage = $ty![UnpinChatMessage];
|
||||
|
||||
fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage where C: Into<ChatId> {
|
||||
fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(unpin_chat_message this (chat_id: C))
|
||||
}
|
||||
|
@ -847,7 +849,7 @@ macro_rules! requester_forward {
|
|||
(@method unpin_all_chat_messages $body:ident $ty:ident) => {
|
||||
type UnpinAllChatMessages = $ty![UnpinAllChatMessages];
|
||||
|
||||
fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages where C: Into<ChatId> {
|
||||
fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(unpin_all_chat_messages this (chat_id: C))
|
||||
}
|
||||
|
@ -855,7 +857,7 @@ macro_rules! requester_forward {
|
|||
(@method leave_chat $body:ident $ty:ident) => {
|
||||
type LeaveChat = $ty![LeaveChat];
|
||||
|
||||
fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat where C: Into<ChatId> {
|
||||
fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(leave_chat this (chat_id: C))
|
||||
}
|
||||
|
@ -863,7 +865,7 @@ macro_rules! requester_forward {
|
|||
(@method get_chat $body:ident $ty:ident) => {
|
||||
type GetChat = $ty![GetChat];
|
||||
|
||||
fn get_chat<C>(&self, chat_id: C) -> Self::GetChat where C: Into<ChatId> {
|
||||
fn get_chat<C>(&self, chat_id: C) -> Self::GetChat where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(get_chat this (chat_id: C))
|
||||
}
|
||||
|
@ -871,7 +873,7 @@ macro_rules! requester_forward {
|
|||
(@method get_chat_administrators $body:ident $ty:ident) => {
|
||||
type GetChatAdministrators = $ty![GetChatAdministrators];
|
||||
|
||||
fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators where C: Into<ChatId> {
|
||||
fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(get_chat_administrators this (chat_id: C))
|
||||
}
|
||||
|
@ -879,7 +881,7 @@ macro_rules! requester_forward {
|
|||
(@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> {
|
||||
fn get_chat_member_count<C>(&self, chat_id: C) -> Self::GetChatMemberCount where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(get_chat_member_count this (chat_id: C))
|
||||
}
|
||||
|
@ -887,7 +889,7 @@ macro_rules! requester_forward {
|
|||
(@method get_chat_members_count $body:ident $ty:ident) => {
|
||||
type GetChatMembersCount = $ty![GetChatMembersCount];
|
||||
|
||||
fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount where C: Into<ChatId> {
|
||||
fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(get_chat_members_count this (chat_id: C))
|
||||
}
|
||||
|
@ -895,15 +897,15 @@ 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: i64) -> Self::GetChatMember where C: Into<ChatId> {
|
||||
fn get_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::GetChatMember where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(get_chat_member this (chat_id: C, user_id: i64))
|
||||
$body!(get_chat_member this (chat_id: C, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method set_chat_sticker_set $body:ident $ty:ident) => {
|
||||
type SetChatStickerSet = $ty![SetChatStickerSet];
|
||||
|
||||
fn set_chat_sticker_set<C, S>(&self, chat_id: C, sticker_set_name: S) -> Self::SetChatStickerSet where C: Into<ChatId>,
|
||||
fn set_chat_sticker_set<C, S>(&self, chat_id: C, sticker_set_name: S) -> Self::SetChatStickerSet where C: Into<Recipient>,
|
||||
S: Into<String> {
|
||||
let this = self;
|
||||
$body!(set_chat_sticker_set this (chat_id: C, sticker_set_name: S))
|
||||
|
@ -912,7 +914,7 @@ macro_rules! requester_forward {
|
|||
(@method delete_chat_sticker_set $body:ident $ty:ident) => {
|
||||
type DeleteChatStickerSet = $ty![DeleteChatStickerSet];
|
||||
|
||||
fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet where C: Into<ChatId> {
|
||||
fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(delete_chat_sticker_set this (chat_id: C))
|
||||
}
|
||||
|
@ -961,7 +963,7 @@ macro_rules! requester_forward {
|
|||
(@method edit_message_text $body:ident $ty:ident) => {
|
||||
type EditMessageText = $ty![EditMessageText];
|
||||
|
||||
fn edit_message_text<C, T>(&self, chat_id: C, message_id: i32, text: T) -> Self::EditMessageText where C: Into<ChatId>,
|
||||
fn edit_message_text<C, T>(&self, chat_id: C, message_id: i32, text: T) -> Self::EditMessageText where C: Into<Recipient>,
|
||||
T: Into<String> {
|
||||
let this = self;
|
||||
$body!(edit_message_text this (chat_id: C, message_id: i32, text: T))
|
||||
|
@ -979,7 +981,7 @@ macro_rules! requester_forward {
|
|||
(@method edit_message_caption $body:ident $ty:ident) => {
|
||||
type EditMessageCaption = $ty![EditMessageCaption];
|
||||
|
||||
fn edit_message_caption<C>(&self, chat_id: C, message_id: i32) -> Self::EditMessageCaption where C: Into<ChatId> {
|
||||
fn edit_message_caption<C>(&self, chat_id: C, message_id: i32) -> Self::EditMessageCaption where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(edit_message_caption this (chat_id: C, message_id: i32))
|
||||
}
|
||||
|
@ -995,7 +997,7 @@ macro_rules! requester_forward {
|
|||
(@method edit_message_media $body:ident $ty:ident) => {
|
||||
type EditMessageMedia = $ty![EditMessageMedia];
|
||||
|
||||
fn edit_message_media<C>(&self, chat_id: C, message_id: i32, media: InputMedia) -> Self::EditMessageMedia where C: Into<ChatId> {
|
||||
fn edit_message_media<C>(&self, chat_id: C, message_id: i32, media: InputMedia) -> Self::EditMessageMedia where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(edit_message_media this (chat_id: C, message_id: i32, media: InputMedia))
|
||||
}
|
||||
|
@ -1011,7 +1013,7 @@ macro_rules! requester_forward {
|
|||
(@method edit_message_reply_markup $body:ident $ty:ident) => {
|
||||
type EditMessageReplyMarkup = $ty![EditMessageReplyMarkup];
|
||||
|
||||
fn edit_message_reply_markup<C>(&self, chat_id: C, message_id: i32) -> Self::EditMessageReplyMarkup where C: Into<ChatId> {
|
||||
fn edit_message_reply_markup<C>(&self, chat_id: C, message_id: i32) -> Self::EditMessageReplyMarkup where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(edit_message_reply_markup this (chat_id: C, message_id: i32))
|
||||
}
|
||||
|
@ -1027,7 +1029,7 @@ macro_rules! requester_forward {
|
|||
(@method stop_poll $body:ident $ty:ident) => {
|
||||
type StopPoll = $ty![StopPoll];
|
||||
|
||||
fn stop_poll<C>(&self, chat_id: C, message_id: i32) -> Self::StopPoll where C: Into<ChatId> {
|
||||
fn stop_poll<C>(&self, chat_id: C, message_id: i32) -> Self::StopPoll where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(stop_poll this (chat_id: C, message_id: i32))
|
||||
}
|
||||
|
@ -1035,7 +1037,7 @@ macro_rules! requester_forward {
|
|||
(@method delete_message $body:ident $ty:ident) => {
|
||||
type DeleteMessage = $ty![DeleteMessage];
|
||||
|
||||
fn delete_message<C>(&self, chat_id: C, message_id: i32) -> Self::DeleteMessage where C: Into<ChatId> {
|
||||
fn delete_message<C>(&self, chat_id: C, message_id: i32) -> Self::DeleteMessage where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(delete_message this (chat_id: C, message_id: i32))
|
||||
}
|
||||
|
@ -1043,7 +1045,7 @@ macro_rules! requester_forward {
|
|||
(@method send_sticker $body:ident $ty:ident) => {
|
||||
type SendSticker = $ty![SendSticker];
|
||||
|
||||
fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker where C: Into<ChatId> {
|
||||
fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(send_sticker this (chat_id: C, sticker: InputFile))
|
||||
}
|
||||
|
@ -1059,28 +1061,28 @@ macro_rules! requester_forward {
|
|||
(@method upload_sticker_file $body:ident $ty:ident) => {
|
||||
type UploadStickerFile = $ty![UploadStickerFile];
|
||||
|
||||
fn upload_sticker_file(&self, user_id: i64, png_sticker: InputFile) -> Self::UploadStickerFile {
|
||||
fn upload_sticker_file(&self, user_id: UserId, png_sticker: InputFile) -> Self::UploadStickerFile {
|
||||
let this = self;
|
||||
$body!(upload_sticker_file this (user_id: i64, png_sticker: InputFile))
|
||||
$body!(upload_sticker_file this (user_id: UserId, 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: i64, 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: UserId, 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: i64, name: N, title: T, sticker: InputSticker, emojis: E))
|
||||
$body!(create_new_sticker_set this (user_id: UserId, 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: i64, name: N, sticker: InputSticker, emojis: E) -> Self::AddStickerToSet where N: Into<String>,
|
||||
fn add_sticker_to_set<N, E>(&self, user_id: UserId, 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: i64, name: N, sticker: InputSticker, emojis: E))
|
||||
$body!(add_sticker_to_set this (user_id: UserId, name: N, sticker: InputSticker, emojis: E))
|
||||
}
|
||||
};
|
||||
(@method set_sticker_position_in_set $body:ident $ty:ident) => {
|
||||
|
@ -1102,15 +1104,15 @@ 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: i64) -> Self::SetStickerSetThumb where N: Into<String> {
|
||||
fn set_sticker_set_thumb<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumb where N: Into<String> {
|
||||
let this = self;
|
||||
$body!(set_sticker_set_thumb this (name: N, user_id: i64))
|
||||
$body!(set_sticker_set_thumb this (name: N, user_id: UserId))
|
||||
}
|
||||
};
|
||||
(@method send_invoice $body:ident $ty:ident) => {
|
||||
type SendInvoice = $ty![SendInvoice];
|
||||
|
||||
fn send_invoice<Ch, T, D, Pa, P, C, Pri>(&self, chat_id: Ch, title: T, description: D, payload: Pa, provider_token: P, currency: C, prices: Pri) -> Self::SendInvoice where Ch: Into<ChatId>,
|
||||
fn send_invoice<Ch, T, D, Pa, P, C, Pri>(&self, chat_id: Ch, title: T, description: D, payload: Pa, provider_token: P, currency: C, prices: Pri) -> Self::SendInvoice where Ch: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
D: Into<String>,
|
||||
Pa: Into<String>,
|
||||
|
@ -1140,9 +1142,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: i64, errors: E) -> Self::SetPassportDataErrors where E: IntoIterator<Item = PassportElementError> {
|
||||
fn set_passport_data_errors<E>(&self, user_id: UserId, errors: E) -> Self::SetPassportDataErrors where E: IntoIterator<Item = PassportElementError> {
|
||||
let this = self;
|
||||
$body!(set_passport_data_errors this (user_id: i64, errors: E))
|
||||
$body!(set_passport_data_errors this (user_id: UserId, errors: E))
|
||||
}
|
||||
};
|
||||
(@method send_game $body:ident $ty:ident) => {
|
||||
|
@ -1156,25 +1158,25 @@ macro_rules! requester_forward {
|
|||
(@method set_game_score $body:ident $ty:ident) => {
|
||||
type SetGameScore = $ty![SetGameScore];
|
||||
|
||||
fn set_game_score(&self, user_id: i64, score: u64, chat_id: u32, message_id: i64) -> Self::SetGameScore {
|
||||
fn set_game_score(&self, user_id: UserId, score: u64, chat_id: u32, message_id: i64) -> Self::SetGameScore {
|
||||
let this = self;
|
||||
$body!(set_game_score this (user_id: i64, score: u64, chat_id: u32, message_id: i64))
|
||||
$body!(set_game_score this (user_id: UserId, 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: i64, score: u64, inline_message_id: I) -> Self::SetGameScoreInline where I: Into<String> {
|
||||
fn set_game_score_inline<I>(&self, user_id: UserId, score: u64, inline_message_id: I) -> Self::SetGameScoreInline where I: Into<String> {
|
||||
let this = self;
|
||||
$body!(set_game_score_inline this (user_id: i64, score: u64, inline_message_id: I))
|
||||
$body!(set_game_score_inline this (user_id: UserId, 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: i64, target: T) -> Self::GetGameHighScores where T: Into<TargetMessage> {
|
||||
fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores where T: Into<TargetMessage> {
|
||||
let this = self;
|
||||
$body!(get_game_high_scores this (user_id: i64, target: T))
|
||||
$body!(get_game_high_scores this (user_id: UserId, target: T))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputSticker, MaskPosition, True};
|
||||
use crate::types::{InputSticker, MaskPosition, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = sticker]
|
||||
|
@ -17,7 +17,7 @@ impl_payload! {
|
|||
pub AddStickerToSet (AddStickerToSetSetters) => True {
|
||||
required {
|
||||
/// User identifier of sticker file owner
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// 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 »]
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
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.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
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.
|
||||
|
@ -19,9 +19,9 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
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
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{ChatId, Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to ban a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
pub BanChatSenderChat (BanChatSenderChatSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target sender chat
|
||||
pub sender_chat_id: i64,
|
||||
pub sender_chat_id: ChatId [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, MessageEntity, MessageId, ParseMode, ReplyMarkup};
|
||||
use crate::types::{MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to copy messages of any kind. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the [`MessageId`] of the sent message on success.
|
||||
|
@ -18,9 +18,9 @@ impl_payload! {
|
|||
pub CopyMessage (CopyMessageSetters) => MessageId {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the chat where the original message was sent (or channel username in the format `@channelusername`)
|
||||
pub from_chat_id: ChatId [into],
|
||||
pub from_chat_id: Recipient [into],
|
||||
/// Message identifier in the chat specified in _from\_chat\_id_
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, ChatInviteLink};
|
||||
use crate::types::{ChatInviteLink, Recipient};
|
||||
|
||||
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.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
optional {
|
||||
/// Invite link name; 0-32 characters
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputSticker, MaskPosition, True};
|
||||
use crate::types::{InputSticker, MaskPosition, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = sticker]
|
||||
|
@ -17,7 +17,7 @@ impl_payload! {
|
|||
pub CreateNewStickerSet (CreateNewStickerSetSetters) => True {
|
||||
required {
|
||||
/// User identifier of sticker file owner
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// 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
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
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.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub DeleteChatPhoto (DeleteChatPhotoSetters) => String {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field `can_set_sticker_set` optionally returned in [`GetChat`] requests to check if the bot can use this method. Returns _True_ on success.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub DeleteChatStickerSet (DeleteChatStickerSetSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to delete a message, including service messages, with the following limitations:
|
||||
|
@ -25,7 +25,7 @@ impl_payload! {
|
|||
pub DeleteMessage (DeleteMessageSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to delete
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
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.
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
/// The invite link to edit
|
||||
pub invite_link: String [into],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InlineKeyboardMarkup, Message, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, Message, MessageEntity, ParseMode, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit captions of messages. On success, the edited Message is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub EditMessageCaption (EditMessageCaptionSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, ReplyMarkup};
|
||||
use crate::types::{Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to [`StopMessageLiveLocation`]. On success, the edited Message is returned.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
pub EditMessageLiveLocation (EditMessageLiveLocationSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
/// Latitude of new location
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InlineKeyboardMarkup, InputMedia, Message};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMedia, Message, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit animation, audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, the edited Message is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub EditMessageMedia (EditMessageMediaSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
/// A JSON-serialized object for a new media content of the message
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InlineKeyboardMarkup, Message};
|
||||
use crate::types::{InlineKeyboardMarkup, Message, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit only the reply markup of messages. On success, the edited Message is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub EditMessageReplyMarkup (EditMessageReplyMarkupSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InlineKeyboardMarkup, Message, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, Message, MessageEntity, ParseMode, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit text and [games] messages. On success, the edited Message is returned.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
pub EditMessageText (EditMessageTextSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
/// New text of the message, 1-4096 characters after entities parsing
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as String on success.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub ExportChatInviteLink (ExportChatInviteLinkSetters) => String {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message};
|
||||
use crate::types::{Message, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to forward messages of any kind. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,9 +18,9 @@ impl_payload! {
|
|||
pub ForwardMessage (ForwardMessageSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the chat where the original message was sent (or channel username in the format `@channelusername`)
|
||||
pub from_chat_id: ChatId [into],
|
||||
pub from_chat_id: Recipient [into],
|
||||
/// Message identifier in the chat specified in _from\_chat\_id_
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Chat, ChatId};
|
||||
use crate::types::{Chat, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a [`Chat`] object on success.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub GetChat (GetChatSetters) => Chat {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, ChatMember};
|
||||
use crate::types::{ChatMember, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get a list of administrators in a chat. On success, returns an Array of [`ChatMember`] objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub GetChatAdministrators (GetChatAdministratorsSetters) => Vec<ChatMember> {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, ChatMember};
|
||||
use crate::types::{ChatMember, Recipient, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get information about a member of a chat. Returns a [`ChatMember`] object on success.
|
||||
|
@ -18,9 +18,9 @@ impl_payload! {
|
|||
pub GetChatMember (GetChatMemberSetters) => ChatMember {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get the number of members in a chat. Returns _Int_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get the number of members in a chat. Returns _Int_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub GetChatMembersCount (GetChatMembersCountSetters) => u32 {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{TargetMessage, True};
|
||||
use crate::types::{TargetMessage, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of [`GameHighScore`] objects.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
pub GetGameHighScores (GetGameHighScoresSetters) => True {
|
||||
required {
|
||||
/// User identifier
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// Target message
|
||||
#[serde(flatten)]
|
||||
pub target: TargetMessage [into],
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::UserProfilePhotos;
|
||||
use crate::types::{UserId, UserProfilePhotos};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to get a list of profile pictures for a user. Returns a [`UserProfilePhotos`] object.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub GetUserProfilePhotos (GetUserProfilePhotosSetters) => UserProfilePhotos {
|
||||
required {
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
optional {
|
||||
/// Sequential number of the first photo to be returned. By default, all photos are returned.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group 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.
|
||||
|
@ -19,9 +19,9 @@ impl_payload! {
|
|||
pub KickChatMember (KickChatMemberSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
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
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method for your bot to leave a group, supergroup or channel. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub LeaveChat (LeaveChatSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub PinChatMessage (PinChatMessageSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of a message to pin
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass _False_ for all boolean parameters to demote a user. Returns _True_ on success.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
pub PromoteChatMember (PromoteChatMemberSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
optional {
|
||||
/// Pass True, if the administrator's presence in the chat is hidden
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, ChatPermissions, True};
|
||||
use crate::types::{ChatPermissions, Recipient, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass _True_ for all permissions to lift restrictions from a user. Returns _True_ on success.
|
||||
|
@ -17,9 +17,9 @@ impl_payload! {
|
|||
pub RestrictChatMember (RestrictChatMemberSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// A JSON-serialized object for new user permissions
|
||||
pub permissions: ChatPermissions,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
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.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
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],
|
||||
pub chat_id: Recipient [into],
|
||||
/// The invite link to revoke
|
||||
pub invite_link: String [into],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = animation, thumb]
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
pub SendAnimation (SendAnimationSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Animation to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = audio, thumb]
|
||||
|
@ -22,7 +22,7 @@ impl_payload! {
|
|||
pub SendAudio (SendAudioSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatAction, ChatId, True};
|
||||
use crate::types::{ChatAction, Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
|
||||
|
@ -22,7 +22,7 @@ impl_payload! {
|
|||
pub SendChatAction (SendChatActionSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [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], choose_sticker for [stickers], find_location for [location data], record_video_note or upload_video_note for [video notes].
|
||||
///
|
||||
/// [text messages]: crate::payloads::SendMessage
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, ReplyMarkup};
|
||||
use crate::types::{Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send phone contacts. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SendContact (SendContactSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Contact's phone number
|
||||
pub phone_number: String [into],
|
||||
/// Contact's first name
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, DiceEmoji, Message, ReplyMarkup};
|
||||
use crate::types::{DiceEmoji, Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send an animated emoji that will display a random value. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SendDice (SendDiceSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [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 “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = document, thumb]
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
pub SendDocument (SendDocumentSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), 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 »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use serde::Serialize;
|
||||
use url::Url;
|
||||
|
||||
use crate::types::{ChatId, InlineKeyboardMarkup, LabeledPrice, Message};
|
||||
use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send invoices. On success, the sent [`Message`] is returned.
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
pub SendInvoice (SendInvoiceSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target private chat
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Product name, 1-32 characters
|
||||
pub title: String [into],
|
||||
/// Product description, 1-255 characters
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, ReplyMarkup};
|
||||
use crate::types::{Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send point on the map. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SendLocation (SendLocationSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Latitude of the location
|
||||
pub latitude: f64,
|
||||
/// Longitude of the location
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputMedia, Message};
|
||||
use crate::types::{InputMedia, Message, Recipient};
|
||||
|
||||
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 [`Message`]s that were sent is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SendMediaGroup (SendMediaGroupSetters) => Vec<Message> {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// A JSON-serialized array describing messages to be sent, must include 2-10 items
|
||||
pub media: Vec<InputMedia> [collect],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send text messages. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SendMessage (SendMessageSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Text of the message to be sent, 1-4096 characters after entities parsing
|
||||
pub text: String [into],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = photo]
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
pub SendPhoto (SendPhotoSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, MessageEntity, ParseMode, PollType, ReplyMarkup};
|
||||
use crate::types::{Message, MessageEntity, ParseMode, PollType, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send phone contacts. On success, the sent [`Message`] is returned.
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
pub SendPoll (SendPollSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Poll question, 1-300 characters
|
||||
pub question: String [into],
|
||||
/// A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = sticker]
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
pub SendSticker (SendStickerSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Sticker to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, ReplyMarkup};
|
||||
use crate::types::{Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send information about a venue. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SendVenue (SendVenueSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Latitude of new location
|
||||
pub latitude: f64,
|
||||
/// Longitude of new location
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = video, thumb]
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
pub SendVideo (SendVideoSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = video_note, thumb]
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
pub SendVideoNote (SendVideoNoteSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. [More info on Sending Files »]. Sending video notes by a URL is currently unsupported
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, Message, MessageEntity, ParseMode, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageEntity, ParseMode, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = voice]
|
||||
|
@ -21,7 +21,7 @@ impl_payload! {
|
|||
pub SendVoice (SendVoiceSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns _True_on success.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
pub SetChatAdministratorCustomTitle (SetChatAdministratorCustomTitleSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// New custom title for the administrator; 0-16 characters, emoji are not allowed
|
||||
pub custom_title: String [into],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub SetChatDescription (SetChatDescriptionSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
optional {
|
||||
/// New chat description, 0-255 characters
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, ChatPermissions, True};
|
||||
use crate::types::{ChatPermissions, Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the _can_restrict_members_ admin rights. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub SetChatPermissions (SetChatPermissionsSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// New default chat permissions
|
||||
pub permissions: ChatPermissions,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InputFile, True};
|
||||
use crate::types::{InputFile, Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = photo]
|
||||
|
@ -17,7 +17,7 @@ impl_payload! {
|
|||
pub SetChatPhoto (SetChatPhotoSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// New chat photo, uploaded using multipart/form-data
|
||||
pub photo: InputFile,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field _can\_set\_sticker\_set_ optionally returned in getChat requests to check if the bot can use this method. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub SetChatStickerSet (SetChatStickerSetSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Name of the sticker set to be set as the group sticker set
|
||||
pub sticker_set_name: String [into],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub SetChatTitle (SetChatTitleSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// New chat title, 1-255 characters
|
||||
pub title: String [into],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::Message;
|
||||
use crate::types::{Message, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to set the score of the specified user in a game. On success, returns the edited [`Message`]. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
pub SetGameScore (SetGameScoreSetters) => Message {
|
||||
required {
|
||||
/// User identifier
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// New score
|
||||
pub score: u64,
|
||||
/// Unique identifier for the target chat
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::Message;
|
||||
use crate::types::{Message, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to set the score of the specified user in a game. On success, returns _True_. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SetGameScoreInline (SetGameScoreInlineSetters) => Message {
|
||||
required {
|
||||
/// User identifier
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// New score
|
||||
pub score: u64,
|
||||
/// Identifier of the inline message
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{PassportElementError, True};
|
||||
use crate::types::{PassportElementError, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns _True_ on success.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
pub SetPassportDataErrors (SetPassportDataErrorsSetters) => True {
|
||||
required {
|
||||
/// User identifier
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// A JSON-serialized array describing the errors
|
||||
pub errors: Vec<PassportElementError> [collect],
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputFile, True};
|
||||
use crate::types::{InputFile, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = thumb]
|
||||
|
@ -19,7 +19,7 @@ impl_payload! {
|
|||
/// Name of the sticker set
|
||||
pub name: String [into],
|
||||
/// User identifier of sticker file owner
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
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.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, Message, ReplyMarkup};
|
||||
use crate::types::{Message, Recipient, ReplyMarkup};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to [`StopMessageLiveLocation`]. On success, the edited Message is returned.
|
||||
|
@ -21,7 +21,7 @@ impl_payload! {
|
|||
pub StopMessageLiveLocation (StopMessageLiveLocationSetters) => Message {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
/// Latitude of new location
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, InlineKeyboardMarkup, Poll};
|
||||
use crate::types::{InlineKeyboardMarkup, Poll, Recipient};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub StopPoll (StopPollSetters) => Poll {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`).
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Identifier of the message to edit
|
||||
pub message_id: i32,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True, UserId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to unban a previously kicked user in a supergroup or channel. The user will **not** return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be **removed** from the chat. If you don't want this, use the parameter _only\_if\_banned_. Returns _True_ on success.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
pub UnbanChatMember (UnbanChatMemberSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target user
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
}
|
||||
optional {
|
||||
/// Do nothing if the user is not banned
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{ChatId, Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights.
|
||||
|
@ -16,9 +16,9 @@ impl_payload! {
|
|||
pub UnbanChatSenderChat (UnbanChatSenderChatSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier of the target sender chat
|
||||
pub sender_chat_id: i64,
|
||||
pub sender_chat_id: ChatId [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub UnpinAllChatMessages (UnpinAllChatMessagesSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::types::{Recipient, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns _True_ on success.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
pub UnpinChatMessage (UnpinChatMessageSetters) => True {
|
||||
required {
|
||||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: ChatId [into],
|
||||
pub chat_id: Recipient [into],
|
||||
}
|
||||
optional {
|
||||
/// Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// [`schema`]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{File, InputFile};
|
||||
use crate::types::{File, InputFile, UserId};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = png_sticker]
|
||||
|
@ -17,7 +17,7 @@ impl_payload! {
|
|||
pub UploadStickerFile (UploadStickerFileSetters) => File {
|
||||
required {
|
||||
/// User identifier of sticker file owner
|
||||
pub user_id: i64,
|
||||
pub user_id: UserId,
|
||||
/// 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
|
||||
|
|
|
@ -75,12 +75,12 @@ pub trait Request: HasPayload {
|
|||
/// ## Examples
|
||||
/// ```
|
||||
/// # async {
|
||||
/// use teloxide_core::{prelude::*, requests::Request, Bot};
|
||||
/// use teloxide_core::{prelude::*, requests::Request, types::ChatId, Bot};
|
||||
///
|
||||
/// let bot = Bot::new("TOKEN");
|
||||
/// # let chat_ids = vec![1i64, 2, 3, 4].into_iter().map(Into::into);
|
||||
/// # let chat_ids = vec![1i64, 2, 3, 4].into_iter().map(ChatId).map(Into::into).collect::<Vec<_>>();
|
||||
///
|
||||
/// let mut req = bot.send_message(0, "Hi there!");
|
||||
/// let mut req = bot.send_message(ChatId(0xAAAAAAAA), "Hi there!");
|
||||
/// for chat_id in chat_ids {
|
||||
/// req.chat_id = chat_id;
|
||||
/// req.send_ref().await.unwrap();
|
||||
|
|
|
@ -6,10 +6,7 @@ use url::Url;
|
|||
use crate::{
|
||||
payloads::{GetMe, SendMessage, *},
|
||||
requests::Request,
|
||||
types::{
|
||||
BotCommand, ChatAction, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
|
||||
InputSticker, LabeledPrice, PassportElementError, TargetMessage,
|
||||
},
|
||||
types::*,
|
||||
};
|
||||
|
||||
/// Methods for building requests.
|
||||
|
@ -22,27 +19,35 @@ use crate::{
|
|||
///
|
||||
/// ```
|
||||
/// # async {
|
||||
/// use teloxide_core::{prelude::*, types::ParseMode};
|
||||
/// # let chat_id = ChatId(-1);
|
||||
/// use teloxide_core::{
|
||||
/// prelude::*,
|
||||
/// types::{ChatId, ParseMode},
|
||||
/// };
|
||||
///
|
||||
/// // Bot implements `Requester`
|
||||
/// let bot = Bot::new("TOKEN");
|
||||
///
|
||||
/// // Required parameters are supplied to the `Requester` methods:
|
||||
/// bot.send_message(0, "<b>Text</b>")
|
||||
/// bot.send_message(chat_id, "<b>Text</b>")
|
||||
/// // Optional parameters can be supplied by calling setters
|
||||
/// .parse_mode(ParseMode::Html)
|
||||
/// // To send request to telegram you need to call `.send()` and await the resulting future
|
||||
/// .send()
|
||||
/// .await?;
|
||||
/// # Ok::<_, teloxide_core::RequestError>(()) };
|
||||
/// # Ok::<_, teloxide_core::RequestError>(())
|
||||
/// # };
|
||||
/// ```
|
||||
///
|
||||
/// Using `Requester` in a generic context:
|
||||
///
|
||||
/// ```
|
||||
/// use teloxide_core::{prelude::*, types::Message};
|
||||
/// use teloxide_core::{
|
||||
/// prelude::*,
|
||||
/// types::{ChatId, Message},
|
||||
/// };
|
||||
///
|
||||
/// async fn send_hi<R>(bot: R, chat: i64) -> Message
|
||||
/// async fn send_hi<R>(bot: R, chat: ChatId) -> Message
|
||||
/// where
|
||||
/// R: Requester,
|
||||
/// {
|
||||
|
@ -103,7 +108,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SendMessage`].
|
||||
fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>;
|
||||
|
||||
type ForwardMessage: Request<Payload = ForwardMessage, Err = Self::Err>;
|
||||
|
@ -116,72 +121,72 @@ pub trait Requester {
|
|||
message_id: i32,
|
||||
) -> Self::ForwardMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
F: Into<ChatId>;
|
||||
C: Into<Recipient>,
|
||||
F: Into<Recipient>;
|
||||
|
||||
type CopyMessage: Request<Payload = CopyMessage, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`CopyMessage`].
|
||||
fn copy_message<C, F>(&self, chat_id: C, from_chat_id: F, message_id: i32) -> Self::CopyMessage
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
F: Into<ChatId>;
|
||||
C: Into<Recipient>,
|
||||
F: Into<Recipient>;
|
||||
|
||||
type SendPhoto: Request<Payload = SendPhoto, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendPhoto`].
|
||||
fn send_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SendPhoto
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendAudio: Request<Payload = SendAudio, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendAudio`].
|
||||
fn send_audio<C>(&self, chat_id: C, audio: InputFile) -> Self::SendAudio
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendDocument: Request<Payload = SendDocument, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendDocument`].
|
||||
fn send_document<C>(&self, chat_id: C, document: InputFile) -> Self::SendDocument
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendVideo: Request<Payload = SendVideo, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendVideo`].
|
||||
fn send_video<C>(&self, chat_id: C, video: InputFile) -> Self::SendVideo
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendAnimation: Request<Payload = SendAnimation, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendAnimation`].
|
||||
fn send_animation<C>(&self, chat_id: C, animation: InputFile) -> Self::SendAnimation
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendVoice: Request<Payload = SendVoice, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendVoice`].
|
||||
fn send_voice<C>(&self, chat_id: C, voice: InputFile) -> Self::SendVoice
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendVideoNote: Request<Payload = SendVideoNote, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendVideoNote`].
|
||||
fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendMediaGroup: Request<Payload = SendMediaGroup, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendMediaGroup`].
|
||||
fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
M: IntoIterator<Item = InputMedia>;
|
||||
|
||||
type SendLocation: Request<Payload = SendLocation, Err = Self::Err>;
|
||||
|
@ -189,7 +194,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SendLocation`].
|
||||
fn send_location<C>(&self, chat_id: C, latitude: f64, longitude: f64) -> Self::SendLocation
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type EditMessageLiveLocation: Request<Payload = EditMessageLiveLocation, Err = Self::Err>;
|
||||
|
||||
|
@ -202,7 +207,7 @@ pub trait Requester {
|
|||
longitude: f64,
|
||||
) -> Self::EditMessageLiveLocation
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type EditMessageLiveLocationInline: Request<
|
||||
Payload = EditMessageLiveLocationInline,
|
||||
|
@ -230,7 +235,7 @@ pub trait Requester {
|
|||
longitude: f64,
|
||||
) -> Self::StopMessageLiveLocation
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type StopMessageLiveLocationInline: Request<
|
||||
Payload = StopMessageLiveLocationInline,
|
||||
|
@ -259,7 +264,7 @@ pub trait Requester {
|
|||
address: A,
|
||||
) -> Self::SendVenue
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
A: Into<String>;
|
||||
|
||||
|
@ -273,7 +278,7 @@ pub trait Requester {
|
|||
first_name: F,
|
||||
) -> Self::SendContact
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
P: Into<String>,
|
||||
F: Into<String>;
|
||||
|
||||
|
@ -282,7 +287,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SendPoll`].
|
||||
fn send_poll<C, Q, O>(&self, chat_id: C, question: Q, options: O) -> Self::SendPoll
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
Q: Into<String>,
|
||||
O: IntoIterator<Item = String>;
|
||||
|
||||
|
@ -291,19 +296,19 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SendDice`].
|
||||
fn send_dice<C>(&self, chat_id: C) -> Self::SendDice
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendChatAction: Request<Payload = SendChatAction, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendChatAction`].
|
||||
fn send_chat_action<C>(&self, chat_id: C, action: ChatAction) -> Self::SendChatAction
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetUserProfilePhotos: Request<Payload = GetUserProfilePhotos, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetUserProfilePhotos`].
|
||||
fn get_user_profile_photos(&self, user_id: i64) -> Self::GetUserProfilePhotos;
|
||||
fn get_user_profile_photos(&self, user_id: UserId) -> Self::GetUserProfilePhotos;
|
||||
|
||||
type GetFile: Request<Payload = GetFile, Err = Self::Err>;
|
||||
|
||||
|
@ -315,23 +320,23 @@ pub trait Requester {
|
|||
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
|
||||
fn ban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::BanChatMember
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type KickChatMember: Request<Payload = KickChatMember, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`KickChatMember`].
|
||||
fn kick_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::KickChatMember
|
||||
fn kick_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::KickChatMember
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type UnbanChatMember: Request<Payload = UnbanChatMember, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`UnbanChatMember`].
|
||||
fn unban_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::UnbanChatMember
|
||||
fn unban_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::UnbanChatMember
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type RestrictChatMember: Request<Payload = RestrictChatMember, Err = Self::Err>;
|
||||
|
||||
|
@ -339,18 +344,18 @@ pub trait Requester {
|
|||
fn restrict_chat_member<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
permissions: ChatPermissions,
|
||||
) -> Self::RestrictChatMember
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type PromoteChatMember: Request<Payload = PromoteChatMember, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`PromoteChatMember`].
|
||||
fn promote_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::PromoteChatMember
|
||||
fn promote_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::PromoteChatMember
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SetChatAdministratorCustomTitle: Request<
|
||||
Payload = SetChatAdministratorCustomTitle,
|
||||
|
@ -361,30 +366,32 @@ pub trait Requester {
|
|||
fn set_chat_administrator_custom_title<Ch, Cu>(
|
||||
&self,
|
||||
chat_id: Ch,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
custom_title: Cu,
|
||||
) -> Self::SetChatAdministratorCustomTitle
|
||||
where
|
||||
Ch: Into<ChatId>,
|
||||
Ch: Into<Recipient>,
|
||||
Cu: Into<String>;
|
||||
|
||||
type BanChatSenderChat: Request<Payload = BanChatSenderChat, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`BanChatSenderChat`].
|
||||
fn ban_chat_sender_chat<C>(&self, chat_id: C, sender_chat_id: i64) -> Self::BanChatSenderChat
|
||||
fn ban_chat_sender_chat<C, S>(&self, chat_id: C, sender_chat_id: S) -> Self::BanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>,
|
||||
S: Into<ChatId>;
|
||||
|
||||
type UnbanChatSenderChat: Request<Payload = UnbanChatSenderChat, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`UnbanChatSenderChat`].
|
||||
fn unban_chat_sender_chat<C>(
|
||||
fn unban_chat_sender_chat<C, S>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
sender_chat_id: i64,
|
||||
sender_chat_id: S,
|
||||
) -> Self::UnbanChatSenderChat
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>,
|
||||
S: Into<ChatId>;
|
||||
|
||||
type SetChatPermissions: Request<Payload = SetChatPermissions, Err = Self::Err>;
|
||||
|
||||
|
@ -395,28 +402,28 @@ pub trait Requester {
|
|||
permissions: ChatPermissions,
|
||||
) -> Self::SetChatPermissions
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type ExportChatInviteLink: Request<Payload = ExportChatInviteLink, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`ExportChatInviteLink`].
|
||||
fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
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>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
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>,
|
||||
C: Into<Recipient>,
|
||||
I: Into<String>;
|
||||
|
||||
type RevokeChatInviteLink: Request<Payload = RevokeChatInviteLink, Err = Self::Err>;
|
||||
|
@ -428,7 +435,7 @@ pub trait Requester {
|
|||
invite_link: I,
|
||||
) -> Self::RevokeChatInviteLink
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
I: Into<String>;
|
||||
|
||||
type ApproveChatJoinRequest: Request<Payload = ApproveChatJoinRequest, Err = Self::Err>;
|
||||
|
@ -437,10 +444,10 @@ pub trait Requester {
|
|||
fn approve_chat_join_request<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
) -> Self::ApproveChatJoinRequest
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type DeclineChatJoinRequest: Request<Payload = DeclineChatJoinRequest, Err = Self::Err>;
|
||||
|
||||
|
@ -448,31 +455,31 @@ pub trait Requester {
|
|||
fn decline_chat_join_request<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
) -> Self::DeclineChatJoinRequest
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SetChatPhoto: Request<Payload = SetChatPhoto, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SetChatPhoto`].
|
||||
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type DeleteChatPhoto: Request<Payload = DeleteChatPhoto, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`DeleteChatPhoto`].
|
||||
fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SetChatTitle: Request<Payload = SetChatTitle, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SetChatTitle`].
|
||||
fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>;
|
||||
|
||||
type SetChatDescription: Request<Payload = SetChatDescription, Err = Self::Err>;
|
||||
|
@ -480,70 +487,70 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SetChatDescription`].
|
||||
fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type PinChatMessage: Request<Payload = PinChatMessage, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`PinChatMessage`].
|
||||
fn pin_chat_message<C>(&self, chat_id: C, message_id: i32) -> Self::PinChatMessage
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type UnpinChatMessage: Request<Payload = UnpinChatMessage, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`UnpinChatMessage`].
|
||||
fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type UnpinAllChatMessages: Request<Payload = UnpinAllChatMessages, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`UnpinAllChatMessages`].
|
||||
fn unpin_all_chat_messages<C>(&self, chat_id: C) -> Self::UnpinAllChatMessages
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type LeaveChat: Request<Payload = LeaveChat, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`LeaveChat`].
|
||||
fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetChat: Request<Payload = GetChat, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetChat`].
|
||||
fn get_chat<C>(&self, chat_id: C) -> Self::GetChat
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetChatAdministrators: Request<Payload = GetChatAdministrators, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetChatAdministrators`].
|
||||
fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
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>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetChatMembersCount: Request<Payload = GetChatMembersCount, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetChatMembersCount`].
|
||||
fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetChatMember: Request<Payload = GetChatMember, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`GetChatMember`].
|
||||
fn get_chat_member<C>(&self, chat_id: C, user_id: i64) -> Self::GetChatMember
|
||||
fn get_chat_member<C>(&self, chat_id: C, user_id: UserId) -> Self::GetChatMember
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SetChatStickerSet: Request<Payload = SetChatStickerSet, Err = Self::Err>;
|
||||
|
||||
|
@ -554,7 +561,7 @@ pub trait Requester {
|
|||
sticker_set_name: S,
|
||||
) -> Self::SetChatStickerSet
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
S: Into<String>;
|
||||
|
||||
type DeleteChatStickerSet: Request<Payload = DeleteChatStickerSet, Err = Self::Err>;
|
||||
|
@ -562,7 +569,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`DeleteChatStickerSet`].
|
||||
fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type AnswerCallbackQuery: Request<Payload = AnswerCallbackQuery, Err = Self::Err>;
|
||||
|
||||
|
@ -606,7 +613,7 @@ pub trait Requester {
|
|||
text: T,
|
||||
) -> Self::EditMessageText
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
C: Into<Recipient>,
|
||||
T: Into<String>;
|
||||
|
||||
type EditMessageTextInline: Request<Payload = EditMessageTextInline, Err = Self::Err>;
|
||||
|
@ -626,7 +633,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`EditMessageCaption`].
|
||||
fn edit_message_caption<C>(&self, chat_id: C, message_id: i32) -> Self::EditMessageCaption
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type EditMessageCaptionInline: Request<Payload = EditMessageCaptionInline, Err = Self::Err>;
|
||||
|
||||
|
@ -648,7 +655,7 @@ pub trait Requester {
|
|||
media: InputMedia,
|
||||
) -> Self::EditMessageMedia
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type EditMessageMediaInline: Request<Payload = EditMessageMediaInline, Err = Self::Err>;
|
||||
|
||||
|
@ -670,7 +677,7 @@ pub trait Requester {
|
|||
message_id: i32,
|
||||
) -> Self::EditMessageReplyMarkup
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type EditMessageReplyMarkupInline: Request<
|
||||
Payload = EditMessageReplyMarkupInline,
|
||||
|
@ -690,21 +697,21 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`StopPoll`].
|
||||
fn stop_poll<C>(&self, chat_id: C, message_id: i32) -> Self::StopPoll
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type DeleteMessage: Request<Payload = DeleteMessage, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`DeleteMessage`].
|
||||
fn delete_message<C>(&self, chat_id: C, message_id: i32) -> Self::DeleteMessage
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type SendSticker: Request<Payload = SendSticker, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`SendSticker`].
|
||||
fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker
|
||||
where
|
||||
C: Into<ChatId>;
|
||||
C: Into<Recipient>;
|
||||
|
||||
type GetStickerSet: Request<Payload = GetStickerSet, Err = Self::Err>;
|
||||
|
||||
|
@ -716,14 +723,18 @@ pub trait Requester {
|
|||
type UploadStickerFile: Request<Payload = UploadStickerFile, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`UploadStickerFile`].
|
||||
fn upload_sticker_file(&self, user_id: i64, png_sticker: InputFile) -> Self::UploadStickerFile;
|
||||
fn upload_sticker_file(
|
||||
&self,
|
||||
user_id: UserId,
|
||||
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: i64,
|
||||
user_id: UserId,
|
||||
name: N,
|
||||
title: T,
|
||||
sticker: InputSticker,
|
||||
|
@ -739,7 +750,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`AddStickerToSet`].
|
||||
fn add_sticker_to_set<N, E>(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
name: N,
|
||||
sticker: InputSticker,
|
||||
emojis: E,
|
||||
|
@ -769,7 +780,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: i64) -> Self::SetStickerSetThumb
|
||||
fn set_sticker_set_thumb<N>(&self, name: N, user_id: UserId) -> Self::SetStickerSetThumb
|
||||
where
|
||||
N: Into<String>;
|
||||
|
||||
|
@ -787,7 +798,7 @@ pub trait Requester {
|
|||
prices: Pri,
|
||||
) -> Self::SendInvoice
|
||||
where
|
||||
Ch: Into<ChatId>,
|
||||
Ch: Into<Recipient>,
|
||||
T: Into<String>,
|
||||
D: Into<String>,
|
||||
Pa: Into<String>,
|
||||
|
@ -816,7 +827,11 @@ 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: i64, errors: E) -> Self::SetPassportDataErrors
|
||||
fn set_passport_data_errors<E>(
|
||||
&self,
|
||||
user_id: UserId,
|
||||
errors: E,
|
||||
) -> Self::SetPassportDataErrors
|
||||
where
|
||||
E: IntoIterator<Item = PassportElementError>;
|
||||
|
||||
|
@ -832,7 +847,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SetGameScore`].
|
||||
fn set_game_score(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
score: u64,
|
||||
chat_id: u32,
|
||||
message_id: i64,
|
||||
|
@ -843,7 +858,7 @@ pub trait Requester {
|
|||
/// For Telegram documentation see [`SetGameScoreInline`].
|
||||
fn set_game_score_inline<I>(
|
||||
&self,
|
||||
user_id: i64,
|
||||
user_id: UserId,
|
||||
score: u64,
|
||||
inline_message_id: I,
|
||||
) -> Self::SetGameScoreInline
|
||||
|
@ -853,7 +868,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: i64, target: T) -> Self::GetGameHighScores
|
||||
fn get_game_high_scores<T>(&self, user_id: UserId, target: T) -> Self::GetGameHighScores
|
||||
where
|
||||
T: Into<TargetMessage>;
|
||||
}
|
||||
|
|
|
@ -88,9 +88,9 @@ mod tests {
|
|||
use crate::{
|
||||
payloads::{self, setters::*},
|
||||
types::{
|
||||
InputFile, InputMedia, InputMediaAnimation, InputMediaAudio, InputMediaDocument,
|
||||
InputMediaPhoto, InputMediaVideo, InputSticker, MessageEntity, MessageEntityKind,
|
||||
ParseMode,
|
||||
ChatId, InputFile, InputMedia, InputMediaAnimation, InputMediaAudio,
|
||||
InputMediaDocument, InputMediaPhoto, InputMediaVideo, InputSticker, MessageEntity,
|
||||
MessageEntityKind, ParseMode, UserId,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -98,7 +98,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
async fn issue_473() {
|
||||
to_form_ref(
|
||||
&payloads::SendPhoto::new(0, InputFile::file_id("0")).caption_entities([
|
||||
&payloads::SendPhoto::new(ChatId(0), InputFile::file_id("0")).caption_entities([
|
||||
MessageEntity {
|
||||
kind: MessageEntityKind::Url,
|
||||
offset: 0,
|
||||
|
@ -115,7 +115,7 @@ mod tests {
|
|||
const CAPTION: &str = "caption";
|
||||
|
||||
to_form_ref(&payloads::SendMediaGroup::new(
|
||||
0,
|
||||
ChatId(0),
|
||||
[
|
||||
InputMedia::Photo(
|
||||
InputMediaPhoto::new(InputFile::file("./media/logo.png"))
|
||||
|
@ -151,7 +151,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
async fn test_add_sticker_to_set() {
|
||||
to_form_ref(&payloads::AddStickerToSet::new(
|
||||
0,
|
||||
UserId(0),
|
||||
"name",
|
||||
InputSticker::Png(InputFile::file("./media/logo.png")),
|
||||
"✈️⚙️",
|
||||
|
@ -163,7 +163,7 @@ mod tests {
|
|||
#[tokio::test]
|
||||
async fn test_send_animation() {
|
||||
to_form_ref(
|
||||
&payloads::SendAnimation::new(0, InputFile::file("./media/logo.png"))
|
||||
&payloads::SendAnimation::new(ChatId(0), InputFile::file("./media/logo.png"))
|
||||
.caption_entities(entities())
|
||||
.thumb(InputFile::read(
|
||||
File::open("./media/logo.png").await.unwrap(),
|
||||
|
|
12
src/types.rs
12
src/types.rs
|
@ -1,4 +1,4 @@
|
|||
//! Telergam API types.
|
||||
//! Telegram API types.
|
||||
|
||||
pub use allowed_update::*;
|
||||
pub use animation::*;
|
||||
|
@ -9,7 +9,6 @@ pub use callback_game::*;
|
|||
pub use callback_query::*;
|
||||
pub use chat::*;
|
||||
pub use chat_action::*;
|
||||
pub use chat_id::*;
|
||||
pub use chat_invite_link::*;
|
||||
pub use chat_join_request::*;
|
||||
pub use chat_location::*;
|
||||
|
@ -115,7 +114,6 @@ mod callback_game;
|
|||
mod callback_query;
|
||||
mod chat;
|
||||
mod chat_action;
|
||||
mod chat_id;
|
||||
mod chat_invite_link;
|
||||
mod chat_join_request;
|
||||
mod chat_location;
|
||||
|
@ -222,6 +220,14 @@ mod non_telegram_types {
|
|||
pub(super) mod until_date;
|
||||
}
|
||||
|
||||
mod chat_id;
|
||||
mod recipient;
|
||||
mod user_id;
|
||||
|
||||
pub use chat_id::*;
|
||||
pub use recipient::*;
|
||||
pub use user_id::*;
|
||||
|
||||
pub(crate) mod serde_opt_date_from_unix_timestamp {
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::ChatId;
|
||||
use crate::types::{Recipient, UserId};
|
||||
|
||||
/// This object represents the scope to which bot commands are applied.
|
||||
///
|
||||
|
@ -49,20 +49,22 @@ pub enum BotCommandScope {
|
|||
AllPrivateChats,
|
||||
AllGroupChats,
|
||||
AllChatAdministrators,
|
||||
Chat { chat_id: ChatId },
|
||||
ChatAdministrators { chat_id: ChatId },
|
||||
ChatMember { chat_id: ChatId, user_id: i64 },
|
||||
Chat { chat_id: Recipient },
|
||||
ChatAdministrators { chat_id: Recipient },
|
||||
ChatMember { chat_id: Recipient, user_id: UserId },
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_486() {
|
||||
use crate::types::ChatId;
|
||||
|
||||
serde_json::to_string(&BotCommandScope::Chat {
|
||||
chat_id: ChatId::Id(0),
|
||||
chat_id: Recipient::Id(ChatId(0)),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
serde_json::to_string(&BotCommandScope::ChatAdministrators {
|
||||
chat_id: ChatId::Id(0),
|
||||
chat_id: Recipient::Id(ChatId(0)),
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ pub struct CallbackQuery {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::types::UserId;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
@ -70,7 +72,7 @@ mod tests {
|
|||
let expected = CallbackQuery {
|
||||
id: "id".to_string(),
|
||||
from: User {
|
||||
id: 12345,
|
||||
id: UserId(12345),
|
||||
is_bot: false,
|
||||
first_name: "firstName".to_string(),
|
||||
last_name: None,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message, True};
|
||||
use crate::types::{ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, True};
|
||||
|
||||
/// This object represents a chat.
|
||||
///
|
||||
|
@ -8,12 +8,8 @@ use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message, True};
|
|||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Chat {
|
||||
/// A unique identifier for this chat. This number may be greater than 32
|
||||
/// bits and some programming languages may have difficulty/silent defects
|
||||
/// in interpreting it. But it is smaller than 52 bits, so a signed 64 bit
|
||||
/// integer or double-precision float type are safe for storing this
|
||||
/// identifier.
|
||||
pub id: i64,
|
||||
/// A unique identifier for this chat.
|
||||
pub id: ChatId,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub kind: ChatKind,
|
||||
|
@ -454,11 +450,11 @@ mod tests {
|
|||
#[test]
|
||||
fn channel_de() {
|
||||
let expected = Chat {
|
||||
id: -1,
|
||||
id: ChatId(-1),
|
||||
kind: ChatKind::Public(ChatPublic {
|
||||
title: None,
|
||||
kind: PublicChatKind::Channel(PublicChatChannel {
|
||||
username: Some("channelname".into()),
|
||||
username: Some("channel_name".into()),
|
||||
linked_chat_id: None,
|
||||
}),
|
||||
description: None,
|
||||
|
@ -469,7 +465,7 @@ mod tests {
|
|||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
};
|
||||
let actual = from_str(r#"{"id":-1,"type":"channel","username":"channelname"}"#).unwrap();
|
||||
let actual = from_str(r#"{"id":-1,"type":"channel","username":"channel_name"}"#).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -477,7 +473,7 @@ mod tests {
|
|||
fn private_chat_de() {
|
||||
assert_eq!(
|
||||
Chat {
|
||||
id: 0,
|
||||
id: ChatId(0),
|
||||
kind: ChatKind::Private(ChatPrivate {
|
||||
type_: (),
|
||||
username: Some("username".into()),
|
||||
|
|
|
@ -1,71 +1,84 @@
|
|||
use derive_more::{Display, From};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A unique identifier for the target chat or username of the target channel
|
||||
/// (in the format `@channelusername`).
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, Display, From)]
|
||||
#[serde(untagged)]
|
||||
pub enum ChatId {
|
||||
/// A chat identifier.
|
||||
#[display(fmt = "{}", _0)]
|
||||
Id(i64),
|
||||
use crate::types::UserId;
|
||||
|
||||
/// A channel username (in the format @channelusername).
|
||||
#[display(fmt = "{}", _0)]
|
||||
ChannelUsername(String),
|
||||
/// Identifier of a chat.
|
||||
///
|
||||
/// Note that "a chat" here means any of group, supergroup, channel or user PM.
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Debug, derive_more::Display)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct ChatId(pub i64);
|
||||
|
||||
impl From<UserId> for ChatId {
|
||||
fn from(UserId(id): UserId) -> Self {
|
||||
Self(id as _)
|
||||
}
|
||||
}
|
||||
|
||||
impl ChatId {
|
||||
pub(crate) fn is_channel(&self) -> bool {
|
||||
matches!(self.unmark(), None | Some(UnmarkedChatId::Channel(_)))
|
||||
pub(crate) fn is_channel(self) -> bool {
|
||||
matches!(self.unmark(), UnmarkedChatId::Channel(_))
|
||||
}
|
||||
|
||||
pub(crate) fn unmark(&self) -> Option<UnmarkedChatId> {
|
||||
pub(crate) fn unmark(self) -> UnmarkedChatId {
|
||||
use UnmarkedChatId::*;
|
||||
|
||||
const MAX_CHANNEL_ID: i64 = -(10i64.pow(12));
|
||||
const MIN_CHANNEL_ID: i64 = MAX_CHANNEL_ID - (i32::MAX as i64);
|
||||
const MAX_USER_ID: i64 = i32::MAX as _;
|
||||
const MIN_CHAT_ID: i64 = -MAX_USER_ID;
|
||||
// https://github.com/mtcute/mtcute/blob/6933ecc3f82dd2e9100f52b0afec128af564713b/packages/core/src/utils/peer-utils.ts#L4
|
||||
const MIN_MARKED_CHANNEL_ID: i64 = -1997852516352;
|
||||
const MAX_MARKED_CHANNEL_ID: i64 = -1000000000000;
|
||||
const MIN_MARKED_CHAT_ID: i64 = MAX_MARKED_CHANNEL_ID + 1;
|
||||
const MAX_MARKED_CHAT_ID: i64 = MIN_USER_ID - 1;
|
||||
const MIN_USER_ID: i64 = 0;
|
||||
const MAX_USER_ID: i64 = (1 << 40) - 1;
|
||||
|
||||
let res = match self {
|
||||
&Self::Id(id @ MIN_CHAT_ID..=-1) => Chat(-id as _),
|
||||
&Self::Id(id @ MIN_CHANNEL_ID..=MAX_CHANNEL_ID) => Channel((MAX_CHANNEL_ID - id) as _),
|
||||
&Self::Id(id) => {
|
||||
debug_assert!(0 < id && id < MAX_USER_ID, "malformed chat id: {}", id);
|
||||
User(id as _)
|
||||
match self.0 {
|
||||
id @ MIN_MARKED_CHAT_ID..=MAX_MARKED_CHAT_ID => Group(-id as _),
|
||||
id @ MIN_MARKED_CHANNEL_ID..=MAX_MARKED_CHANNEL_ID => {
|
||||
Channel((MAX_MARKED_CHANNEL_ID - id) as _)
|
||||
}
|
||||
Self::ChannelUsername(_) => return None,
|
||||
};
|
||||
|
||||
Some(res)
|
||||
id @ MIN_USER_ID..=MAX_USER_ID => User(UserId(id as _)),
|
||||
id => panic!("malformed chat id: {}", id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum UnmarkedChatId {
|
||||
User(u32),
|
||||
Chat(u32),
|
||||
Channel(u32),
|
||||
User(UserId),
|
||||
Group(u64),
|
||||
Channel(u64),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{ChatId, UnmarkedChatId, UserId};
|
||||
|
||||
/// Test that `ChatId` is serialized as the underlying integer
|
||||
#[test]
|
||||
fn chat_id_id_serialization() {
|
||||
let expected_json = String::from(r#"123456"#);
|
||||
let actual_json = serde_json::to_string(&ChatId::Id(123_456)).unwrap();
|
||||
fn deser() {
|
||||
let chat_id = S {
|
||||
chat_id: ChatId(0xAA),
|
||||
};
|
||||
let json = r#"{"chat_id":170}"#;
|
||||
|
||||
assert_eq!(expected_json, actual_json)
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
struct S {
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
assert_eq!(serde_json::to_string(&chat_id).unwrap(), json);
|
||||
assert_eq!(chat_id, serde_json::from_str(json).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chat_id_channel_username_serialization() {
|
||||
let expected_json = String::from(r#""@username""#);
|
||||
let actual_json =
|
||||
serde_json::to_string(&ChatId::ChannelUsername(String::from("@username"))).unwrap();
|
||||
|
||||
assert_eq!(expected_json, actual_json)
|
||||
fn user_id_unmark() {
|
||||
assert!(matches!(
|
||||
ChatId(5298363099).unmark(),
|
||||
UnmarkedChatId::User(UserId(5298363099))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,6 +591,8 @@ pub enum ChatMemberStatus {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::types::UserId;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
@ -618,7 +620,7 @@ mod tests {
|
|||
}"#;
|
||||
let expected = ChatMember {
|
||||
user: User {
|
||||
id: 1029940401,
|
||||
id: UserId(1029940401),
|
||||
is_bot: false,
|
||||
first_name: "First".to_string(),
|
||||
last_name: Some("Last".to_string()),
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::UserId;
|
||||
|
||||
/// This object represents a phone contact.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#contact).
|
||||
|
@ -16,7 +18,7 @@ pub struct Contact {
|
|||
pub last_name: Option<String>,
|
||||
|
||||
/// A contact's user identifier in Telegram.
|
||||
pub user_id: Option<i32>,
|
||||
pub user_id: Option<UserId>,
|
||||
|
||||
/// Additional data about the contact in the form of a [vCard].
|
||||
///
|
||||
|
|
|
@ -4,8 +4,8 @@ use chrono::{DateTime, Utc};
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{
|
||||
Animation, Audio, Chat, Contact, Dice, Document, Game, InlineKeyboardMarkup, Invoice, Location,
|
||||
MessageAutoDeleteTimerChanged, MessageEntity, PassportData, PhotoSize, Poll,
|
||||
Animation, Audio, Chat, ChatId, Contact, Dice, Document, Game, InlineKeyboardMarkup, Invoice,
|
||||
Location, MessageAutoDeleteTimerChanged, MessageEntity, PassportData, PhotoSize, Poll,
|
||||
ProximityAlertTriggered, Sticker, SuccessfulPayment, True, User, Venue, Video, VideoNote,
|
||||
Voice, VoiceChatEnded, VoiceChatParticipantsInvited, VoiceChatScheduled, VoiceChatStarted,
|
||||
};
|
||||
|
@ -187,14 +187,14 @@ pub enum ChatMigration {
|
|||
/// identifier `chat_id`.
|
||||
To {
|
||||
#[serde(rename = "migrate_to_chat_id")]
|
||||
chat_id: i64,
|
||||
chat_id: ChatId,
|
||||
},
|
||||
|
||||
/// The supergroup has been migrated from a group with the specified
|
||||
/// identifier `chat_id`.
|
||||
From {
|
||||
#[serde(rename = "migrate_from_chat_id")]
|
||||
chat_id: i64,
|
||||
chat_id: ChatId,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -519,14 +519,15 @@ mod getters {
|
|||
use std::ops::Deref;
|
||||
|
||||
use crate::types::{
|
||||
self, message::MessageKind::*, Chat, ChatMigration, Forward, ForwardedFrom, MediaAnimation,
|
||||
MediaAudio, MediaContact, MediaDocument, MediaGame, MediaKind, MediaLocation, MediaPhoto,
|
||||
MediaPoll, MediaSticker, MediaText, MediaVenue, MediaVideo, MediaVideoNote, MediaVoice,
|
||||
Message, MessageChannelChatCreated, MessageCommon, MessageConnectedWebsite,
|
||||
MessageDeleteChatPhoto, MessageDice, MessageEntity, MessageGroupChatCreated,
|
||||
MessageInvoice, MessageLeftChatMember, MessageNewChatMembers, MessageNewChatPhoto,
|
||||
MessageNewChatTitle, MessagePassportData, MessagePinned, MessageProximityAlertTriggered,
|
||||
MessageSuccessfulPayment, MessageSupergroupChatCreated, PhotoSize, True, User,
|
||||
self, message::MessageKind::*, Chat, ChatId, ChatMigration, Forward, ForwardedFrom,
|
||||
MediaAnimation, MediaAudio, MediaContact, MediaDocument, MediaGame, MediaKind,
|
||||
MediaLocation, MediaPhoto, MediaPoll, MediaSticker, MediaText, MediaVenue, MediaVideo,
|
||||
MediaVideoNote, MediaVoice, Message, MessageChannelChatCreated, MessageCommon,
|
||||
MessageConnectedWebsite, MessageDeleteChatPhoto, MessageDice, MessageEntity,
|
||||
MessageGroupChatCreated, MessageInvoice, MessageLeftChatMember, MessageNewChatMembers,
|
||||
MessageNewChatPhoto, MessageNewChatTitle, MessagePassportData, MessagePinned,
|
||||
MessageProximityAlertTriggered, MessageSuccessfulPayment, MessageSupergroupChatCreated,
|
||||
PhotoSize, True, User,
|
||||
};
|
||||
|
||||
/// Getters for [Message] fields from [telegram docs].
|
||||
|
@ -558,7 +559,7 @@ mod getters {
|
|||
}
|
||||
|
||||
#[deprecated(since = "0.4.2", note = "use `.chat.id` field instead")]
|
||||
pub fn chat_id(&self) -> i64 {
|
||||
pub fn chat_id(&self) -> ChatId {
|
||||
self.chat.id
|
||||
}
|
||||
|
||||
|
@ -931,7 +932,7 @@ mod getters {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn migrate_to_chat_id(&self) -> Option<i64> {
|
||||
pub fn migrate_to_chat_id(&self) -> Option<ChatId> {
|
||||
match &self.kind {
|
||||
Common(MessageCommon {
|
||||
media_kind: MediaKind::Migration(ChatMigration::To { chat_id }),
|
||||
|
@ -941,7 +942,7 @@ mod getters {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn migrate_from_chat_id(&self) -> Option<i64> {
|
||||
pub fn migrate_from_chat_id(&self) -> Option<ChatId> {
|
||||
match &self.kind {
|
||||
Common(MessageCommon {
|
||||
media_kind: MediaKind::Migration(ChatMigration::From { chat_id }),
|
||||
|
@ -1069,7 +1070,8 @@ impl Message {
|
|||
// accessible to the group members.
|
||||
None => format!(
|
||||
"https://t.me/c/{0}/{1}/",
|
||||
(-self.chat.id) - 1000000000000,
|
||||
// FIXME: this may be wrong for private channels
|
||||
(-self.chat.id.0) - 1000000000000,
|
||||
self.id
|
||||
),
|
||||
};
|
||||
|
@ -1326,7 +1328,7 @@ mod tests {
|
|||
let message: Message = serde_json::from_str(json).unwrap();
|
||||
|
||||
let group = Chat {
|
||||
id: -1001160242915,
|
||||
id: ChatId(-1001160242915),
|
||||
kind: ChatKind::Public(ChatPublic {
|
||||
title: Some("a".to_owned()),
|
||||
kind: PublicChatKind::Supergroup(PublicChatSupergroup {
|
||||
|
@ -1360,8 +1362,8 @@ mod tests {
|
|||
/// Regression test for <https://github.com/teloxide/teloxide/issues/427>
|
||||
#[test]
|
||||
fn issue_427() {
|
||||
let old = -599075523;
|
||||
let new = -1001555296434;
|
||||
let old = ChatId(-599075523);
|
||||
let new = ChatId(-1001555296434);
|
||||
|
||||
// Migration to a supergroup
|
||||
let json = r#"{"chat":{"all_members_are_administrators":false,"id":-599075523,"title":"test","type":"group"},"date":1629404938,"from":{"first_name":"nullptr","id":729497414,"is_bot":false,"language_code":"en","username":"hex0x0000"},"message_id":16,"migrate_to_chat_id":-1001555296434}"#;
|
||||
|
|
58
src/types/recipient.rs
Normal file
58
src/types/recipient.rs
Normal file
|
@ -0,0 +1,58 @@
|
|||
use derive_more::{Display, From};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{ChatId, UserId};
|
||||
|
||||
/// A unique identifier for the target chat or username of the target channel
|
||||
/// (in the format `@channelusername`).
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Display, From)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum Recipient {
|
||||
/// A chat identifier.
|
||||
#[display(fmt = "{}", _0)]
|
||||
Id(ChatId),
|
||||
|
||||
/// A channel username (in the format @channelusername).
|
||||
#[display(fmt = "{}", _0)]
|
||||
ChannelUsername(String),
|
||||
}
|
||||
|
||||
impl Recipient {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn is_channel(&self) -> bool {
|
||||
match self {
|
||||
Recipient::Id(id) => id.is_channel(),
|
||||
Recipient::ChannelUsername(_) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UserId> for Recipient {
|
||||
fn from(id: UserId) -> Self {
|
||||
Self::Id(id.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn chat_id_id_serialization() {
|
||||
let expected_json = String::from(r#"123456"#);
|
||||
let actual_json = serde_json::to_string(&Recipient::Id(ChatId(123_456))).unwrap();
|
||||
|
||||
assert_eq!(expected_json, actual_json)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chat_id_channel_username_serialization() {
|
||||
let expected_json = String::from(r#""@username""#);
|
||||
let actual_json =
|
||||
serde_json::to_string(&Recipient::ChannelUsername(String::from("@username"))).unwrap();
|
||||
|
||||
assert_eq!(expected_json, actual_json)
|
||||
}
|
||||
}
|
|
@ -13,7 +13,8 @@ use crate::types::True;
|
|||
///
|
||||
/// [`KeyboardMarkup`]: crate::types::KeyboardMarkup
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
|
||||
#[derive(Eq, Hash, PartialEq)]
|
||||
pub struct KeyboardRemove {
|
||||
/// Requests clients to remove the custom keyboard (user will not be able
|
||||
/// to summon this keyboard; if you want to hide the keyboard from sight
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::types::ChatId;
|
||||
use crate::types::Recipient;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum TargetMessage {
|
||||
Common { chat_id: ChatId, message_id: i32 },
|
||||
Common { chat_id: Recipient, message_id: i32 },
|
||||
Inline { inline_message_id: String },
|
||||
}
|
||||
|
||||
|
|
|
@ -294,8 +294,8 @@ impl Serialize for UpdateKind {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::types::{
|
||||
Chat, ChatKind, ChatPrivate, MediaKind, MediaText, Message, MessageCommon, MessageKind,
|
||||
Update, UpdateKind, User,
|
||||
Chat, ChatId, ChatKind, ChatPrivate, MediaKind, MediaText, Message, MessageCommon,
|
||||
MessageKind, Update, UpdateKind, User, UserId,
|
||||
};
|
||||
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
|
@ -335,7 +335,7 @@ mod test {
|
|||
id: 6557,
|
||||
date,
|
||||
chat: Chat {
|
||||
id: 218_485_655,
|
||||
id: ChatId(218_485_655),
|
||||
kind: ChatKind::Private(ChatPrivate {
|
||||
type_: (),
|
||||
username: Some(String::from("WaffleLapkin")),
|
||||
|
@ -350,7 +350,7 @@ mod test {
|
|||
},
|
||||
kind: MessageKind::Common(MessageCommon {
|
||||
from: Some(User {
|
||||
id: 218_485_655,
|
||||
id: UserId(218_485_655),
|
||||
is_bot: false,
|
||||
first_name: String::from("Waffle"),
|
||||
last_name: None,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::UserId;
|
||||
|
||||
/// This object represents a Telegram user or bot.
|
||||
///
|
||||
/// [The official docs](https://core.telegram.org/bots/api#user).
|
||||
|
@ -7,7 +9,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: i64,
|
||||
pub id: UserId,
|
||||
|
||||
/// `true`, if this user is a bot.
|
||||
pub is_bot: bool,
|
||||
|
@ -53,7 +55,7 @@ impl User {
|
|||
/// denote an anonymous user that sends messages on behalf of a group.
|
||||
pub fn is_anonymous(&self) -> bool {
|
||||
// https://github.com/tdlib/td/blob/4791fb6a2af0257f6cad8396e10424a79ee5f768/td/telegram/ContactsManager.cpp#L4941-L4943
|
||||
const ANON_ID: i64 = 1087968824;
|
||||
const ANON_ID: UserId = UserId(1087968824);
|
||||
|
||||
// Sanity check
|
||||
debug_assert!(
|
||||
|
@ -71,7 +73,7 @@ impl User {
|
|||
/// denote an anonymous user that sends messages on behalf of a channel.
|
||||
pub fn is_channel(&self) -> bool {
|
||||
// https://github.com/tdlib/td/blob/4791fb6a2af0257f6cad8396e10424a79ee5f768/td/telegram/ContactsManager.cpp#L4945-L4947
|
||||
const ANON_CHANNEL_ID: i64 = 136817688;
|
||||
const ANON_CHANNEL_ID: UserId = UserId(136817688);
|
||||
|
||||
// Sanity check
|
||||
debug_assert!(
|
||||
|
@ -91,7 +93,7 @@ impl User {
|
|||
/// is automatically forwarded to a group, bots in a group will get a
|
||||
/// message where `from` is the Telegram user.
|
||||
pub fn is_telegram(&self) -> bool {
|
||||
const TELEGRAM_USER_ID: i64 = 777000;
|
||||
const TELEGRAM_USER_ID: UserId = UserId(777000);
|
||||
|
||||
// Sanity check
|
||||
debug_assert!(
|
||||
|
@ -121,7 +123,7 @@ mod tests {
|
|||
"language_code":"ru"
|
||||
}"#;
|
||||
let expected = User {
|
||||
id: 12345,
|
||||
id: UserId(12345),
|
||||
is_bot: false,
|
||||
first_name: "firstName".to_string(),
|
||||
last_name: Some("lastName".to_string()),
|
||||
|
|
33
src/types/user_id.rs
Normal file
33
src/types/user_id.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Identifier of a user.
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Debug, derive_more::Display)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct UserId(pub u64);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::UserId;
|
||||
|
||||
/// Test that `UserId` is serialized as the underlying integer
|
||||
#[test]
|
||||
fn deser() {
|
||||
let user_id = S {
|
||||
user_id: UserId(17),
|
||||
};
|
||||
let json = r#"{"user_id":17}"#;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
struct S {
|
||||
user_id: UserId,
|
||||
}
|
||||
|
||||
assert_eq!(serde_json::to_string(&user_id).unwrap(), json);
|
||||
assert_eq!(user_id, serde_json::from_str(json).unwrap());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue