mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Merge pull request #887 from teloxide/use_message_id_type_more
Types improvements
This commit is contained in:
commit
326c8515cd
54 changed files with 365 additions and 200 deletions
|
@ -15,8 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `Update::from`, a replacement for `Update::user` ([#850][pr850])
|
||||
- `Seconds` type, which represents a duration is seconds ([#859][pr859])
|
||||
- `VideoChatEnded::duration` field that was previously missed ([#859][pr859])
|
||||
- `ThreadId` newtype over `MessageId`, used for identifying reply threads ([#887][pr887])
|
||||
|
||||
[pr851]: https://github.com/teloxide/teloxide/pull/851
|
||||
[pr887]: https://github.com/teloxide/teloxide/pull/887
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -47,6 +49,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
are now defined as named (`struct S {}`) instead of unit (`struct S;`) in order to fix their deserialization ([#876][pr876])
|
||||
- `Download` now uses GAT feature on the `Fut` and `Err` associated types, instead of a lifetime on the whole trait ([#885][pr885])
|
||||
- MSRV (Minimal Supported Rust Version) was bumped from `1.64.0` to `1.65.0`
|
||||
- Renamed `ForumTopic::message_thread_id` into `thread_id` ([#887][pr887])
|
||||
- `ForumTopic::thread_id` and `Message::thread_id` now use `ThreadId` instead of `i32` ([#887][pr887])
|
||||
- `message_thread_id` method parameters now use `ThreadId` instead of `i32` ([#887][pr887])
|
||||
- `DiceEmoji` variant order ([#887][pr887])
|
||||
- `Dice::value` now use `u8`, instead of `i32` ([#887][pr887])
|
||||
- `Invoice::total_amount`, `LabeledPrice::amount`, `PreCheckoutQuery::total_amount`, `SuccessfulPayment::total_amout` now use `u32`, instead of `i32` ([#887][pr887])
|
||||
- `Forward::message_id` and `Message::forward_from_message_id` now use `MessageId` instead of `i32` ([#887][pr887])
|
||||
- `Poll::total_voter_count` and `PollOption::voter_count` now use `u32` instead of `i32` ([#887][pr887])
|
||||
- `PollAnswer::option_ids` now use `u8` instead of `i32` ([#887][pr887])
|
||||
- Use `u32` for sizes and `Seconds` for timespans in `InlineQueryResult*` ([#887][pr887])
|
||||
- `SendGame::reply_to_message_id`, `SendSticker::reply_to_message_id` and `SendInvoice::reply_to_message_id` now use `MessageId` instead of `i32` ([#887][pr887])
|
||||
|
||||
[pr852]: https://github.com/teloxide/teloxide/pull/853
|
||||
[pr859]: https://github.com/teloxide/teloxide/pull/859
|
||||
|
|
|
@ -232,7 +232,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -311,7 +311,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -356,7 +356,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -440,7 +440,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -530,7 +530,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -635,7 +635,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -733,7 +733,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -849,7 +849,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -963,7 +963,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1048,7 +1048,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1131,7 +1131,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1181,7 +1181,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1449,7 +1449,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1548,7 +1548,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1627,7 +1627,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1746,7 +1746,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -1824,7 +1824,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread; supergroups only")
|
||||
),
|
||||
],
|
||||
|
@ -2626,7 +2626,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: i32,
|
||||
ty: RawTy("ThreadId"),
|
||||
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
|
||||
),
|
||||
Param(
|
||||
|
@ -2655,7 +2655,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: i32,
|
||||
ty: RawTy("ThreadId"),
|
||||
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
|
||||
),
|
||||
],
|
||||
|
@ -2674,7 +2674,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: i32,
|
||||
ty: RawTy("ThreadId"),
|
||||
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
|
||||
),
|
||||
],
|
||||
|
@ -2693,7 +2693,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: i32,
|
||||
ty: RawTy("ThreadId"),
|
||||
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
|
||||
),
|
||||
],
|
||||
|
@ -2712,7 +2712,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: i32,
|
||||
ty: RawTy("ThreadId"),
|
||||
descr: Doc(md: "Unique identifier for the target message thread of the forum topic"),
|
||||
),
|
||||
],
|
||||
|
@ -3411,7 +3411,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -3437,7 +3437,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "reply_to_message_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("MessageId")),
|
||||
descr: Doc(md: "If the message is a reply, ID of the original message")
|
||||
),
|
||||
Param(
|
||||
|
@ -3669,7 +3669,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -3798,7 +3798,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "reply_to_message_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("MessageId")),
|
||||
descr: Doc(md: "If the message is a reply, ID of the original message")
|
||||
),
|
||||
Param(
|
||||
|
@ -4026,7 +4026,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "message_thread_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("ThreadId")),
|
||||
descr: Doc(md: "Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"),
|
||||
),
|
||||
Param(
|
||||
|
@ -4049,7 +4049,7 @@ Schema(
|
|||
),
|
||||
Param(
|
||||
name: "reply_to_message_id",
|
||||
ty: Option(i32),
|
||||
ty: Option(RawTy("MessageId")),
|
||||
descr: Doc(md: "If the message is a reply, ID of the original message")
|
||||
),
|
||||
Param(
|
||||
|
|
|
@ -628,31 +628,31 @@ trait ErasableRequester<'a> {
|
|||
fn edit_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, EditForumTopic, Self::Err>;
|
||||
|
||||
fn close_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, CloseForumTopic, Self::Err>;
|
||||
|
||||
fn reopen_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, ReopenForumTopic, Self::Err>;
|
||||
|
||||
fn delete_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, DeleteForumTopic, Self::Err>;
|
||||
|
||||
fn unpin_all_forum_topic_messages(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err>;
|
||||
|
||||
fn edit_general_forum_topic(
|
||||
|
@ -1368,7 +1368,7 @@ where
|
|||
fn edit_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, EditForumTopic, Self::Err> {
|
||||
Requester::edit_forum_topic(self, chat_id, message_thread_id).erase()
|
||||
}
|
||||
|
@ -1376,7 +1376,7 @@ where
|
|||
fn close_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, CloseForumTopic, Self::Err> {
|
||||
Requester::close_forum_topic(self, chat_id, message_thread_id).erase()
|
||||
}
|
||||
|
@ -1384,7 +1384,7 @@ where
|
|||
fn reopen_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, ReopenForumTopic, Self::Err> {
|
||||
Requester::reopen_forum_topic(self, chat_id, message_thread_id).erase()
|
||||
}
|
||||
|
@ -1392,7 +1392,7 @@ where
|
|||
fn delete_forum_topic(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, DeleteForumTopic, Self::Err> {
|
||||
Requester::delete_forum_topic(self, chat_id, message_thread_id).erase()
|
||||
}
|
||||
|
@ -1400,7 +1400,7 @@ where
|
|||
fn unpin_all_forum_topic_messages(
|
||||
&self,
|
||||
chat_id: Recipient,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> ErasedRequest<'a, UnpinAllForumTopicMessages, Self::Err> {
|
||||
Requester::unpin_all_forum_topic_messages(self, chat_id, message_thread_id).erase()
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
requests::{JsonRequest, MultipartRequest},
|
||||
types::{
|
||||
BotCommand, ChatId, ChatPermissions, InlineQueryResult, InputFile, InputMedia,
|
||||
InputSticker, LabeledPrice, MessageId, Recipient, UserId,
|
||||
InputSticker, LabeledPrice, MessageId, Recipient, ThreadId, UserId,
|
||||
},
|
||||
Bot,
|
||||
};
|
||||
|
@ -671,7 +671,7 @@ impl Requester for Bot {
|
|||
|
||||
type EditForumTopic = JsonRequest<payloads::EditForumTopic>;
|
||||
|
||||
fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic
|
||||
fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic
|
||||
where
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
|
@ -683,7 +683,7 @@ impl Requester for Bot {
|
|||
|
||||
type CloseForumTopic = JsonRequest<payloads::CloseForumTopic>;
|
||||
|
||||
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic
|
||||
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::CloseForumTopic
|
||||
where
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
|
@ -695,7 +695,11 @@ impl Requester for Bot {
|
|||
|
||||
type ReopenForumTopic = JsonRequest<payloads::ReopenForumTopic>;
|
||||
|
||||
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic
|
||||
fn reopen_forum_topic<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::ReopenForumTopic
|
||||
where
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
|
@ -707,7 +711,11 @@ impl Requester for Bot {
|
|||
|
||||
type DeleteForumTopic = JsonRequest<payloads::DeleteForumTopic>;
|
||||
|
||||
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic
|
||||
fn delete_forum_topic<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::DeleteForumTopic
|
||||
where
|
||||
C: Into<Recipient>,
|
||||
{
|
||||
|
@ -722,7 +730,7 @@ impl Requester for Bot {
|
|||
fn unpin_all_forum_topic_messages<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::UnpinAllForumTopicMessages
|
||||
where
|
||||
C: Into<Recipient>,
|
||||
|
|
|
@ -931,41 +931,41 @@ macro_rules! requester_forward {
|
|||
(@method edit_forum_topic $body:ident $ty:ident) => {
|
||||
type EditForumTopic = $ty![EditForumTopic];
|
||||
|
||||
fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic where C: Into<Recipient> {
|
||||
fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(edit_forum_topic this (chat_id: C, message_thread_id: i32))
|
||||
$body!(edit_forum_topic this (chat_id: C, message_thread_id: ThreadId))
|
||||
}
|
||||
};
|
||||
(@method close_forum_topic $body:ident $ty:ident) => {
|
||||
type CloseForumTopic = $ty![CloseForumTopic];
|
||||
|
||||
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic where C: Into<Recipient> {
|
||||
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::CloseForumTopic where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(close_forum_topic this (chat_id: C, message_thread_id: i32))
|
||||
$body!(close_forum_topic this (chat_id: C, message_thread_id: ThreadId))
|
||||
}
|
||||
};
|
||||
(@method reopen_forum_topic $body:ident $ty:ident) => {
|
||||
type ReopenForumTopic = $ty![ReopenForumTopic];
|
||||
|
||||
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic where C: Into<Recipient> {
|
||||
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::ReopenForumTopic where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(reopen_forum_topic this (chat_id: C, message_thread_id: i32))
|
||||
$body!(reopen_forum_topic this (chat_id: C, message_thread_id: ThreadId))
|
||||
}
|
||||
};
|
||||
(@method delete_forum_topic $body:ident $ty:ident) => {
|
||||
type DeleteForumTopic = $ty![DeleteForumTopic];
|
||||
|
||||
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic where C: Into<Recipient> {
|
||||
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::DeleteForumTopic where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(delete_forum_topic this (chat_id: C, message_thread_id: i32))
|
||||
$body!(delete_forum_topic this (chat_id: C, message_thread_id: ThreadId))
|
||||
}
|
||||
};
|
||||
(@method unpin_all_forum_topic_messages $body:ident $ty:ident) => {
|
||||
type UnpinAllForumTopicMessages = $ty![UnpinAllForumTopicMessages];
|
||||
|
||||
fn unpin_all_forum_topic_messages<C>(&self, chat_id: C, message_thread_id: i32) -> Self::UnpinAllForumTopicMessages where C: Into<Recipient> {
|
||||
fn unpin_all_forum_topic_messages<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::UnpinAllForumTopicMessages where C: Into<Recipient> {
|
||||
let this = self;
|
||||
$body!(unpin_all_forum_topic_messages this (chat_id: C, message_thread_id: i32))
|
||||
$body!(unpin_all_forum_topic_messages this (chat_id: C, message_thread_id: ThreadId))
|
||||
}
|
||||
};
|
||||
(@method edit_general_forum_topic $body:ident $ty:ident) => {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Recipient, True};
|
||||
use crate::types::{Recipient, ThreadId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success.
|
||||
|
@ -12,7 +12,7 @@ impl_payload! {
|
|||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the target message thread of the forum topic
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup};
|
||||
use crate::types::{MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
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.
|
||||
|
@ -21,7 +21,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
|
||||
pub caption: String [into],
|
||||
/// Mode for parsing entities in the photo caption. See [formatting options] for more details.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Recipient, True};
|
||||
use crate::types::{Recipient, ThreadId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_delete\_messages_ administrator rights. Returns True on success.
|
||||
|
@ -12,7 +12,7 @@ impl_payload! {
|
|||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the target message thread of the forum topic
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Recipient, True};
|
||||
use crate::types::{Recipient, ThreadId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success.
|
||||
|
@ -12,7 +12,7 @@ impl_payload! {
|
|||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the target message thread of the forum topic
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
}
|
||||
optional {
|
||||
/// Topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Message, MessageId, Recipient};
|
||||
use crate::types::{Message, MessageId, Recipient, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to forward messages of any kind. On success, the sent [`Message`] is returned.
|
||||
|
@ -21,7 +21,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Sends the message [silently]. Users will receive a notification with no sound.
|
||||
///
|
||||
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Recipient, True};
|
||||
use crate::types::{Recipient, ThreadId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns True on success.
|
||||
|
@ -12,7 +12,7 @@ impl_payload! {
|
|||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the target message thread of the forum topic
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup,
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -23,7 +23,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Duration of the animation in seconds
|
||||
pub duration: u32,
|
||||
/// Animation width
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup,
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -26,7 +26,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Audio caption, 0-1024 characters after entities parsing
|
||||
pub caption: String [into],
|
||||
/// Mode for parsing entities in the audio caption. See [formatting options] for more details.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{ChatAction, Recipient, True};
|
||||
use crate::types::{ChatAction, Recipient, ThreadId, 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.
|
||||
|
@ -31,7 +31,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread; supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Message, MessageId, Recipient, ReplyMarkup};
|
||||
use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send phone contacts. On success, the sent [`Message`] is returned.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Contact's last name
|
||||
pub last_name: String [into],
|
||||
/// Additional data about the contact in the form of a [vCard], 0-2048 bytes
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{DiceEmoji, Message, MessageId, Recipient, ReplyMarkup};
|
||||
use crate::types::{DiceEmoji, Message, MessageId, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send an animated emoji that will display a random value. On success, the sent [`Message`] is returned.
|
||||
|
@ -16,7 +16,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
|
||||
pub emoji: DiceEmoji,
|
||||
/// Sends the message [silently]. Users will receive a notification with no sound.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup,
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -23,7 +23,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. [More info on Sending Files »]
|
||||
///
|
||||
/// [More info on Sending Files »]: crate::types::InputFile
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Message, ReplyMarkup};
|
||||
use crate::types::{Message, MessageId, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send a game. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +18,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Sends the message [silently]. Users will receive a notification with no sound.
|
||||
///
|
||||
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
|
||||
|
@ -26,7 +26,8 @@ impl_payload! {
|
|||
/// Protects the contents of sent messages from forwarding and saving
|
||||
pub protect_content: bool,
|
||||
/// If the message is a reply, ID of the original message
|
||||
pub reply_to_message_id: i32,
|
||||
#[serde(serialize_with = "crate::types::serialize_reply_to_message_id")]
|
||||
pub reply_to_message_id: MessageId,
|
||||
/// Pass _True_, if the message should be sent even if the specified replied-to message is not found
|
||||
pub allow_sending_without_reply: bool,
|
||||
/// A JSON-serialized object for an [inline keyboard]. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
use url::Url;
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message, Recipient};
|
||||
use crate::types::{InlineKeyboardMarkup, LabeledPrice, Message, MessageId, Recipient, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send invoices. On success, the sent [`Message`] is returned.
|
||||
|
@ -31,7 +31,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of `US$ 1.45` pass `max_tip_amount = 145`. See the exp parameter in [`currencies.json`], it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0
|
||||
///
|
||||
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
|
||||
|
@ -71,7 +71,8 @@ impl_payload! {
|
|||
/// Protects the contents of sent messages from forwarding and saving
|
||||
pub protect_content: bool,
|
||||
/// If the message is a reply, ID of the original message
|
||||
pub reply_to_message_id: i32,
|
||||
#[serde(serialize_with = "crate::types::serialize_reply_to_message_id")]
|
||||
pub reply_to_message_id: MessageId,
|
||||
/// Pass _True_, if the message should be sent even if the specified replied-to message is not found
|
||||
pub allow_sending_without_reply: bool,
|
||||
/// A JSON-serialized object for an [inline keyboard]. If empty, one 'Pay `total price`' button will be shown. If not empty, the first button must be a Pay button.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Message, MessageId, Recipient, ReplyMarkup};
|
||||
use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send point on the map. On success, the sent [`Message`] is returned.
|
||||
|
@ -20,7 +20,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// The radius of uncertainty for the location, measured in meters; 0-1500
|
||||
pub horizontal_accuracy: f64,
|
||||
/// Period in seconds for which the location will be updated (see [Live Locations], should be between 60 and 86400.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputMedia, Message, MessageId, Recipient};
|
||||
use crate::types::{InputMedia, Message, MessageId, Recipient, ThreadId};
|
||||
|
||||
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! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Sends the message [silently]. Users will receive a notification with no sound.
|
||||
///
|
||||
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup};
|
||||
use crate::types::{
|
||||
Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send text messages. On success, the sent [`Message`] is returned.
|
||||
|
@ -18,7 +20,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Mode for parsing entities in the message text. See [formatting options] for more details.
|
||||
///
|
||||
/// [formatting options]: https://core.telegram.org/bots/api#formatting-options
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup,
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -23,7 +23,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Photo caption (may also be used when resending photos by _file\_id_), 0-1024 characters after entities parsing
|
||||
pub caption: String [into],
|
||||
/// Mode for parsing entities in the photo caption. See [formatting options] for more details.
|
||||
|
|
|
@ -4,7 +4,7 @@ use chrono::{DateTime, Utc};
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
Message, MessageEntity, MessageId, ParseMode, PollType, Recipient, ReplyMarkup,
|
||||
Message, MessageEntity, MessageId, ParseMode, PollType, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -23,7 +23,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// True, if the poll needs to be anonymous, defaults to True
|
||||
pub is_anonymous: bool,
|
||||
/// Poll type, “quiz” or “regular”, defaults to “regular”
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputFile, Message, Recipient, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = sticker]
|
||||
|
@ -21,7 +21,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Sends the message [silently]. Users will receive a notification with no sound.
|
||||
///
|
||||
/// [silently]: https://telegram.org/blog/channels-2-0#silent-messages
|
||||
|
@ -29,7 +29,8 @@ impl_payload! {
|
|||
/// Protects the contents of sent messages from forwarding and saving
|
||||
pub protect_content: bool,
|
||||
/// If the message is a reply, ID of the original message
|
||||
pub reply_to_message_id: i32,
|
||||
#[serde(serialize_with = "crate::types::serialize_reply_to_message_id")]
|
||||
pub reply_to_message_id: MessageId,
|
||||
/// Pass _True_, if the message should be sent even if the specified replied-to message is not found
|
||||
pub allow_sending_without_reply: bool,
|
||||
/// Additional interface options. A JSON-serialized object for an [inline keyboard], [custom reply keyboard], instructions to remove reply keyboard or to force a reply from the user.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Message, MessageId, Recipient, ReplyMarkup};
|
||||
use crate::types::{Message, MessageId, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to send information about a venue. On success, the sent [`Message`] is returned.
|
||||
|
@ -24,7 +24,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Foursquare identifier of the venue
|
||||
pub foursquare_id: String [into],
|
||||
/// Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup,
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -24,7 +24,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Duration of the video in seconds
|
||||
pub duration: u32,
|
||||
/// Video width
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup};
|
||||
use crate::types::{InputFile, Message, MessageId, Recipient, ReplyMarkup, ThreadId};
|
||||
|
||||
impl_payload! {
|
||||
@[multipart = video_note, thumb]
|
||||
|
@ -22,7 +22,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Duration of the video in seconds
|
||||
pub duration: u32,
|
||||
/// Video width and height, i.e. diameter of the video message
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use crate::types::{
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup,
|
||||
InputFile, Message, MessageEntity, MessageId, ParseMode, Recipient, ReplyMarkup, ThreadId,
|
||||
};
|
||||
|
||||
impl_payload! {
|
||||
|
@ -25,7 +25,7 @@ impl_payload! {
|
|||
}
|
||||
optional {
|
||||
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
/// Voice message caption, 0-1024 characters after entities parsing
|
||||
pub caption: String [into],
|
||||
/// Mode for parsing entities in the voice message caption. See [formatting options] for more details.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::types::{Recipient, True};
|
||||
use crate::types::{Recipient, ThreadId, True};
|
||||
|
||||
impl_payload! {
|
||||
/// Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the _can\_pin\_messages_ administrator right in the supergroup. Returns True on success.
|
||||
|
@ -12,7 +12,7 @@ impl_payload! {
|
|||
/// Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
|
||||
pub chat_id: Recipient [into],
|
||||
/// Unique identifier for the target message thread of the forum topic
|
||||
pub message_thread_id: i32,
|
||||
pub message_thread_id: ThreadId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -678,28 +678,40 @@ pub trait Requester {
|
|||
type EditForumTopic: Request<Payload = EditForumTopic, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`EditForumTopic`].
|
||||
fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::EditForumTopic
|
||||
fn edit_forum_topic<C>(&self, chat_id: C, message_thread_id: ThreadId) -> Self::EditForumTopic
|
||||
where
|
||||
C: Into<Recipient>;
|
||||
|
||||
type CloseForumTopic: Request<Payload = CloseForumTopic, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`CloseForumTopic`].
|
||||
fn close_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::CloseForumTopic
|
||||
fn close_forum_topic<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::CloseForumTopic
|
||||
where
|
||||
C: Into<Recipient>;
|
||||
|
||||
type ReopenForumTopic: Request<Payload = ReopenForumTopic, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`ReopenForumTopic`].
|
||||
fn reopen_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::ReopenForumTopic
|
||||
fn reopen_forum_topic<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::ReopenForumTopic
|
||||
where
|
||||
C: Into<Recipient>;
|
||||
|
||||
type DeleteForumTopic: Request<Payload = DeleteForumTopic, Err = Self::Err>;
|
||||
|
||||
/// For Telegram documentation see [`DeleteForumTopic`].
|
||||
fn delete_forum_topic<C>(&self, chat_id: C, message_thread_id: i32) -> Self::DeleteForumTopic
|
||||
fn delete_forum_topic<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::DeleteForumTopic
|
||||
where
|
||||
C: Into<Recipient>;
|
||||
|
||||
|
@ -709,7 +721,7 @@ pub trait Requester {
|
|||
fn unpin_all_forum_topic_messages<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
message_thread_id: i32,
|
||||
message_thread_id: ThreadId,
|
||||
) -> Self::UnpinAllForumTopicMessages
|
||||
where
|
||||
C: Into<Recipient>;
|
||||
|
|
|
@ -100,6 +100,7 @@ pub use sticker::*;
|
|||
pub use sticker_set::*;
|
||||
pub use successful_payment::*;
|
||||
pub use target_message::*;
|
||||
pub use thread_id::*;
|
||||
pub use unit_false::*;
|
||||
pub use unit_true::*;
|
||||
pub use update::*;
|
||||
|
@ -191,6 +192,7 @@ mod sticker;
|
|||
mod sticker_set;
|
||||
mod successful_payment;
|
||||
mod target_message;
|
||||
mod thread_id;
|
||||
mod unit_false;
|
||||
mod unit_true;
|
||||
mod update;
|
||||
|
@ -384,6 +386,42 @@ pub(crate) mod option_url_from_string {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) mod option_msg_id_as_int {
|
||||
use crate::types::MessageId;
|
||||
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
pub(crate) fn serialize<S>(this: &Option<MessageId>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
this.map(|MessageId(id)| id).serialize(serializer)
|
||||
}
|
||||
|
||||
pub(crate) fn deserialize<'de, D>(deserializer: D) -> Result<Option<MessageId>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
Option::<i32>::deserialize(deserializer).map(|r| r.map(MessageId))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Struct {
|
||||
#[serde(with = "crate::types::option_msg_id_as_int")]
|
||||
id: Option<MessageId>,
|
||||
}
|
||||
|
||||
{
|
||||
let json = r#"{"id":123}"#;
|
||||
let id: Struct = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(id.id, Some(MessageId(123)));
|
||||
assert_eq!(serde_json::to_string(&id).unwrap(), json.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn serialize_reply_to_message_id<S>(
|
||||
this: &Option<MessageId>,
|
||||
serializer: S,
|
||||
|
|
|
@ -11,11 +11,7 @@ pub struct Dice {
|
|||
|
||||
/// Value of the dice.
|
||||
///
|
||||
/// 1-6 for [`DiceEmoji::Dice`] and [`DiceEmoji::Darts`], 1-5 for
|
||||
/// [`DiceEmoji::Basketball`].
|
||||
///
|
||||
/// [`DiceEmoji::Dice`]: crate::types::DiceEmoji::Dice
|
||||
/// [`DiceEmoji::Darts`]:crate::types::DiceEmoji::Darts
|
||||
/// [`DiceEmoji::Basketball`]:crate::types::DiceEmoji::Basketball
|
||||
pub value: i32,
|
||||
/// Value of the dice, 1-6 for 🎲, 🎯 and 🎳 base emoji, 1-5 for 🏀 and ⚽
|
||||
/// base emoji, 1-64 for 🎰 base emoji
|
||||
pub value: u8,
|
||||
}
|
||||
|
|
|
@ -2,27 +2,27 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
#[derive(Copy, Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
||||
pub enum DiceEmoji {
|
||||
/// Values from 1-6. Defaults to this variant.
|
||||
/// "🎲" emoji. Values from 1-6. Defaults to this variant.
|
||||
#[serde(rename = "🎲")]
|
||||
Dice,
|
||||
|
||||
/// Values from 1-6.
|
||||
/// "🎯" emoji. Values from 1-6.
|
||||
#[serde(rename = "🎯")]
|
||||
Darts,
|
||||
|
||||
/// Values from 1-5.
|
||||
#[serde(rename = "🏀")]
|
||||
Basketball,
|
||||
|
||||
/// Values 1-5
|
||||
#[serde(rename = "⚽")]
|
||||
Football,
|
||||
|
||||
/// Values 1-5
|
||||
/// "🎳" emoji. Values 1-6
|
||||
#[serde(rename = "🎳")]
|
||||
Bowling,
|
||||
|
||||
/// Values 1-64
|
||||
/// "🏀" emoji. Values from 1-5.
|
||||
#[serde(rename = "🏀")]
|
||||
Basketball,
|
||||
|
||||
/// "⚽" emoji. Values 1-5
|
||||
#[serde(rename = "⚽")]
|
||||
Football,
|
||||
|
||||
/// "🎰" emoji. Values 1-64
|
||||
#[serde(rename = "🎰")]
|
||||
SlotMachine,
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use crate::types::ThreadId;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// This object represents a forum topic.
|
||||
|
@ -7,8 +9,8 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ForumTopic {
|
||||
/// Unique identifier of the forum topic
|
||||
// FIXME: MessageThreadId or something
|
||||
pub message_thread_id: i32,
|
||||
#[serde(rename = "message_thread_id")]
|
||||
pub thread_id: ThreadId,
|
||||
|
||||
/// Name of the topic.
|
||||
pub name: String,
|
||||
|
|
|
@ -34,10 +34,10 @@ pub struct InlineQueryResultArticle {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultArticle {
|
||||
|
@ -115,13 +115,13 @@ impl InlineQueryResultArticle {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ pub struct InlineQueryResultContact {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultContact {
|
||||
|
@ -128,13 +128,13 @@ impl InlineQueryResultContact {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ pub struct InlineQueryResultDocument {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultDocument {
|
||||
|
@ -140,13 +140,13 @@ impl InlineQueryResultDocument {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to an animated GIF file.
|
||||
///
|
||||
|
@ -19,13 +19,13 @@ pub struct InlineQueryResultGif {
|
|||
pub gif_url: reqwest::Url,
|
||||
|
||||
/// Width of the GIF.
|
||||
pub gif_width: Option<i32>,
|
||||
pub gif_width: Option<u32>,
|
||||
|
||||
/// Height of the GIFv.
|
||||
pub gif_height: Option<i32>,
|
||||
pub gif_height: Option<u32>,
|
||||
|
||||
/// Duration of the GIF.
|
||||
pub gif_duration: Option<i32>,
|
||||
pub gif_duration: Option<Seconds>,
|
||||
|
||||
/// URL of the static thumbnail for the result (jpeg or gif).
|
||||
pub thumb_url: reqwest::Url,
|
||||
|
@ -93,19 +93,19 @@ impl InlineQueryResultGif {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn gif_width(mut self, val: i32) -> Self {
|
||||
pub fn gif_width(mut self, val: u32) -> Self {
|
||||
self.gif_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn gif_height(mut self, val: i32) -> Self {
|
||||
pub fn gif_height(mut self, val: u32) -> Self {
|
||||
self.gif_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn gif_duration(mut self, val: i32) -> Self {
|
||||
pub fn gif_duration(mut self, val: Seconds) -> Self {
|
||||
self.gif_duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to a video animation (H.264/MPEG-4 AVC video without
|
||||
/// sound).
|
||||
|
@ -16,17 +16,19 @@ pub struct InlineQueryResultMpeg4Gif {
|
|||
/// Unique identifier for this result, 1-64 bytes.
|
||||
pub id: String,
|
||||
|
||||
// FIXME: rename everything so that it doesn't have `mpeg4_` (and similarly for other
|
||||
// `InlineQueryResult*`)
|
||||
/// A valid URL for the MP4 file. File size must not exceed 1MB.
|
||||
pub mpeg4_url: reqwest::Url,
|
||||
|
||||
/// Video width.
|
||||
pub mpeg4_width: Option<i32>,
|
||||
pub mpeg4_width: Option<u32>,
|
||||
|
||||
/// Video height.
|
||||
pub mpeg4_height: Option<i32>,
|
||||
pub mpeg4_height: Option<u32>,
|
||||
|
||||
/// Video duration.
|
||||
pub mpeg4_duration: Option<i32>,
|
||||
pub mpeg4_duration: Option<Seconds>,
|
||||
|
||||
/// URL of the static thumbnail (jpeg or gif) for the result.
|
||||
pub thumb_url: reqwest::Url,
|
||||
|
@ -94,19 +96,19 @@ impl InlineQueryResultMpeg4Gif {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn mpeg4_width(mut self, val: i32) -> Self {
|
||||
pub fn mpeg4_width(mut self, val: u32) -> Self {
|
||||
self.mpeg4_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn mpeg4_height(mut self, val: i32) -> Self {
|
||||
pub fn mpeg4_height(mut self, val: u32) -> Self {
|
||||
self.mpeg4_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn mpeg4_duration(mut self, val: i32) -> Self {
|
||||
pub fn mpeg4_duration(mut self, val: Seconds) -> Self {
|
||||
self.mpeg4_duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ pub struct InlineQueryResultPhoto {
|
|||
pub thumb_url: reqwest::Url,
|
||||
|
||||
/// Width of the photo.
|
||||
pub photo_width: Option<i32>,
|
||||
pub photo_width: Option<u32>,
|
||||
|
||||
/// Height of the photo.
|
||||
pub photo_height: Option<i32>,
|
||||
pub photo_height: Option<u32>,
|
||||
|
||||
/// Title for the result.
|
||||
pub title: Option<String>,
|
||||
|
@ -100,13 +100,13 @@ impl InlineQueryResultPhoto {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn photo_width(mut self, val: i32) -> Self {
|
||||
pub fn photo_width(mut self, val: u32) -> Self {
|
||||
self.photo_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn photo_height(mut self, val: i32) -> Self {
|
||||
pub fn photo_height(mut self, val: u32) -> Self {
|
||||
self.photo_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ pub struct InlineQueryResultVenue {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultVenue {
|
||||
|
@ -173,13 +173,13 @@ impl InlineQueryResultVenue {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use mime::Mime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to a page containing an embedded video player or a video
|
||||
/// file.
|
||||
|
@ -46,13 +46,13 @@ pub struct InlineQueryResultVideo {
|
|||
pub caption_entities: Option<Vec<MessageEntity>>,
|
||||
|
||||
/// Video width.
|
||||
pub video_width: Option<i32>,
|
||||
pub video_width: Option<u32>,
|
||||
|
||||
/// Video height.
|
||||
pub video_height: Option<i32>,
|
||||
pub video_height: Option<u32>,
|
||||
|
||||
/// Video duration in seconds.
|
||||
pub video_duration: Option<i32>,
|
||||
pub video_duration: Option<Seconds>,
|
||||
|
||||
/// Short description of the result.
|
||||
pub description: Option<String>,
|
||||
|
@ -158,19 +158,19 @@ impl InlineQueryResultVideo {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn video_width(mut self, val: i32) -> Self {
|
||||
pub fn video_width(mut self, val: u32) -> Self {
|
||||
self.video_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn video_height(mut self, val: i32) -> Self {
|
||||
pub fn video_height(mut self, val: u32) -> Self {
|
||||
self.video_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn video_duration(mut self, val: i32) -> Self {
|
||||
pub fn video_duration(mut self, val: Seconds) -> Self {
|
||||
self.video_duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to a voice recording in an .ogg container encoded with
|
||||
/// OPUS.
|
||||
|
@ -38,7 +38,7 @@ pub struct InlineQueryResultVoice {
|
|||
pub caption_entities: Option<Vec<MessageEntity>>,
|
||||
|
||||
/// Recording duration in seconds.
|
||||
pub voice_duration: Option<i32>,
|
||||
pub voice_duration: Option<Seconds>,
|
||||
|
||||
/// [Inline keyboard] attached to the message.
|
||||
///
|
||||
|
@ -113,7 +113,7 @@ impl InlineQueryResultVoice {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn voice_duration(mut self, value: i32) -> Self {
|
||||
pub fn voice_duration(mut self, value: Seconds) -> Self {
|
||||
self.voice_duration = Some(value);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@ pub struct Invoice {
|
|||
/// majority of currencies).
|
||||
///
|
||||
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
|
||||
pub total_amount: i32,
|
||||
pub total_amount: u32,
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ pub struct LabeledPrice {
|
|||
///
|
||||
/// [currency]: https://core.telegram.org/bots/payments#supported-currencies
|
||||
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
|
||||
pub amount: i32,
|
||||
pub amount: u32,
|
||||
}
|
||||
|
||||
impl LabeledPrice {
|
||||
pub fn new<S>(label: S, amount: i32) -> Self
|
||||
pub fn new<S>(label: S, amount: u32) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ impl LabeledPrice {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn amount(mut self, val: i32) -> Self {
|
||||
pub fn amount(mut self, val: u32) -> Self {
|
||||
self.amount = val;
|
||||
self
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ use crate::types::{
|
|||
ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, Game, GeneralForumTopicHidden,
|
||||
GeneralForumTopicUnhidden, InlineKeyboardMarkup, Invoice, Location,
|
||||
MessageAutoDeleteTimerChanged, MessageEntity, MessageEntityRef, MessageId, PassportData,
|
||||
PhotoSize, Poll, ProximityAlertTriggered, Sticker, SuccessfulPayment, True, User, Venue, Video,
|
||||
VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote,
|
||||
Voice, WebAppData, WriteAccessAllowed,
|
||||
PhotoSize, Poll, ProximityAlertTriggered, Sticker, SuccessfulPayment, ThreadId, True, User,
|
||||
Venue, Video, VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled,
|
||||
VideoChatStarted, VideoNote, Voice, WebAppData, WriteAccessAllowed,
|
||||
};
|
||||
|
||||
/// This object represents a message.
|
||||
|
@ -25,9 +25,8 @@ pub struct Message {
|
|||
|
||||
/// Unique identifier of a message thread to which the message belongs; for
|
||||
/// supergroups only.
|
||||
// FIXME: MessageThreadId or such
|
||||
#[serde(rename = "message_thread_id")]
|
||||
pub thread_id: Option<i32>,
|
||||
pub thread_id: Option<ThreadId>,
|
||||
|
||||
/// Date the message was sent in Unix time.
|
||||
#[serde(with = "crate::types::serde_date_from_unix_timestamp")]
|
||||
|
@ -291,8 +290,13 @@ pub struct Forward {
|
|||
|
||||
/// For messages forwarded from channels, identifier of the original message
|
||||
/// in the channel
|
||||
#[serde(rename = "forward_from_message_id")]
|
||||
pub message_id: Option<i32>,
|
||||
#[serde(
|
||||
rename = "forward_from_message_id",
|
||||
with = "crate::types::option_msg_id_as_int",
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub message_id: Option<MessageId>,
|
||||
}
|
||||
|
||||
/// The entity that sent the original message that later was forwarded.
|
||||
|
@ -615,10 +619,10 @@ mod getters {
|
|||
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,
|
||||
MessageVideoChatParticipantsInvited, PhotoSize, True, User,
|
||||
MessageGroupChatCreated, MessageId, MessageInvoice, MessageLeftChatMember,
|
||||
MessageNewChatMembers, MessageNewChatPhoto, MessageNewChatTitle, MessagePassportData,
|
||||
MessagePinned, MessageProximityAlertTriggered, MessageSuccessfulPayment,
|
||||
MessageSupergroupChatCreated, MessageVideoChatParticipantsInvited, PhotoSize, True, User,
|
||||
};
|
||||
|
||||
/// Getters for [Message] fields from [telegram docs].
|
||||
|
@ -697,7 +701,7 @@ mod getters {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn forward_from_message_id(&self) -> Option<i32> {
|
||||
pub fn forward_from_message_id(&self) -> Option<MessageId> {
|
||||
self.forward().and_then(|f| f.message_id)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,13 @@ use serde::{Deserialize, Serialize};
|
|||
#[serde(from = "MessageIdRaw", into = "MessageIdRaw")]
|
||||
pub struct MessageId(pub i32);
|
||||
|
||||
// N.B. we [de]serialize `MessageId` as `{"message_id":n}`, which means that if
|
||||
// you want just an integer, you need to special case it with something
|
||||
// like `serde(with = "crate::types::option_msg_id_as_int")]`
|
||||
//
|
||||
// (we can't change the default format of `MessageId` because it's returned
|
||||
// by some methods and we can't change serialization there)
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct MessageIdRaw {
|
||||
message_id: i32,
|
||||
|
|
|
@ -22,7 +22,7 @@ pub struct Poll {
|
|||
pub is_closed: bool,
|
||||
|
||||
/// Total number of users that voted in the poll
|
||||
pub total_voter_count: i32,
|
||||
pub total_voter_count: u32,
|
||||
|
||||
/// True, if the poll is anonymous
|
||||
pub is_anonymous: bool,
|
||||
|
@ -64,7 +64,7 @@ pub struct PollOption {
|
|||
pub text: String,
|
||||
|
||||
/// Number of users that voted for this option.
|
||||
pub voter_count: i32,
|
||||
pub voter_count: u32,
|
||||
}
|
||||
|
||||
impl Poll {
|
||||
|
|
|
@ -12,5 +12,5 @@ pub struct PollAnswer {
|
|||
/// 0-based identifiers of answer options, chosen by the user.
|
||||
///
|
||||
/// May be empty if the user retracted their vote.
|
||||
pub option_ids: Vec<i32>,
|
||||
pub option_ids: Vec<u8>,
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ pub struct PreCheckoutQuery {
|
|||
/// majority of currencies).
|
||||
///
|
||||
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
|
||||
pub total_amount: i32,
|
||||
pub total_amount: u32,
|
||||
|
||||
/// Bot specified invoice payload.
|
||||
pub invoice_payload: String,
|
||||
|
|
|
@ -20,7 +20,7 @@ pub struct SuccessfulPayment {
|
|||
/// the majority of currencies).
|
||||
///
|
||||
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
|
||||
pub total_amount: i32,
|
||||
pub total_amount: u32,
|
||||
|
||||
/// Bot specified invoice payload.
|
||||
pub invoice_payload: String,
|
||||
|
|
80
crates/teloxide-core/src/types/thread_id.rs
Normal file
80
crates/teloxide-core/src/types/thread_id.rs
Normal file
|
@ -0,0 +1,80 @@
|
|||
use crate::types::MessageId;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Reply thread identifier.
|
||||
///
|
||||
/// A message that isn't a reply and other messages that reply to it directly or
|
||||
/// indirectly through a reply chain constitute a reply thread. All messages
|
||||
/// except the initial root message have an additional [`thread_id`] field that
|
||||
/// is equal to the root message's id.
|
||||
///
|
||||
/// In other words a thread id can be found recursively following
|
||||
/// `reply_to_message_id`, until you find a message which does not reply to
|
||||
/// anything, it's id is the thread id.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```text
|
||||
/// lizard: Hi {id:17} <-------------+--------------+----+--------------+---------------------+
|
||||
/// | | | | |
|
||||
/// wizard: hewwo {id:18, reply: 17 -+, thread: 17 -+} | | |
|
||||
/// | | |
|
||||
/// lizard: I've been wondering [...] {id:19, reply: 17 -+, thread: 17 -+} <---+ |
|
||||
/// | |
|
||||
/// neushoorn: wait, did y'all know that [...] {id:20} <-----------------------)--------------)--+-----+
|
||||
/// | | | |
|
||||
/// wizard: so this is not an easy question, actually [...] {id:21, reply: 19 -+, thread: 17 -+} | |
|
||||
/// +--------+ |
|
||||
/// | |
|
||||
/// wizard: everyone knows that, how did you not know that before?... {id:22, reply:20 -+, thread: 20 -+}
|
||||
/// ```
|
||||
///
|
||||
/// Note that channel comments and forum topics, reuse threads for different
|
||||
/// meanings. For channel comments every comment (indirectly) replies to the
|
||||
/// channel post forwarded to the linked chat (i.e. the forwarded channel post
|
||||
/// is the root of the comments thread). For forum topics every message in a
|
||||
/// topic is in the same thread too (i.e. they (indirectly) reply to the start
|
||||
/// of the topic).
|
||||
///
|
||||
/// [`thread_id`]: crate::types::Message::thread_id
|
||||
#[derive(Clone, Copy, Debug, derive_more::Display, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(from = "ThreadIdRaw", into = "ThreadIdRaw")]
|
||||
pub struct ThreadId(/** Identifier of the root message in a reply thread. */ pub MessageId);
|
||||
|
||||
// N.B. this is a hack to [de]serialize `ThreadId` as just a number
|
||||
// we need this since `MessageId` is [de]serialized as `{"message_id":n}`.
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct ThreadIdRaw(i32);
|
||||
|
||||
impl From<ThreadIdRaw> for ThreadId {
|
||||
fn from(ThreadIdRaw(message_id): ThreadIdRaw) -> Self {
|
||||
ThreadId(MessageId(message_id))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ThreadId> for ThreadIdRaw {
|
||||
fn from(ThreadId(MessageId(message_id)): ThreadId) -> Self {
|
||||
ThreadIdRaw(message_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::types::{MessageId, ThreadId};
|
||||
|
||||
#[test]
|
||||
fn smoke_deser() {
|
||||
let json = r#"123"#;
|
||||
let mid: ThreadId = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(mid, ThreadId(MessageId(123)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smoke_ser() {
|
||||
let mid: ThreadId = ThreadId(MessageId(123));
|
||||
let json = serde_json::to_string(&mid).unwrap();
|
||||
assert_eq!(json, r#"123"#);
|
||||
}
|
||||
}
|
|
@ -29,8 +29,6 @@ pub struct Update {
|
|||
}
|
||||
|
||||
impl Update {
|
||||
// FIXME: add mentioned_users -> impl Iterator<&User>
|
||||
|
||||
/// Returns the user that performed the action that caused this update, if
|
||||
/// known.
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue