mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
commit
c9c3c7d03b
47 changed files with 331 additions and 1 deletions
|
@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
[pr241]: https://github.com/teloxide/teloxide-core/pull/241
|
[pr241]: https://github.com/teloxide/teloxide-core/pull/241
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- More functions are now marked with `#[must_use]` ([#242][PR242])
|
||||||
|
|
||||||
|
[pr242]: https://github.com/teloxide/teloxide-core/pull/242
|
||||||
|
|
||||||
## 0.7.0 - 2022-07-19
|
## 0.7.0 - 2022-07-19
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -21,6 +21,7 @@ type BoxedFuture = Pin<Box<dyn Future<Output = ()> + Send>>;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Throttle`]: crate::adaptors::throttle::Throttle
|
/// [`Throttle`]: crate::adaptors::throttle::Throttle
|
||||||
|
#[must_use]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub limits: Limits,
|
pub limits: Limits,
|
||||||
|
|
|
@ -51,6 +51,7 @@ const TELOXIDE_TOKEN: &str = "TELOXIDE_TOKEN";
|
||||||
///
|
///
|
||||||
/// [`Arc`]: std::sync::Arc
|
/// [`Arc`]: std::sync::Arc
|
||||||
/// [Telegram Bot API]: https://core.telegram.org/bots/api
|
/// [Telegram Bot API]: https://core.telegram.org/bots/api
|
||||||
|
#[must_use]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Bot {
|
pub struct Bot {
|
||||||
token: Arc<str>,
|
token: Arc<str>,
|
||||||
|
@ -186,16 +187,19 @@ impl Bot {
|
||||||
/// Getters
|
/// Getters
|
||||||
impl Bot {
|
impl Bot {
|
||||||
/// Returns currently used token.
|
/// Returns currently used token.
|
||||||
|
#[must_use]
|
||||||
pub fn token(&self) -> &str {
|
pub fn token(&self) -> &str {
|
||||||
&self.token
|
&self.token
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns currently used http-client.
|
/// Returns currently used http-client.
|
||||||
|
#[must_use]
|
||||||
pub fn client(&self) -> &Client {
|
pub fn client(&self) -> &Client {
|
||||||
&self.client
|
&self.client
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns currently used token API url.
|
/// Returns currently used token API url.
|
||||||
|
#[must_use]
|
||||||
pub fn api_url(&self) -> reqwest::Url {
|
pub fn api_url(&self) -> reqwest::Url {
|
||||||
reqwest::Url::clone(&*self.api_url)
|
reqwest::Url::clone(&*self.api_url)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ pub const TELEGRAM_API_URL: &str = "https://api.telegram.org";
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// If `TELOXIDE_PROXY` exists, but isn't correct url.
|
/// If `TELOXIDE_PROXY` exists, but isn't correct url.
|
||||||
|
#[must_use]
|
||||||
pub fn client_from_env() -> reqwest::Client {
|
pub fn client_from_env() -> reqwest::Client {
|
||||||
use reqwest::Proxy;
|
use reqwest::Proxy;
|
||||||
|
|
||||||
|
|
|
@ -191,10 +191,12 @@ pub struct PublicChatSupergroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Chat {
|
impl Chat {
|
||||||
|
#[must_use]
|
||||||
pub fn is_private(&self) -> bool {
|
pub fn is_private(&self) -> bool {
|
||||||
matches!(self.kind, ChatKind::Private(_))
|
matches!(self.kind, ChatKind::Private(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn is_group(&self) -> bool {
|
pub fn is_group(&self) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
self.kind,
|
self.kind,
|
||||||
|
@ -205,6 +207,7 @@ impl Chat {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn is_supergroup(&self) -> bool {
|
pub fn is_supergroup(&self) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
self.kind,
|
self.kind,
|
||||||
|
@ -215,6 +218,7 @@ impl Chat {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn is_channel(&self) -> bool {
|
pub fn is_channel(&self) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
self.kind,
|
self.kind,
|
||||||
|
@ -225,6 +229,7 @@ impl Chat {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn is_chat(&self) -> bool {
|
pub fn is_chat(&self) -> bool {
|
||||||
self.is_private() || self.is_group() || self.is_supergroup()
|
self.is_private() || self.is_group() || self.is_supergroup()
|
||||||
}
|
}
|
||||||
|
@ -233,6 +238,7 @@ impl Chat {
|
||||||
/// Getters
|
/// Getters
|
||||||
impl Chat {
|
impl Chat {
|
||||||
/// A title, for supergroups, channels and group chats.
|
/// A title, for supergroups, channels and group chats.
|
||||||
|
#[must_use]
|
||||||
pub fn title(&self) -> Option<&str> {
|
pub fn title(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Public(this) => this.title.as_deref(),
|
ChatKind::Public(this) => this.title.as_deref(),
|
||||||
|
@ -241,6 +247,7 @@ impl Chat {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A username, for private chats, supergroups and channels if available.
|
/// A username, for private chats, supergroups and channels if available.
|
||||||
|
#[must_use]
|
||||||
pub fn username(&self) -> Option<&str> {
|
pub fn username(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Public(this) => match &this.kind {
|
ChatKind::Public(this) => match &this.kind {
|
||||||
|
@ -258,6 +265,7 @@ impl Chat {
|
||||||
/// identifier for a channel and vice versa. Returned only in [`GetChat`].
|
/// identifier for a channel and vice versa. Returned only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn linked_chat_id(&self) -> Option<i64> {
|
pub fn linked_chat_id(&self) -> Option<i64> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Public(this) => match &this.kind {
|
ChatKind::Public(this) => match &this.kind {
|
||||||
|
@ -275,6 +283,7 @@ impl Chat {
|
||||||
/// only from [`GetChat`].
|
/// only from [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn permissions(&self) -> Option<ChatPermissions> {
|
pub fn permissions(&self) -> Option<ChatPermissions> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Group(PublicChatGroup { permissions })
|
if let PublicChatKind::Group(PublicChatGroup { permissions })
|
||||||
|
@ -291,6 +300,7 @@ impl Chat {
|
||||||
/// [`GetChat`].
|
/// [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn sticker_set_name(&self) -> Option<&str> {
|
pub fn sticker_set_name(&self) -> Option<&str> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Supergroup(this) = &this.kind {
|
if let PublicChatKind::Supergroup(this) = &this.kind {
|
||||||
|
@ -305,6 +315,7 @@ impl Chat {
|
||||||
/// from [`GetChat`].
|
/// from [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn can_set_sticker_set(&self) -> Option<bool> {
|
pub fn can_set_sticker_set(&self) -> Option<bool> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Supergroup(this) = &this.kind {
|
if let PublicChatKind::Supergroup(this) = &this.kind {
|
||||||
|
@ -319,6 +330,7 @@ impl Chat {
|
||||||
/// unpriviledged user. Returned only from [`GetChat`].
|
/// unpriviledged user. Returned only from [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn slow_mode_delay(&self) -> Option<u32> {
|
pub fn slow_mode_delay(&self) -> Option<u32> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Supergroup(this) = &this.kind {
|
if let PublicChatKind::Supergroup(this) = &this.kind {
|
||||||
|
@ -333,6 +345,7 @@ impl Chat {
|
||||||
/// [`GetChat`].
|
/// [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn location(&self) -> Option<&ChatLocation> {
|
pub fn location(&self) -> Option<&ChatLocation> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Supergroup(this) = &this.kind {
|
if let PublicChatKind::Supergroup(this) = &this.kind {
|
||||||
|
@ -347,6 +360,7 @@ impl Chat {
|
||||||
/// messages. Returned only in [`GetChat`].
|
/// messages. Returned only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn join_to_send_messages(&self) -> Option<True> {
|
pub fn join_to_send_messages(&self) -> Option<True> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Supergroup(this) = &this.kind {
|
if let PublicChatKind::Supergroup(this) = &this.kind {
|
||||||
|
@ -361,6 +375,7 @@ impl Chat {
|
||||||
/// by supergroup administrators. Returned only in [`GetChat`].
|
/// by supergroup administrators. Returned only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn join_by_request(&self) -> Option<True> {
|
pub fn join_by_request(&self) -> Option<True> {
|
||||||
if let ChatKind::Public(this) = &self.kind {
|
if let ChatKind::Public(this) = &self.kind {
|
||||||
if let PublicChatKind::Supergroup(this) = &this.kind {
|
if let PublicChatKind::Supergroup(this) = &this.kind {
|
||||||
|
@ -375,6 +390,7 @@ impl Chat {
|
||||||
/// only in [`GetChat`].
|
/// only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn description(&self) -> Option<&str> {
|
pub fn description(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Public(this) => this.description.as_deref(),
|
ChatKind::Public(this) => this.description.as_deref(),
|
||||||
|
@ -392,6 +408,7 @@ impl Chat {
|
||||||
/// crate::payloads::ExportChatInviteLink
|
/// crate::payloads::ExportChatInviteLink
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn invite_link(&self) -> Option<&str> {
|
pub fn invite_link(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Public(this) => this.invite_link.as_deref(),
|
ChatKind::Public(this) => this.invite_link.as_deref(),
|
||||||
|
@ -403,6 +420,7 @@ impl Chat {
|
||||||
/// Returned only in [`GetChat`].
|
/// Returned only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn has_protected_content(&self) -> Option<True> {
|
pub fn has_protected_content(&self) -> Option<True> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Public(this) => this.has_protected_content,
|
ChatKind::Public(this) => this.has_protected_content,
|
||||||
|
@ -411,6 +429,7 @@ impl Chat {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A first name of the other party in a private chat.
|
/// A first name of the other party in a private chat.
|
||||||
|
#[must_use]
|
||||||
pub fn first_name(&self) -> Option<&str> {
|
pub fn first_name(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Private(this) => this.first_name.as_deref(),
|
ChatKind::Private(this) => this.first_name.as_deref(),
|
||||||
|
@ -419,6 +438,7 @@ impl Chat {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A last name of the other party in a private chat.
|
/// A last name of the other party in a private chat.
|
||||||
|
#[must_use]
|
||||||
pub fn last_name(&self) -> Option<&str> {
|
pub fn last_name(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Private(this) => this.last_name.as_deref(),
|
ChatKind::Private(this) => this.last_name.as_deref(),
|
||||||
|
@ -429,6 +449,7 @@ impl Chat {
|
||||||
/// Bio of the other party in a private chat. Returned only in [`GetChat`].
|
/// Bio of the other party in a private chat. Returned only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn bio(&self) -> Option<&str> {
|
pub fn bio(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Private(this) => this.bio.as_deref(),
|
ChatKind::Private(this) => this.bio.as_deref(),
|
||||||
|
@ -441,6 +462,7 @@ impl Chat {
|
||||||
/// user. Returned only in [`GetChat`].
|
/// user. Returned only in [`GetChat`].
|
||||||
///
|
///
|
||||||
/// [`GetChat`]: crate::payloads::GetChat
|
/// [`GetChat`]: crate::payloads::GetChat
|
||||||
|
#[must_use]
|
||||||
pub fn has_private_forwards(&self) -> Option<True> {
|
pub fn has_private_forwards(&self) -> Option<True> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChatKind::Private(this) => this.has_private_forwards,
|
ChatKind::Private(this) => this.has_private_forwards,
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub(crate) enum BareChatId {
|
||||||
|
|
||||||
impl ChatId {
|
impl ChatId {
|
||||||
/// Returns `true` if this is an id of a user.
|
/// Returns `true` if this is an id of a user.
|
||||||
|
#[must_use]
|
||||||
pub fn is_user(self) -> bool {
|
pub fn is_user(self) -> bool {
|
||||||
matches!(self.to_bare(), BareChatId::User(_))
|
matches!(self.to_bare(), BareChatId::User(_))
|
||||||
}
|
}
|
||||||
|
@ -38,11 +39,13 @@ impl ChatId {
|
||||||
/// Returns `true` if this is an id of a group.
|
/// Returns `true` if this is an id of a group.
|
||||||
///
|
///
|
||||||
/// Note: supergroup is **not** considered a group.
|
/// Note: supergroup is **not** considered a group.
|
||||||
|
#[must_use]
|
||||||
pub fn is_group(self) -> bool {
|
pub fn is_group(self) -> bool {
|
||||||
matches!(self.to_bare(), BareChatId::Group(_))
|
matches!(self.to_bare(), BareChatId::Group(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this is an id of a channel.
|
/// Returns `true` if this is an id of a channel.
|
||||||
|
#[must_use]
|
||||||
pub fn is_channel_or_supergroup(self) -> bool {
|
pub fn is_channel_or_supergroup(self) -> bool {
|
||||||
matches!(self.to_bare(), BareChatId::Channel(_))
|
matches!(self.to_bare(), BareChatId::Channel(_))
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ impl Deref for ChatMember {
|
||||||
/// Simple methods for checking a user status.
|
/// Simple methods for checking a user status.
|
||||||
impl ChatMemberKind {
|
impl ChatMemberKind {
|
||||||
/// Returns chat member status.
|
/// Returns chat member status.
|
||||||
|
#[must_use]
|
||||||
pub fn status(&self) -> ChatMemberStatus {
|
pub fn status(&self) -> ChatMemberStatus {
|
||||||
match self {
|
match self {
|
||||||
ChatMemberKind::Owner(_) => ChatMemberStatus::Owner,
|
ChatMemberKind::Owner(_) => ChatMemberStatus::Owner,
|
||||||
|
@ -161,6 +162,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` if the user is the [owner] of the given chat.
|
/// Returns `true` if the user is the [owner] of the given chat.
|
||||||
///
|
///
|
||||||
/// [owner]: ChatMemberKind::Owner
|
/// [owner]: ChatMemberKind::Owner
|
||||||
|
#[must_use]
|
||||||
pub fn is_owner(&self) -> bool {
|
pub fn is_owner(&self) -> bool {
|
||||||
matches!(self, Self::Owner { .. })
|
matches!(self, Self::Owner { .. })
|
||||||
}
|
}
|
||||||
|
@ -173,6 +175,7 @@ impl ChatMemberKind {
|
||||||
/// owner of the given chat. See also: [`is_privileged`].
|
/// owner of the given chat. See also: [`is_privileged`].
|
||||||
///
|
///
|
||||||
/// [`is_privileged`]: ChatMemberKind::is_privileged
|
/// [`is_privileged`]: ChatMemberKind::is_privileged
|
||||||
|
#[must_use]
|
||||||
pub fn is_administrator(&self) -> bool {
|
pub fn is_administrator(&self) -> bool {
|
||||||
matches!(self, Self::Administrator { .. })
|
matches!(self, Self::Administrator { .. })
|
||||||
}
|
}
|
||||||
|
@ -180,6 +183,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` if the user is a common [member] of the given chat.
|
/// Returns `true` if the user is a common [member] of the given chat.
|
||||||
///
|
///
|
||||||
/// [member]: ChatMemberKind::Member
|
/// [member]: ChatMemberKind::Member
|
||||||
|
#[must_use]
|
||||||
pub fn is_member(&self) -> bool {
|
pub fn is_member(&self) -> bool {
|
||||||
matches!(self, Self::Member { .. })
|
matches!(self, Self::Member { .. })
|
||||||
}
|
}
|
||||||
|
@ -187,6 +191,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` if the user is [restricted] in the given chat.
|
/// Returns `true` if the user is [restricted] in the given chat.
|
||||||
///
|
///
|
||||||
/// [restricted]: ChatMemberKind::Restricted
|
/// [restricted]: ChatMemberKind::Restricted
|
||||||
|
#[must_use]
|
||||||
pub fn is_restricted(&self) -> bool {
|
pub fn is_restricted(&self) -> bool {
|
||||||
matches!(self, Self::Restricted { .. })
|
matches!(self, Self::Restricted { .. })
|
||||||
}
|
}
|
||||||
|
@ -194,6 +199,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` if the user [left] the given chat.
|
/// Returns `true` if the user [left] the given chat.
|
||||||
///
|
///
|
||||||
/// [left]: ChatMemberKind::Left
|
/// [left]: ChatMemberKind::Left
|
||||||
|
#[must_use]
|
||||||
pub fn is_left(&self) -> bool {
|
pub fn is_left(&self) -> bool {
|
||||||
matches!(self, Self::Left { .. })
|
matches!(self, Self::Left { .. })
|
||||||
}
|
}
|
||||||
|
@ -201,6 +207,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` if the user is [banned] in the given chat.
|
/// Returns `true` if the user is [banned] in the given chat.
|
||||||
///
|
///
|
||||||
/// [banned]: ChatMemberKind::Banned
|
/// [banned]: ChatMemberKind::Banned
|
||||||
|
#[must_use]
|
||||||
pub fn is_banned(&self) -> bool {
|
pub fn is_banned(&self) -> bool {
|
||||||
matches!(self, Self::Banned { .. })
|
matches!(self, Self::Banned { .. })
|
||||||
}
|
}
|
||||||
|
@ -209,6 +216,7 @@ impl ChatMemberKind {
|
||||||
///
|
///
|
||||||
/// [kicked]: ChatMemberKind::Banned
|
/// [kicked]: ChatMemberKind::Banned
|
||||||
#[deprecated = "use `is_banned` instead"]
|
#[deprecated = "use `is_banned` instead"]
|
||||||
|
#[must_use]
|
||||||
pub fn is_kicked(&self) -> bool {
|
pub fn is_kicked(&self) -> bool {
|
||||||
self.is_banned()
|
self.is_banned()
|
||||||
}
|
}
|
||||||
|
@ -217,6 +225,7 @@ impl ChatMemberKind {
|
||||||
///
|
///
|
||||||
/// [creator]: ChatMemberKind::Owner
|
/// [creator]: ChatMemberKind::Owner
|
||||||
#[deprecated = "use `is_owner` instead"]
|
#[deprecated = "use `is_owner` instead"]
|
||||||
|
#[must_use]
|
||||||
pub fn is_creator(&self) -> bool {
|
pub fn is_creator(&self) -> bool {
|
||||||
self.is_owner()
|
self.is_owner()
|
||||||
}
|
}
|
||||||
|
@ -229,6 +238,7 @@ impl ChatMemberKind {
|
||||||
///
|
///
|
||||||
/// [owner]: ChatMemberKind::Owner
|
/// [owner]: ChatMemberKind::Owner
|
||||||
/// [administrator]: ChatMemberKind::Administrator
|
/// [administrator]: ChatMemberKind::Administrator
|
||||||
|
#[must_use]
|
||||||
pub fn is_privileged(&self) -> bool {
|
pub fn is_privileged(&self) -> bool {
|
||||||
self.is_administrator() || self.is_owner()
|
self.is_administrator() || self.is_owner()
|
||||||
}
|
}
|
||||||
|
@ -238,6 +248,7 @@ impl ChatMemberKind {
|
||||||
///
|
///
|
||||||
/// [left]: ChatMemberKind::Left
|
/// [left]: ChatMemberKind::Left
|
||||||
/// [banned]: ChatMemberKind::Banned
|
/// [banned]: ChatMemberKind::Banned
|
||||||
|
#[must_use]
|
||||||
pub fn is_present(&self) -> bool {
|
pub fn is_present(&self) -> bool {
|
||||||
!(self.is_left() || self.is_banned())
|
!(self.is_left() || self.is_banned())
|
||||||
}
|
}
|
||||||
|
@ -246,6 +257,7 @@ impl ChatMemberKind {
|
||||||
impl ChatMemberKind {
|
impl ChatMemberKind {
|
||||||
/// Getter for [`Administrator::custom_title`] and [`Owner::custom_title`]
|
/// Getter for [`Administrator::custom_title`] and [`Owner::custom_title`]
|
||||||
/// fields.
|
/// fields.
|
||||||
|
#[must_use]
|
||||||
pub fn custom_title(&self) -> Option<&str> {
|
pub fn custom_title(&self) -> Option<&str> {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Administrator(Administrator { custom_title, .. })
|
Self::Administrator(Administrator { custom_title, .. })
|
||||||
|
@ -261,6 +273,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_manage_chat`]: Administrator::can_manage_chat
|
/// [`can_manage_chat`]: Administrator::can_manage_chat
|
||||||
|
#[must_use]
|
||||||
pub fn is_anonymous(&self) -> bool {
|
pub fn is_anonymous(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(Owner { is_anonymous, .. })
|
Self::Owner(Owner { is_anonymous, .. })
|
||||||
|
@ -270,6 +283,7 @@ impl ChatMemberKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getter for [`Restricted::until_date`] and [`Banned::until_date`] fields.
|
/// Getter for [`Restricted::until_date`] and [`Banned::until_date`] fields.
|
||||||
|
#[must_use]
|
||||||
pub fn until_date(&self) -> Option<UntilDate> {
|
pub fn until_date(&self) -> Option<UntilDate> {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Owner(_) | Self::Administrator(_) | Self::Member | Self::Left => None,
|
Self::Owner(_) | Self::Administrator(_) | Self::Member | Self::Left => None,
|
||||||
|
@ -283,6 +297,7 @@ impl ChatMemberKind {
|
||||||
impl ChatMemberKind {
|
impl ChatMemberKind {
|
||||||
/// Returns `true` if the user is an administrator in the given chat and the
|
/// Returns `true` if the user is an administrator in the given chat and the
|
||||||
/// bot is allowed to edit administrator privileges of that user.
|
/// bot is allowed to edit administrator privileges of that user.
|
||||||
|
#[must_use]
|
||||||
pub fn can_be_edited(&self) -> bool {
|
pub fn can_be_edited(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Administrator(Administrator { can_be_edited, .. }) => *can_be_edited,
|
Self::Administrator(Administrator { can_be_edited, .. }) => *can_be_edited,
|
||||||
|
@ -305,6 +320,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_manage_chat`]: Administrator::can_manage_chat
|
/// [`can_manage_chat`]: Administrator::can_manage_chat
|
||||||
|
#[must_use]
|
||||||
pub fn can_manage_chat(&self) -> bool {
|
pub fn can_manage_chat(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -325,6 +341,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_change_info`]: Administrator::can_change_info
|
/// [`can_change_info`]: Administrator::can_change_info
|
||||||
|
#[must_use]
|
||||||
pub fn can_change_info(&self) -> bool {
|
pub fn can_change_info(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -344,6 +361,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_post_messages`]: Administrator::can_post_messages
|
/// [`can_post_messages`]: Administrator::can_post_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_post_messages(&self) -> bool {
|
pub fn can_post_messages(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -364,6 +382,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_edit_messages`]: Administrator::can_edit_messages
|
/// [`can_edit_messages`]: Administrator::can_edit_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_edit_messages(&self) -> bool {
|
pub fn can_edit_messages(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -383,6 +402,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_delete_messages`]: Administrator::can_delete_messages
|
/// [`can_delete_messages`]: Administrator::can_delete_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_delete_messages(&self) -> bool {
|
pub fn can_delete_messages(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -403,6 +423,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_manage_video_chats`]: Administrator::can_manage_video_chats
|
/// [`can_manage_video_chats`]: Administrator::can_manage_video_chats
|
||||||
|
#[must_use]
|
||||||
pub fn can_manage_video_chats(&self) -> bool {
|
pub fn can_manage_video_chats(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -415,6 +436,7 @@ impl ChatMemberKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deprecated(since = "0.6.0", note = "renamed to `can_manage_video_chats`")]
|
#[deprecated(since = "0.6.0", note = "renamed to `can_manage_video_chats`")]
|
||||||
|
#[must_use]
|
||||||
pub fn can_manage_voice_chats(&self) -> bool {
|
pub fn can_manage_voice_chats(&self) -> bool {
|
||||||
self.can_manage_video_chats()
|
self.can_manage_video_chats()
|
||||||
}
|
}
|
||||||
|
@ -428,6 +450,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_invite_users`]: Administrator::can_invite_users
|
/// [`can_invite_users`]: Administrator::can_invite_users
|
||||||
|
#[must_use]
|
||||||
pub fn can_invite_users(&self) -> bool {
|
pub fn can_invite_users(&self) -> bool {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -447,6 +470,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_restrict_members`]: Administrator::can_restrict_members
|
/// [`can_restrict_members`]: Administrator::can_restrict_members
|
||||||
|
#[must_use]
|
||||||
pub fn can_restrict_members(&self) -> bool {
|
pub fn can_restrict_members(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -467,6 +491,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_pin_messages`]: Administrator::can_pin_messages
|
/// [`can_pin_messages`]: Administrator::can_pin_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_pin_messages(&self) -> bool {
|
pub fn can_pin_messages(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -489,6 +514,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `false` otherwise.
|
/// Returns `false` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_promote_members`]: Administrator::can_promote_members
|
/// [`can_promote_members`]: Administrator::can_promote_members
|
||||||
|
#[must_use]
|
||||||
pub fn can_promote_members(&self) -> bool {
|
pub fn can_promote_members(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Owner(_) => true,
|
Self::Owner(_) => true,
|
||||||
|
@ -512,6 +538,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` otherwise.
|
/// Returns `true` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_send_messages`]: Restricted::can_send_messages
|
/// [`can_send_messages`]: Restricted::can_send_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_send_messages(&self) -> bool {
|
pub fn can_send_messages(&self) -> bool {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Restricted(Restricted {
|
Self::Restricted(Restricted {
|
||||||
|
@ -531,6 +558,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` otherwise.
|
/// Returns `true` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_send_media_messages`]: Restricted::can_send_media_messages
|
/// [`can_send_media_messages`]: Restricted::can_send_media_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_send_media_messages(&self) -> bool {
|
pub fn can_send_media_messages(&self) -> bool {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Restricted(Restricted {
|
Self::Restricted(Restricted {
|
||||||
|
@ -551,6 +579,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` otherwise.
|
/// Returns `true` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_send_media_messages`]: Restricted::can_send_media_messages
|
/// [`can_send_media_messages`]: Restricted::can_send_media_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_send_other_messages(&self) -> bool {
|
pub fn can_send_other_messages(&self) -> bool {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Restricted(Restricted {
|
Self::Restricted(Restricted {
|
||||||
|
@ -571,6 +600,7 @@ impl ChatMemberKind {
|
||||||
/// Returns `true` otherwise.
|
/// Returns `true` otherwise.
|
||||||
///
|
///
|
||||||
/// [`can_send_media_messages`]: Restricted::can_send_media_messages
|
/// [`can_send_media_messages`]: Restricted::can_send_media_messages
|
||||||
|
#[must_use]
|
||||||
pub fn can_add_web_page_previews(&self) -> bool {
|
pub fn can_add_web_page_previews(&self) -> bool {
|
||||||
match &self {
|
match &self {
|
||||||
Self::Restricted(Restricted {
|
Self::Restricted(Restricted {
|
||||||
|
@ -601,6 +631,7 @@ impl ChatMemberStatus {
|
||||||
/// Returns `true` if the user is the [owner] of the given chat.
|
/// Returns `true` if the user is the [owner] of the given chat.
|
||||||
///
|
///
|
||||||
/// [owner]: ChatMemberKind::Owner
|
/// [owner]: ChatMemberKind::Owner
|
||||||
|
#[must_use]
|
||||||
pub fn is_owner(&self) -> bool {
|
pub fn is_owner(&self) -> bool {
|
||||||
matches!(self, Self::Owner { .. })
|
matches!(self, Self::Owner { .. })
|
||||||
}
|
}
|
||||||
|
@ -613,6 +644,7 @@ impl ChatMemberStatus {
|
||||||
/// owner of the given chat. See also: [`is_privileged`].
|
/// owner of the given chat. See also: [`is_privileged`].
|
||||||
///
|
///
|
||||||
/// [`is_privileged`]: ChatMemberKind::is_privileged
|
/// [`is_privileged`]: ChatMemberKind::is_privileged
|
||||||
|
#[must_use]
|
||||||
pub fn is_administrator(&self) -> bool {
|
pub fn is_administrator(&self) -> bool {
|
||||||
matches!(self, Self::Administrator { .. })
|
matches!(self, Self::Administrator { .. })
|
||||||
}
|
}
|
||||||
|
@ -620,6 +652,7 @@ impl ChatMemberStatus {
|
||||||
/// Returns `true` if the user is a common [member] of the given chat.
|
/// Returns `true` if the user is a common [member] of the given chat.
|
||||||
///
|
///
|
||||||
/// [member]: ChatMemberKind::Member
|
/// [member]: ChatMemberKind::Member
|
||||||
|
#[must_use]
|
||||||
pub fn is_member(&self) -> bool {
|
pub fn is_member(&self) -> bool {
|
||||||
matches!(self, Self::Member { .. })
|
matches!(self, Self::Member { .. })
|
||||||
}
|
}
|
||||||
|
@ -627,6 +660,7 @@ impl ChatMemberStatus {
|
||||||
/// Returns `true` if the user is [restricted] in the given chat.
|
/// Returns `true` if the user is [restricted] in the given chat.
|
||||||
///
|
///
|
||||||
/// [restricted]: ChatMemberKind::Restricted
|
/// [restricted]: ChatMemberKind::Restricted
|
||||||
|
#[must_use]
|
||||||
pub fn is_restricted(&self) -> bool {
|
pub fn is_restricted(&self) -> bool {
|
||||||
matches!(self, Self::Restricted { .. })
|
matches!(self, Self::Restricted { .. })
|
||||||
}
|
}
|
||||||
|
@ -634,6 +668,7 @@ impl ChatMemberStatus {
|
||||||
/// Returns `true` if the user [left] the given chat.
|
/// Returns `true` if the user [left] the given chat.
|
||||||
///
|
///
|
||||||
/// [left]: ChatMemberKind::Left
|
/// [left]: ChatMemberKind::Left
|
||||||
|
#[must_use]
|
||||||
pub fn is_left(&self) -> bool {
|
pub fn is_left(&self) -> bool {
|
||||||
matches!(self, Self::Left { .. })
|
matches!(self, Self::Left { .. })
|
||||||
}
|
}
|
||||||
|
@ -641,6 +676,7 @@ impl ChatMemberStatus {
|
||||||
/// Returns `true` if the user is [banned] in the given chat.
|
/// Returns `true` if the user is [banned] in the given chat.
|
||||||
///
|
///
|
||||||
/// [banned]: ChatMemberKind::Banned
|
/// [banned]: ChatMemberKind::Banned
|
||||||
|
#[must_use]
|
||||||
pub fn is_banned(&self) -> bool {
|
pub fn is_banned(&self) -> bool {
|
||||||
matches!(self, Self::Banned { .. })
|
matches!(self, Self::Banned { .. })
|
||||||
}
|
}
|
||||||
|
@ -653,6 +689,7 @@ impl ChatMemberStatus {
|
||||||
///
|
///
|
||||||
/// [owner]: ChatMemberKind::Owner
|
/// [owner]: ChatMemberKind::Owner
|
||||||
/// [administrator]: ChatMemberKind::Administrator
|
/// [administrator]: ChatMemberKind::Administrator
|
||||||
|
#[must_use]
|
||||||
pub fn is_privileged(&self) -> bool {
|
pub fn is_privileged(&self) -> bool {
|
||||||
self.is_administrator() || self.is_owner()
|
self.is_administrator() || self.is_owner()
|
||||||
}
|
}
|
||||||
|
@ -662,6 +699,7 @@ impl ChatMemberStatus {
|
||||||
///
|
///
|
||||||
/// [left]: ChatMemberKind::Left
|
/// [left]: ChatMemberKind::Left
|
||||||
/// [banned]: ChatMemberKind::Banned
|
/// [banned]: ChatMemberKind::Banned
|
||||||
|
#[must_use]
|
||||||
pub fn is_present(&self) -> bool {
|
pub fn is_present(&self) -> bool {
|
||||||
!(self.is_left() || self.is_banned())
|
!(self.is_left() || self.is_banned())
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct ForceReply {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ForceReply {
|
impl ForceReply {
|
||||||
|
#[must_use]
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
force_reply: True,
|
force_reply: True,
|
||||||
|
@ -49,6 +50,7 @@ impl ForceReply {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn selective(mut self, val: bool) -> Self {
|
pub const fn selective(mut self, val: bool) -> Self {
|
||||||
self.selective = Some(val);
|
self.selective = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -218,6 +218,7 @@ impl InlineKeyboardButton {
|
||||||
since = "0.7.0",
|
since = "0.7.0",
|
||||||
note = "set correct kind in the constructor or access the field directly"
|
note = "set correct kind in the constructor or access the field directly"
|
||||||
)]
|
)]
|
||||||
|
#[must_use]
|
||||||
pub fn kind(mut self, val: InlineKeyboardButtonKind) -> Self {
|
pub fn kind(mut self, val: InlineKeyboardButtonKind) -> Self {
|
||||||
self.kind = val;
|
self.kind = val;
|
||||||
self
|
self
|
||||||
|
|
|
@ -66,6 +66,7 @@ impl InlineKeyboardMarkup {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn append_to_row(mut self, index: usize, button: InlineKeyboardButton) -> Self {
|
pub fn append_to_row(mut self, index: usize, button: InlineKeyboardButton) -> Self {
|
||||||
match self.inline_keyboard.get_mut(index) {
|
match self.inline_keyboard.get_mut(index) {
|
||||||
Some(buttons) => buttons.push(button),
|
Some(buttons) => buttons.push(button),
|
||||||
|
|
|
@ -60,11 +60,13 @@ impl InlineQuery {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn from(mut self, val: User) -> Self {
|
pub fn from(mut self, val: User) -> Self {
|
||||||
self.from = val;
|
self.from = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn location(mut self, val: Location) -> Self {
|
pub fn location(mut self, val: Location) -> Self {
|
||||||
self.location = Some(val);
|
self.location = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -76,21 +76,25 @@ impl InlineQueryResultArticle {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = val;
|
self.input_message_content = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn url(mut self, val: reqwest::Url) -> Self {
|
pub fn url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.url = Some(val);
|
self.url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn hide_url(mut self, val: bool) -> Self {
|
pub fn hide_url(mut self, val: bool) -> Self {
|
||||||
self.hide_url = Some(val);
|
self.hide_url = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -104,16 +108,19 @@ impl InlineQueryResultArticle {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = Some(val);
|
self.thumb_url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||||
self.thumb_width = Some(val);
|
self.thumb_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||||
self.thumb_height = Some(val);
|
self.thumb_height = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -79,6 +79,7 @@ impl InlineQueryResultAudio {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn audio_url(mut self, val: reqwest::Url) -> Self {
|
pub fn audio_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.audio_url = val;
|
self.audio_url = val;
|
||||||
self
|
self
|
||||||
|
@ -100,6 +101,7 @@ impl InlineQueryResultAudio {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -129,11 +131,13 @@ impl InlineQueryResultAudio {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -83,6 +83,7 @@ impl InlineQueryResultCachedAudio {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -96,11 +97,13 @@ impl InlineQueryResultCachedAudio {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -108,6 +108,7 @@ impl InlineQueryResultCachedDocument {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -121,11 +122,13 @@ impl InlineQueryResultCachedDocument {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -96,6 +96,7 @@ impl InlineQueryResultCachedGif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -109,11 +110,13 @@ impl InlineQueryResultCachedGif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -88,6 +88,7 @@ impl InlineQueryResultCachedMpeg4Gif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -101,11 +102,13 @@ impl InlineQueryResultCachedMpeg4Gif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -107,6 +107,7 @@ impl InlineQueryResultCachedPhoto {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -120,11 +121,13 @@ impl InlineQueryResultCachedPhoto {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -57,11 +57,13 @@ impl InlineQueryResultCachedSticker {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -108,6 +108,7 @@ impl InlineQueryResultCachedVideo {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -121,11 +122,13 @@ impl InlineQueryResultCachedVideo {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -96,6 +96,7 @@ impl InlineQueryResultCachedVoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -109,11 +110,13 @@ impl InlineQueryResultCachedVoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -109,26 +109,31 @@ impl InlineQueryResultContact {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = Some(val);
|
self.thumb_url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||||
self.thumb_width = Some(val);
|
self.thumb_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||||
self.thumb_height = Some(val);
|
self.thumb_height = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -87,6 +87,7 @@ impl InlineQueryResultDocument {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -100,11 +101,13 @@ impl InlineQueryResultDocument {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn document_url(mut self, val: reqwest::Url) -> Self {
|
pub fn document_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.document_url = val;
|
self.document_url = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||||
self.mime_type = val;
|
self.mime_type = val;
|
||||||
self
|
self
|
||||||
|
@ -118,26 +121,31 @@ impl InlineQueryResultDocument {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = Some(val);
|
self.thumb_url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||||
self.thumb_width = Some(val);
|
self.thumb_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||||
self.thumb_height = Some(val);
|
self.thumb_height = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -51,6 +51,7 @@ impl InlineQueryResultGame {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -86,26 +86,31 @@ impl InlineQueryResultGif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn gif_url(mut self, val: reqwest::Url) -> Self {
|
pub fn gif_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.gif_url = val;
|
self.gif_url = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn gif_width(mut self, val: i32) -> Self {
|
pub fn gif_width(mut self, val: i32) -> Self {
|
||||||
self.gif_width = Some(val);
|
self.gif_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn gif_height(mut self, val: i32) -> Self {
|
pub fn gif_height(mut self, val: i32) -> Self {
|
||||||
self.gif_height = Some(val);
|
self.gif_height = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn gif_duration(mut self, val: i32) -> Self {
|
pub fn gif_duration(mut self, val: i32) -> Self {
|
||||||
self.gif_duration = Some(val);
|
self.gif_duration = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = val;
|
self.thumb_url = val;
|
||||||
self
|
self
|
||||||
|
@ -127,6 +132,7 @@ impl InlineQueryResultGif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -140,11 +146,13 @@ impl InlineQueryResultGif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -89,11 +89,13 @@ impl InlineQueryResultLocation {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn latitude(mut self, val: f64) -> Self {
|
pub fn latitude(mut self, val: f64) -> Self {
|
||||||
self.latitude = val;
|
self.latitude = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn longitude(mut self, val: f64) -> Self {
|
pub fn longitude(mut self, val: f64) -> Self {
|
||||||
self.longitude = val;
|
self.longitude = val;
|
||||||
self
|
self
|
||||||
|
@ -107,46 +109,55 @@ impl InlineQueryResultLocation {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn horizontal_accuracy<S>(mut self, val: f64) -> Self {
|
pub fn horizontal_accuracy<S>(mut self, val: f64) -> Self {
|
||||||
self.horizontal_accuracy = Some(val);
|
self.horizontal_accuracy = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn live_period(mut self, val: i32) -> Self {
|
pub fn live_period(mut self, val: i32) -> Self {
|
||||||
self.live_period = Some(val);
|
self.live_period = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn heading(mut self, val: u16) -> Self {
|
pub fn heading(mut self, val: u16) -> Self {
|
||||||
self.heading = Some(val);
|
self.heading = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn proximity_alert_radius(mut self, val: u32) -> Self {
|
pub fn proximity_alert_radius(mut self, val: u32) -> Self {
|
||||||
self.proximity_alert_radius = Some(val);
|
self.proximity_alert_radius = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = Some(val);
|
self.thumb_url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||||
self.thumb_width = Some(val);
|
self.thumb_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||||
self.thumb_height = Some(val);
|
self.thumb_height = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -87,26 +87,31 @@ impl InlineQueryResultMpeg4Gif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn mpeg4_url(mut self, val: reqwest::Url) -> Self {
|
pub fn mpeg4_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.mpeg4_url = val;
|
self.mpeg4_url = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn mpeg4_width(mut self, val: i32) -> Self {
|
pub fn mpeg4_width(mut self, val: i32) -> Self {
|
||||||
self.mpeg4_width = Some(val);
|
self.mpeg4_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn mpeg4_height(mut self, val: i32) -> Self {
|
pub fn mpeg4_height(mut self, val: i32) -> Self {
|
||||||
self.mpeg4_height = Some(val);
|
self.mpeg4_height = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn mpeg4_duration(mut self, val: i32) -> Self {
|
pub fn mpeg4_duration(mut self, val: i32) -> Self {
|
||||||
self.mpeg4_duration = Some(val);
|
self.mpeg4_duration = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = val;
|
self.thumb_url = val;
|
||||||
self
|
self
|
||||||
|
@ -128,6 +133,7 @@ impl InlineQueryResultMpeg4Gif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -141,11 +147,13 @@ impl InlineQueryResultMpeg4Gif {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -87,21 +87,25 @@ impl InlineQueryResultPhoto {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_url(mut self, val: reqwest::Url) -> Self {
|
pub fn photo_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.photo_url = val;
|
self.photo_url = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url<S>(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url<S>(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = val;
|
self.thumb_url = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_width(mut self, val: i32) -> Self {
|
pub fn photo_width(mut self, val: i32) -> Self {
|
||||||
self.photo_width = Some(val);
|
self.photo_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_height(mut self, val: i32) -> Self {
|
pub fn photo_height(mut self, val: i32) -> Self {
|
||||||
self.photo_height = Some(val);
|
self.photo_height = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -131,6 +135,7 @@ impl InlineQueryResultPhoto {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -144,11 +149,13 @@ impl InlineQueryResultPhoto {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -94,11 +94,13 @@ impl InlineQueryResultVenue {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn latitude(mut self, val: f64) -> Self {
|
pub fn latitude(mut self, val: f64) -> Self {
|
||||||
self.latitude = val;
|
self.latitude = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn longitude(mut self, val: f64) -> Self {
|
pub fn longitude(mut self, val: f64) -> Self {
|
||||||
self.longitude = val;
|
self.longitude = val;
|
||||||
self
|
self
|
||||||
|
@ -152,26 +154,31 @@ impl InlineQueryResultVenue {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = Some(val);
|
self.thumb_url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||||
self.thumb_width = Some(val);
|
self.thumb_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||||
self.thumb_height = Some(val);
|
self.thumb_height = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -109,16 +109,19 @@ impl InlineQueryResultVideo {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn video_url(mut self, val: reqwest::Url) -> Self {
|
pub fn video_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.video_url = val;
|
self.video_url = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||||
self.mime_type = val;
|
self.mime_type = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
pub fn thumb_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.thumb_url = val;
|
self.thumb_url = val;
|
||||||
self
|
self
|
||||||
|
@ -140,6 +143,7 @@ impl InlineQueryResultVideo {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -153,16 +157,19 @@ impl InlineQueryResultVideo {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn video_width(mut self, val: i32) -> Self {
|
pub fn video_width(mut self, val: i32) -> Self {
|
||||||
self.video_width = Some(val);
|
self.video_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn video_height(mut self, val: i32) -> Self {
|
pub fn video_height(mut self, val: i32) -> Self {
|
||||||
self.video_height = Some(val);
|
self.video_height = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn video_duration(mut self, val: i32) -> Self {
|
pub fn video_duration(mut self, val: i32) -> Self {
|
||||||
self.video_duration = Some(val);
|
self.video_duration = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -176,11 +183,13 @@ impl InlineQueryResultVideo {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -76,6 +76,7 @@ impl InlineQueryResultVoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn voice_url(mut self, val: reqwest::Url) -> Self {
|
pub fn voice_url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.voice_url = val;
|
self.voice_url = val;
|
||||||
self
|
self
|
||||||
|
@ -97,6 +98,7 @@ impl InlineQueryResultVoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -110,16 +112,19 @@ impl InlineQueryResultVoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn voice_duration(mut self, value: i32) -> Self {
|
pub fn voice_duration(mut self, value: i32) -> Self {
|
||||||
self.voice_duration = Some(value);
|
self.voice_duration = Some(value);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||||
self.reply_markup = Some(val);
|
self.reply_markup = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
pub fn input_message_content(mut self, val: InputMessageContent) -> Self {
|
||||||
self.input_message_content = Some(val);
|
self.input_message_content = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -64,6 +64,7 @@ impl InputFile {
|
||||||
/// [`SendAudio`]: crate::payloads::SendAudio
|
/// [`SendAudio`]: crate::payloads::SendAudio
|
||||||
/// [`SendDocument`]: crate::payloads::SendDocument
|
/// [`SendDocument`]: crate::payloads::SendDocument
|
||||||
/// [`SendVoice`]: crate::payloads::SendVoice
|
/// [`SendVoice`]: crate::payloads::SendVoice
|
||||||
|
#[must_use]
|
||||||
pub fn url(url: url::Url) -> Self {
|
pub fn url(url: url::Url) -> Self {
|
||||||
Self::new(Url(url))
|
Self::new(Url(url))
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ impl InputMessageContentText {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||||
self.parse_mode = Some(val);
|
self.parse_mode = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -74,6 +75,7 @@ impl InputMessageContentText {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn disable_web_page_preview(mut self, val: bool) -> Self {
|
pub fn disable_web_page_preview(mut self, val: bool) -> Self {
|
||||||
self.disable_web_page_preview = Some(val);
|
self.disable_web_page_preview = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -109,6 +111,7 @@ pub struct InputMessageContentLocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputMessageContentLocation {
|
impl InputMessageContentLocation {
|
||||||
|
#[must_use]
|
||||||
pub const fn new(latitude: f64, longitude: f64) -> Self {
|
pub const fn new(latitude: f64, longitude: f64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
latitude,
|
latitude,
|
||||||
|
@ -120,16 +123,19 @@ impl InputMessageContentLocation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn latitude(mut self, val: f64) -> Self {
|
pub const fn latitude(mut self, val: f64) -> Self {
|
||||||
self.latitude = val;
|
self.latitude = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn longitude(mut self, val: f64) -> Self {
|
pub const fn longitude(mut self, val: f64) -> Self {
|
||||||
self.longitude = val;
|
self.longitude = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn live_period(mut self, val: u32) -> Self {
|
pub const fn live_period(mut self, val: u32) -> Self {
|
||||||
self.live_period = Some(val);
|
self.live_period = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -188,11 +194,13 @@ impl InputMessageContentVenue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn latitude(mut self, val: f64) -> Self {
|
pub fn latitude(mut self, val: f64) -> Self {
|
||||||
self.latitude = val;
|
self.latitude = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn longitude(mut self, val: f64) -> Self {
|
pub fn longitude(mut self, val: f64) -> Self {
|
||||||
self.longitude = val;
|
self.longitude = val;
|
||||||
self
|
self
|
||||||
|
@ -465,6 +473,7 @@ impl InputMessageContentInvoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn currency(mut self, val: Currency) -> Self {
|
pub fn currency(mut self, val: Currency) -> Self {
|
||||||
self.currency = val;
|
self.currency = val;
|
||||||
self
|
self
|
||||||
|
@ -478,6 +487,7 @@ impl InputMessageContentInvoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn max_tip_amount(mut self, val: u32) -> Self {
|
pub fn max_tip_amount(mut self, val: u32) -> Self {
|
||||||
self.max_tip_amount = Some(val);
|
self.max_tip_amount = Some(val);
|
||||||
self
|
self
|
||||||
|
@ -499,57 +509,68 @@ impl InputMessageContentInvoice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_url(mut self, val: Url) -> Self {
|
pub fn photo_url(mut self, val: Url) -> Self {
|
||||||
self.photo_url = Some(val);
|
self.photo_url = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_size(mut self, val: u32) -> Self {
|
pub fn photo_size(mut self, val: u32) -> Self {
|
||||||
self.photo_size = Some(val);
|
self.photo_size = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_width(mut self, val: u32) -> Self {
|
pub fn photo_width(mut self, val: u32) -> Self {
|
||||||
self.photo_width = Some(val);
|
self.photo_width = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo_height(mut self, val: u32) -> Self {
|
pub fn photo_height(mut self, val: u32) -> Self {
|
||||||
self.photo_height = Some(val);
|
self.photo_height = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn need_name(mut self, val: bool) -> Self {
|
pub fn need_name(mut self, val: bool) -> Self {
|
||||||
self.need_name = Some(val);
|
self.need_name = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn need_phone_number(mut self, val: bool) -> Self {
|
pub fn need_phone_number(mut self, val: bool) -> Self {
|
||||||
self.need_phone_number = Some(val);
|
self.need_phone_number = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn need_email(mut self, val: bool) -> Self {
|
pub fn need_email(mut self, val: bool) -> Self {
|
||||||
self.need_email = Some(val);
|
self.need_email = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn need_shipping_address(mut self, val: bool) -> Self {
|
pub fn need_shipping_address(mut self, val: bool) -> Self {
|
||||||
self.need_shipping_address = Some(val);
|
self.need_shipping_address = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn send_phone_number_to_provider(mut self, val: bool) -> Self {
|
pub fn send_phone_number_to_provider(mut self, val: bool) -> Self {
|
||||||
self.send_phone_number_to_provider = Some(val);
|
self.send_phone_number_to_provider = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn send_email_to_provider(mut self, val: bool) -> Self {
|
pub fn send_email_to_provider(mut self, val: bool) -> Self {
|
||||||
self.send_email_to_provider = Some(val);
|
self.send_email_to_provider = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
|
#[must_use]
|
||||||
pub fn is_flexible(mut self, val: bool) -> Self {
|
pub fn is_flexible(mut self, val: bool) -> Self {
|
||||||
self.is_flexible = Some(val);
|
self.is_flexible = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -38,6 +38,7 @@ impl LabeledPrice {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn amount(mut self, val: i32) -> Self {
|
pub fn amount(mut self, val: i32) -> Self {
|
||||||
self.amount = val;
|
self.amount = val;
|
||||||
self
|
self
|
||||||
|
|
|
@ -46,6 +46,7 @@ pub struct LoginUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginUrl {
|
impl LoginUrl {
|
||||||
|
#[must_use]
|
||||||
pub fn url(mut self, val: reqwest::Url) -> Self {
|
pub fn url(mut self, val: reqwest::Url) -> Self {
|
||||||
self.url = val;
|
self.url = val;
|
||||||
self
|
self
|
||||||
|
@ -67,6 +68,7 @@ impl LoginUrl {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn request_write_access(mut self, val: bool) -> Self {
|
pub fn request_write_access(mut self, val: bool) -> Self {
|
||||||
self.request_write_access = Some(val);
|
self.request_write_access = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -45,16 +45,19 @@ impl MaskPosition {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn x_shift(mut self, val: f64) -> Self {
|
pub fn x_shift(mut self, val: f64) -> Self {
|
||||||
self.x_shift = val;
|
self.x_shift = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn y_shift(mut self, val: f64) -> Self {
|
pub fn y_shift(mut self, val: f64) -> Self {
|
||||||
self.y_shift = val;
|
self.y_shift = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn scale(mut self, val: f64) -> Self {
|
pub fn scale(mut self, val: f64) -> Self {
|
||||||
self.scale = val;
|
self.scale = val;
|
||||||
self
|
self
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub struct Me {
|
||||||
|
|
||||||
impl Me {
|
impl Me {
|
||||||
/// Returns the username of the bot.
|
/// Returns the username of the bot.
|
||||||
|
#[must_use]
|
||||||
pub fn username(&self) -> &str {
|
pub fn username(&self) -> &str {
|
||||||
self.user
|
self.user
|
||||||
.username
|
.username
|
||||||
|
@ -34,11 +35,13 @@ impl Me {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a username mention of this bot.
|
/// Returns a username mention of this bot.
|
||||||
|
#[must_use]
|
||||||
pub fn mention(&self) -> String {
|
pub fn mention(&self) -> String {
|
||||||
format!("@{}", self.username())
|
format!("@{}", self.username())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an URL that links to this bot in the form of `t.me/<...>`.
|
/// Returns an URL that links to this bot in the form of `t.me/<...>`.
|
||||||
|
#[must_use]
|
||||||
pub fn tme_url(&self) -> reqwest::Url {
|
pub fn tme_url(&self) -> reqwest::Url {
|
||||||
format!("https://t.me/{}", self.username()).parse().unwrap()
|
format!("https://t.me/{}", self.username()).parse().unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -544,6 +544,7 @@ mod getters {
|
||||||
/// [Message]: crate::types::Message
|
/// [Message]: crate::types::Message
|
||||||
/// [telegram docs]: https://core.telegram.org/bots/api#message
|
/// [telegram docs]: https://core.telegram.org/bots/api#message
|
||||||
impl Message {
|
impl Message {
|
||||||
|
#[must_use]
|
||||||
pub fn from(&self) -> Option<&User> {
|
pub fn from(&self) -> Option<&User> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon { from, .. }) => from.as_ref(),
|
Common(MessageCommon { from, .. }) => from.as_ref(),
|
||||||
|
@ -551,6 +552,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn author_signature(&self) -> Option<&str> {
|
pub fn author_signature(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -560,6 +562,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn sender_chat(&self) -> Option<&Chat> {
|
pub fn sender_chat(&self) -> Option<&Chat> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon { sender_chat, .. }) => sender_chat.as_ref(),
|
Common(MessageCommon { sender_chat, .. }) => sender_chat.as_ref(),
|
||||||
|
@ -568,22 +571,27 @@ mod getters {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deprecated(since = "0.4.2", note = "use `.chat.id` field instead")]
|
#[deprecated(since = "0.4.2", note = "use `.chat.id` field instead")]
|
||||||
|
#[must_use]
|
||||||
pub fn chat_id(&self) -> ChatId {
|
pub fn chat_id(&self) -> ChatId {
|
||||||
self.chat.id
|
self.chat.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward(&self) -> Option<&Forward> {
|
pub fn forward(&self) -> Option<&Forward> {
|
||||||
self.common().and_then(|m| m.forward.as_ref())
|
self.common().and_then(|m| m.forward.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_date(&self) -> Option<DateTime<Utc>> {
|
pub fn forward_date(&self) -> Option<DateTime<Utc>> {
|
||||||
self.forward().map(|f| f.date)
|
self.forward().map(|f| f.date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_from(&self) -> Option<&ForwardedFrom> {
|
pub fn forward_from(&self) -> Option<&ForwardedFrom> {
|
||||||
self.forward().map(|f| &f.from)
|
self.forward().map(|f| &f.from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_from_user(&self) -> Option<&User> {
|
pub fn forward_from_user(&self) -> Option<&User> {
|
||||||
self.forward_from().and_then(|from| match from {
|
self.forward_from().and_then(|from| match from {
|
||||||
ForwardedFrom::User(user) => Some(user),
|
ForwardedFrom::User(user) => Some(user),
|
||||||
|
@ -591,6 +599,7 @@ mod getters {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_from_chat(&self) -> Option<&Chat> {
|
pub fn forward_from_chat(&self) -> Option<&Chat> {
|
||||||
self.forward_from().and_then(|from| match from {
|
self.forward_from().and_then(|from| match from {
|
||||||
ForwardedFrom::Chat(chat) => Some(chat),
|
ForwardedFrom::Chat(chat) => Some(chat),
|
||||||
|
@ -598,6 +607,7 @@ mod getters {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_from_sender_name(&self) -> Option<&str> {
|
pub fn forward_from_sender_name(&self) -> Option<&str> {
|
||||||
self.forward_from().and_then(|from| match from {
|
self.forward_from().and_then(|from| match from {
|
||||||
ForwardedFrom::SenderName(sender_name) => Some(&**sender_name),
|
ForwardedFrom::SenderName(sender_name) => Some(&**sender_name),
|
||||||
|
@ -605,18 +615,22 @@ mod getters {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_from_message_id(&self) -> Option<i32> {
|
pub fn forward_from_message_id(&self) -> Option<i32> {
|
||||||
self.forward().and_then(|f| f.message_id)
|
self.forward().and_then(|f| f.message_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn forward_signature(&self) -> Option<&str> {
|
pub fn forward_signature(&self) -> Option<&str> {
|
||||||
self.forward().and_then(|f| f.signature.as_deref())
|
self.forward().and_then(|f| f.signature.as_deref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_to_message(&self) -> Option<&Message> {
|
pub fn reply_to_message(&self) -> Option<&Message> {
|
||||||
self.common().and_then(|m| m.reply_to_message.as_deref())
|
self.common().and_then(|m| m.reply_to_message.as_deref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn edit_date(&self) -> Option<&DateTime<Utc>> {
|
pub fn edit_date(&self) -> Option<&DateTime<Utc>> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon { edit_date, .. }) => edit_date.as_ref(),
|
Common(MessageCommon { edit_date, .. }) => edit_date.as_ref(),
|
||||||
|
@ -624,6 +638,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn media_group_id(&self) -> Option<&str> {
|
pub fn media_group_id(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -646,6 +661,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn text(&self) -> Option<&str> {
|
pub fn text(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -668,6 +684,7 @@ mod getters {
|
||||||
///
|
///
|
||||||
/// [`parse_entities`]: Message::parse_entities
|
/// [`parse_entities`]: Message::parse_entities
|
||||||
/// [`caption_entities`]: Message::caption_entities
|
/// [`caption_entities`]: Message::caption_entities
|
||||||
|
#[must_use]
|
||||||
pub fn entities(&self) -> Option<&[MessageEntity]> {
|
pub fn entities(&self) -> Option<&[MessageEntity]> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -690,6 +707,7 @@ mod getters {
|
||||||
///
|
///
|
||||||
/// [`parse_caption_entities`]: Message::parse_caption_entities
|
/// [`parse_caption_entities`]: Message::parse_caption_entities
|
||||||
/// [`entities`]: Message::entities
|
/// [`entities`]: Message::entities
|
||||||
|
#[must_use]
|
||||||
pub fn caption_entities(&self) -> Option<&[MessageEntity]> {
|
pub fn caption_entities(&self) -> Option<&[MessageEntity]> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -738,6 +756,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn audio(&self) -> Option<&types::Audio> {
|
pub fn audio(&self) -> Option<&types::Audio> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -748,6 +767,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn document(&self) -> Option<&types::Document> {
|
pub fn document(&self) -> Option<&types::Document> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -758,6 +778,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn animation(&self) -> Option<&types::Animation> {
|
pub fn animation(&self) -> Option<&types::Animation> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -768,6 +789,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn game(&self) -> Option<&types::Game> {
|
pub fn game(&self) -> Option<&types::Game> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -778,6 +800,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn photo(&self) -> Option<&[PhotoSize]> {
|
pub fn photo(&self) -> Option<&[PhotoSize]> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -788,6 +811,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn sticker(&self) -> Option<&types::Sticker> {
|
pub fn sticker(&self) -> Option<&types::Sticker> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -798,6 +822,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn video(&self) -> Option<&types::Video> {
|
pub fn video(&self) -> Option<&types::Video> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -808,6 +833,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn voice(&self) -> Option<&types::Voice> {
|
pub fn voice(&self) -> Option<&types::Voice> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -818,6 +844,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn video_note(&self) -> Option<&types::VideoNote> {
|
pub fn video_note(&self) -> Option<&types::VideoNote> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -828,6 +855,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn caption(&self) -> Option<&str> {
|
pub fn caption(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon { media_kind, .. }) => match media_kind {
|
Common(MessageCommon { media_kind, .. }) => match media_kind {
|
||||||
|
@ -845,6 +873,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn contact(&self) -> Option<&types::Contact> {
|
pub fn contact(&self) -> Option<&types::Contact> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -855,6 +884,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn location(&self) -> Option<&types::Location> {
|
pub fn location(&self) -> Option<&types::Location> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -865,6 +895,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn venue(&self) -> Option<&types::Venue> {
|
pub fn venue(&self) -> Option<&types::Venue> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -875,6 +906,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn poll(&self) -> Option<&types::Poll> {
|
pub fn poll(&self) -> Option<&types::Poll> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -885,6 +917,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn new_chat_members(&self) -> Option<&[User]> {
|
pub fn new_chat_members(&self) -> Option<&[User]> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
NewChatMembers(MessageNewChatMembers { new_chat_members }) => {
|
NewChatMembers(MessageNewChatMembers { new_chat_members }) => {
|
||||||
|
@ -894,6 +927,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn left_chat_member(&self) -> Option<&User> {
|
pub fn left_chat_member(&self) -> Option<&User> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
LeftChatMember(MessageLeftChatMember { left_chat_member }) => {
|
LeftChatMember(MessageLeftChatMember { left_chat_member }) => {
|
||||||
|
@ -903,6 +937,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn new_chat_title(&self) -> Option<&str> {
|
pub fn new_chat_title(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
NewChatTitle(MessageNewChatTitle { new_chat_title }) => Some(new_chat_title),
|
NewChatTitle(MessageNewChatTitle { new_chat_title }) => Some(new_chat_title),
|
||||||
|
@ -910,6 +945,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn new_chat_photo(&self) -> Option<&[PhotoSize]> {
|
pub fn new_chat_photo(&self) -> Option<&[PhotoSize]> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
NewChatPhoto(MessageNewChatPhoto { new_chat_photo }) => Some(new_chat_photo),
|
NewChatPhoto(MessageNewChatPhoto { new_chat_photo }) => Some(new_chat_photo),
|
||||||
|
@ -919,6 +955,7 @@ mod getters {
|
||||||
|
|
||||||
// TODO: OK, `Option<True>` is weird, can we do something with it?
|
// TODO: OK, `Option<True>` is weird, can we do something with it?
|
||||||
// mb smt like `is_delete_chat_photo(&self) -> bool`?
|
// mb smt like `is_delete_chat_photo(&self) -> bool`?
|
||||||
|
#[must_use]
|
||||||
pub fn delete_chat_photo(&self) -> Option<True> {
|
pub fn delete_chat_photo(&self) -> Option<True> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
DeleteChatPhoto(MessageDeleteChatPhoto { delete_chat_photo }) => {
|
DeleteChatPhoto(MessageDeleteChatPhoto { delete_chat_photo }) => {
|
||||||
|
@ -928,6 +965,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn group_chat_created(&self) -> Option<True> {
|
pub fn group_chat_created(&self) -> Option<True> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
GroupChatCreated(MessageGroupChatCreated { group_chat_created }) => {
|
GroupChatCreated(MessageGroupChatCreated { group_chat_created }) => {
|
||||||
|
@ -937,6 +975,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn super_group_chat_created(&self) -> Option<True> {
|
pub fn super_group_chat_created(&self) -> Option<True> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
SupergroupChatCreated(MessageSupergroupChatCreated {
|
SupergroupChatCreated(MessageSupergroupChatCreated {
|
||||||
|
@ -946,6 +985,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn channel_chat_created(&self) -> Option<True> {
|
pub fn channel_chat_created(&self) -> Option<True> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ChannelChatCreated(MessageChannelChatCreated {
|
ChannelChatCreated(MessageChannelChatCreated {
|
||||||
|
@ -955,6 +995,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn chat_migration(&self) -> Option<ChatMigration> {
|
pub fn chat_migration(&self) -> Option<ChatMigration> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -965,6 +1006,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn migrate_to_chat_id(&self) -> Option<ChatId> {
|
pub fn migrate_to_chat_id(&self) -> Option<ChatId> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -975,6 +1017,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn migrate_from_chat_id(&self) -> Option<ChatId> {
|
pub fn migrate_from_chat_id(&self) -> Option<ChatId> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -985,6 +1028,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn pinned_message(&self) -> Option<&Message> {
|
pub fn pinned_message(&self) -> Option<&Message> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Pinned(MessagePinned { pinned }) => Some(pinned),
|
Pinned(MessagePinned { pinned }) => Some(pinned),
|
||||||
|
@ -992,6 +1036,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn invoice(&self) -> Option<&types::Invoice> {
|
pub fn invoice(&self) -> Option<&types::Invoice> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Invoice(MessageInvoice { invoice }) => Some(invoice),
|
Invoice(MessageInvoice { invoice }) => Some(invoice),
|
||||||
|
@ -999,6 +1044,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn successful_payment(&self) -> Option<&types::SuccessfulPayment> {
|
pub fn successful_payment(&self) -> Option<&types::SuccessfulPayment> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
SuccessfulPayment(MessageSuccessfulPayment { successful_payment }) => {
|
SuccessfulPayment(MessageSuccessfulPayment { successful_payment }) => {
|
||||||
|
@ -1008,6 +1054,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn connected_website(&self) -> Option<&str> {
|
pub fn connected_website(&self) -> Option<&str> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ConnectedWebsite(MessageConnectedWebsite { connected_website }) => {
|
ConnectedWebsite(MessageConnectedWebsite { connected_website }) => {
|
||||||
|
@ -1017,6 +1064,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn passport_data(&self) -> Option<&types::PassportData> {
|
pub fn passport_data(&self) -> Option<&types::PassportData> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
PassportData(MessagePassportData { passport_data }) => Some(passport_data),
|
PassportData(MessagePassportData { passport_data }) => Some(passport_data),
|
||||||
|
@ -1024,6 +1072,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn dice(&self) -> Option<&types::Dice> {
|
pub fn dice(&self) -> Option<&types::Dice> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Dice(MessageDice { dice }) => Some(dice),
|
Dice(MessageDice { dice }) => Some(dice),
|
||||||
|
@ -1031,6 +1080,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn proximity_alert_triggered(&self) -> Option<&types::ProximityAlertTriggered> {
|
pub fn proximity_alert_triggered(&self) -> Option<&types::ProximityAlertTriggered> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ProximityAlertTriggered(MessageProximityAlertTriggered {
|
ProximityAlertTriggered(MessageProximityAlertTriggered {
|
||||||
|
@ -1040,6 +1090,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn reply_markup(&self) -> Option<&types::InlineKeyboardMarkup> {
|
pub fn reply_markup(&self) -> Option<&types::InlineKeyboardMarkup> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon { reply_markup, .. }) => reply_markup.as_ref(),
|
Common(MessageCommon { reply_markup, .. }) => reply_markup.as_ref(),
|
||||||
|
@ -1047,6 +1098,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn is_automatic_forward(&self) -> bool {
|
pub fn is_automatic_forward(&self) -> bool {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -1057,6 +1109,7 @@ mod getters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn has_protected_content(&self) -> bool {
|
pub fn has_protected_content(&self) -> bool {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
Common(MessageCommon {
|
Common(MessageCommon {
|
||||||
|
@ -1085,6 +1138,7 @@ impl Message {
|
||||||
///
|
///
|
||||||
/// Returns `None` for private chats (i.e.: DMs) and private groups (not
|
/// Returns `None` for private chats (i.e.: DMs) and private groups (not
|
||||||
/// supergroups).
|
/// supergroups).
|
||||||
|
#[must_use]
|
||||||
pub fn url(&self) -> Option<Url> {
|
pub fn url(&self) -> Option<Url> {
|
||||||
Self::url_of(self.chat.id, self.chat.username(), self.id)
|
Self::url_of(self.chat.id, self.chat.username(), self.id)
|
||||||
}
|
}
|
||||||
|
@ -1103,6 +1157,7 @@ impl Message {
|
||||||
///
|
///
|
||||||
/// [`url`]: Message::url
|
/// [`url`]: Message::url
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
#[must_use]
|
||||||
pub fn url_of(chat_id: ChatId, chat_username: Option<&str>, message_id: i32) -> Option<Url> {
|
pub fn url_of(chat_id: ChatId, chat_username: Option<&str>, message_id: i32) -> Option<Url> {
|
||||||
use BareChatId::*;
|
use BareChatId::*;
|
||||||
|
|
||||||
|
@ -1146,6 +1201,7 @@ impl Message {
|
||||||
///
|
///
|
||||||
/// Returns `None` for private chats (i.e.: DMs) and private groups (not
|
/// Returns `None` for private chats (i.e.: DMs) and private groups (not
|
||||||
/// supergroups).
|
/// supergroups).
|
||||||
|
#[must_use]
|
||||||
pub fn comment_url(&self, comment_id: i32) -> Option<Url> {
|
pub fn comment_url(&self, comment_id: i32) -> Option<Url> {
|
||||||
Self::comment_url_of(self.chat.id, self.chat.username(), self.id, comment_id)
|
Self::comment_url_of(self.chat.id, self.chat.username(), self.id, comment_id)
|
||||||
}
|
}
|
||||||
|
@ -1164,6 +1220,7 @@ impl Message {
|
||||||
/// supergroups).
|
/// supergroups).
|
||||||
///
|
///
|
||||||
/// [`comment_url`]: Message::comment_url
|
/// [`comment_url`]: Message::comment_url
|
||||||
|
#[must_use]
|
||||||
pub fn comment_url_of(
|
pub fn comment_url_of(
|
||||||
channel_id: ChatId,
|
channel_id: ChatId,
|
||||||
channel_username: Option<&str>,
|
channel_username: Option<&str>,
|
||||||
|
@ -1187,6 +1244,7 @@ impl Message {
|
||||||
///
|
///
|
||||||
/// Returns `None` for private chats (i.e.: DMs) and private groups (not
|
/// Returns `None` for private chats (i.e.: DMs) and private groups (not
|
||||||
/// supergroups).
|
/// supergroups).
|
||||||
|
#[must_use]
|
||||||
pub fn url_in_thread(&self, thread_starter_msg_id: i32) -> Option<Url> {
|
pub fn url_in_thread(&self, thread_starter_msg_id: i32) -> Option<Url> {
|
||||||
Self::url_in_thread_of(
|
Self::url_in_thread_of(
|
||||||
self.chat.id,
|
self.chat.id,
|
||||||
|
@ -1214,6 +1272,7 @@ impl Message {
|
||||||
/// supergroups).
|
/// supergroups).
|
||||||
///
|
///
|
||||||
/// [`url_in_thread`]: Message::url_in_thread
|
/// [`url_in_thread`]: Message::url_in_thread
|
||||||
|
#[must_use]
|
||||||
pub fn url_in_thread_of(
|
pub fn url_in_thread_of(
|
||||||
chat_id: ChatId,
|
chat_id: ChatId,
|
||||||
chat_username: Option<&str>,
|
chat_username: Option<&str>,
|
||||||
|
@ -1235,6 +1294,7 @@ impl Message {
|
||||||
/// See also: [`parse_caption_entities`].
|
/// See also: [`parse_caption_entities`].
|
||||||
///
|
///
|
||||||
/// [`parse_caption_entities`]: Message::parse_caption_entities
|
/// [`parse_caption_entities`]: Message::parse_caption_entities
|
||||||
|
#[must_use]
|
||||||
pub fn parse_entities(&self) -> Option<Vec<MessageEntityRef<'_>>> {
|
pub fn parse_entities(&self) -> Option<Vec<MessageEntityRef<'_>>> {
|
||||||
self.text()
|
self.text()
|
||||||
.zip(self.entities())
|
.zip(self.entities())
|
||||||
|
@ -1249,6 +1309,7 @@ impl Message {
|
||||||
/// See also: [`parse_entities`].
|
/// See also: [`parse_entities`].
|
||||||
///
|
///
|
||||||
/// [`parse_entities`]: Message::parse_entities
|
/// [`parse_entities`]: Message::parse_entities
|
||||||
|
#[must_use]
|
||||||
pub fn parse_caption_entities(&self) -> Option<Vec<MessageEntityRef<'_>>> {
|
pub fn parse_caption_entities(&self) -> Option<Vec<MessageEntityRef<'_>>> {
|
||||||
self.caption()
|
self.caption()
|
||||||
.zip(self.caption_entities())
|
.zip(self.caption_entities())
|
||||||
|
|
|
@ -43,6 +43,7 @@ pub struct MessageEntityRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageEntity {
|
impl MessageEntity {
|
||||||
|
#[must_use]
|
||||||
pub const fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self {
|
pub const fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind,
|
kind,
|
||||||
|
@ -52,6 +53,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing a bold text.
|
/// Create a message entity representing a bold text.
|
||||||
|
#[must_use]
|
||||||
pub const fn bold(offset: usize, length: usize) -> Self {
|
pub const fn bold(offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Bold,
|
kind: MessageEntityKind::Bold,
|
||||||
|
@ -61,6 +63,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing an italic text.
|
/// Create a message entity representing an italic text.
|
||||||
|
#[must_use]
|
||||||
pub const fn italic(offset: usize, length: usize) -> Self {
|
pub const fn italic(offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Italic,
|
kind: MessageEntityKind::Italic,
|
||||||
|
@ -70,6 +73,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing an underline text.
|
/// Create a message entity representing an underline text.
|
||||||
|
#[must_use]
|
||||||
pub const fn underline(offset: usize, length: usize) -> Self {
|
pub const fn underline(offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Underline,
|
kind: MessageEntityKind::Underline,
|
||||||
|
@ -79,6 +83,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing a strikethrough text.
|
/// Create a message entity representing a strikethrough text.
|
||||||
|
#[must_use]
|
||||||
pub const fn strikethrough(offset: usize, length: usize) -> Self {
|
pub const fn strikethrough(offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Strikethrough,
|
kind: MessageEntityKind::Strikethrough,
|
||||||
|
@ -88,6 +93,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing a spoiler text.
|
/// Create a message entity representing a spoiler text.
|
||||||
|
#[must_use]
|
||||||
pub const fn spoiler(offset: usize, length: usize) -> Self {
|
pub const fn spoiler(offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Spoiler,
|
kind: MessageEntityKind::Spoiler,
|
||||||
|
@ -97,6 +103,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing a monowidth text.
|
/// Create a message entity representing a monowidth text.
|
||||||
|
#[must_use]
|
||||||
pub const fn code(offset: usize, length: usize) -> Self {
|
pub const fn code(offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Code,
|
kind: MessageEntityKind::Code,
|
||||||
|
@ -106,6 +113,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing a monowidth block.
|
/// Create a message entity representing a monowidth block.
|
||||||
|
#[must_use]
|
||||||
pub const fn pre(language: Option<String>, offset: usize, length: usize) -> Self {
|
pub const fn pre(language: Option<String>, offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::Pre { language },
|
kind: MessageEntityKind::Pre { language },
|
||||||
|
@ -115,6 +123,7 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a message entity representing a clickable text URL.
|
/// Create a message entity representing a clickable text URL.
|
||||||
|
#[must_use]
|
||||||
pub const fn text_link(url: reqwest::Url, offset: usize, length: usize) -> Self {
|
pub const fn text_link(url: reqwest::Url, offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::TextLink { url },
|
kind: MessageEntityKind::TextLink { url },
|
||||||
|
@ -129,6 +138,7 @@ impl MessageEntity {
|
||||||
///
|
///
|
||||||
/// If you don't have a complete [`User`] value, please use
|
/// If you don't have a complete [`User`] value, please use
|
||||||
/// [`MessageEntity::text_mention_id`] instead.
|
/// [`MessageEntity::text_mention_id`] instead.
|
||||||
|
#[must_use]
|
||||||
pub fn text_mention(user: User, offset: usize, length: usize) -> Self {
|
pub fn text_mention(user: User, offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::TextMention { user },
|
kind: MessageEntityKind::TextMention { user },
|
||||||
|
@ -139,6 +149,7 @@ impl MessageEntity {
|
||||||
|
|
||||||
/// Create a message entity representing a text link in the form of
|
/// Create a message entity representing a text link in the form of
|
||||||
/// `tg://user/?id=...` that mentions user with `user_id`.
|
/// `tg://user/?id=...` that mentions user with `user_id`.
|
||||||
|
#[must_use]
|
||||||
pub fn text_mention_id(user_id: UserId, offset: usize, length: usize) -> Self {
|
pub fn text_mention_id(user_id: UserId, offset: usize, length: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
kind: MessageEntityKind::TextLink { url: user_id.url() },
|
kind: MessageEntityKind::TextLink { url: user_id.url() },
|
||||||
|
@ -147,16 +158,19 @@ impl MessageEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn kind(mut self, val: MessageEntityKind) -> Self {
|
pub fn kind(mut self, val: MessageEntityKind) -> Self {
|
||||||
self.kind = val;
|
self.kind = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn offset(mut self, val: usize) -> Self {
|
pub const fn offset(mut self, val: usize) -> Self {
|
||||||
self.offset = val;
|
self.offset = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn length(mut self, val: usize) -> Self {
|
pub const fn length(mut self, val: usize) -> Self {
|
||||||
self.length = val;
|
self.length = val;
|
||||||
self
|
self
|
||||||
|
@ -165,11 +179,13 @@ impl MessageEntity {
|
||||||
|
|
||||||
impl<'a> MessageEntityRef<'a> {
|
impl<'a> MessageEntityRef<'a> {
|
||||||
/// Returns kind of this entity.
|
/// Returns kind of this entity.
|
||||||
|
#[must_use]
|
||||||
pub fn kind(&self) -> &'a MessageEntityKind {
|
pub fn kind(&self) -> &'a MessageEntityKind {
|
||||||
self.kind
|
self.kind
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the text that this entity is related to.
|
/// Returns the text that this entity is related to.
|
||||||
|
#[must_use]
|
||||||
pub fn text(&self) -> &'a str {
|
pub fn text(&self) -> &'a str {
|
||||||
&self.message[self.range.clone()]
|
&self.message[self.range.clone()]
|
||||||
}
|
}
|
||||||
|
@ -178,34 +194,40 @@ impl<'a> MessageEntityRef<'a> {
|
||||||
///
|
///
|
||||||
/// The range is in bytes for UTF-8 encoding i.e. you can use it with common
|
/// The range is in bytes for UTF-8 encoding i.e. you can use it with common
|
||||||
/// Rust strings.
|
/// Rust strings.
|
||||||
|
#[must_use]
|
||||||
pub fn range(&self) -> Range<usize> {
|
pub fn range(&self) -> Range<usize> {
|
||||||
self.range.clone()
|
self.range.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the offset (in bytes, for UTF-8) to the start of this entity in
|
/// Returns the offset (in bytes, for UTF-8) to the start of this entity in
|
||||||
/// the original message.
|
/// the original message.
|
||||||
|
#[must_use]
|
||||||
pub fn start(&self) -> usize {
|
pub fn start(&self) -> usize {
|
||||||
self.range.start
|
self.range.start
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the offset (in bytes, for UTF-8) to the end of this entity in
|
/// Returns the offset (in bytes, for UTF-8) to the end of this entity in
|
||||||
/// the original message.
|
/// the original message.
|
||||||
|
#[must_use]
|
||||||
pub fn end(&self) -> usize {
|
pub fn end(&self) -> usize {
|
||||||
self.range.end
|
self.range.end
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the length of this entity in bytes for UTF-8 encoding.
|
/// Returns the length of this entity in bytes for UTF-8 encoding.
|
||||||
#[allow(clippy::len_without_is_empty)]
|
#[allow(clippy::len_without_is_empty)]
|
||||||
|
#[must_use]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.range.len()
|
self.range.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the full text of the original message.
|
/// Returns the full text of the original message.
|
||||||
|
#[must_use]
|
||||||
pub fn message_text(&self) -> &'a str {
|
pub fn message_text(&self) -> &'a str {
|
||||||
self.message
|
self.message
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses telegram [`MessageEntity`]s converting offsets to UTF-8.
|
/// Parses telegram [`MessageEntity`]s converting offsets to UTF-8.
|
||||||
|
#[must_use]
|
||||||
pub fn parse(text: &'a str, entities: &'a [MessageEntity]) -> Vec<Self> {
|
pub fn parse(text: &'a str, entities: &'a [MessageEntity]) -> Vec<Self> {
|
||||||
// This creates entities with **wrong** offsets (UTF-16) that we later patch.
|
// This creates entities with **wrong** offsets (UTF-16) that we later patch.
|
||||||
let mut entities: Vec<_> = entities
|
let mut entities: Vec<_> = entities
|
||||||
|
|
|
@ -32,6 +32,7 @@ impl PassportElementError {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn kind(mut self, val: PassportElementErrorKind) -> Self {
|
pub fn kind(mut self, val: PassportElementErrorKind) -> Self {
|
||||||
self.kind = val;
|
self.kind = val;
|
||||||
self
|
self
|
||||||
|
@ -104,6 +105,7 @@ impl PassportElementErrorDataField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorDataFieldType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorDataFieldType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -153,6 +155,7 @@ impl PassportElementErrorFrontSide {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorFrontSideType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorFrontSideType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -194,6 +197,7 @@ impl PassportElementErrorReverseSide {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorReverseSideType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorReverseSideType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -233,6 +237,7 @@ impl PassportElementErrorSelfie {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorSelfieType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorSelfieType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -273,6 +278,7 @@ impl PassportElementErrorFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorFileType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorFileType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -313,6 +319,7 @@ impl PassportElementErrorFiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorFilesType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorFilesType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -354,6 +361,7 @@ impl PassportElementErrorTranslationFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorTranslationFileType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorTranslationFileType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -394,6 +402,7 @@ impl PassportElementErrorTranslationFiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorTranslationFilesType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorTranslationFilesType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
@ -434,6 +443,7 @@ impl PassportElementErrorUnspecified {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn r#type(mut self, val: PassportElementErrorUnspecifiedType) -> Self {
|
pub fn r#type(mut self, val: PassportElementErrorUnspecifiedType) -> Self {
|
||||||
self.r#type = val;
|
self.r#type = val;
|
||||||
self
|
self
|
||||||
|
|
|
@ -75,6 +75,7 @@ impl KeyboardMarkup {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn append_to_row(mut self, index: usize, button: KeyboardButton) -> Self {
|
pub fn append_to_row(mut self, index: usize, button: KeyboardButton) -> Self {
|
||||||
match self.keyboard.get_mut(index) {
|
match self.keyboard.get_mut(index) {
|
||||||
Some(buttons) => buttons.push(button),
|
Some(buttons) => buttons.push(button),
|
||||||
|
|
|
@ -38,6 +38,7 @@ pub struct KeyboardRemove {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeyboardRemove {
|
impl KeyboardRemove {
|
||||||
|
#[must_use]
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
remove_keyboard: True,
|
remove_keyboard: True,
|
||||||
|
@ -45,6 +46,7 @@ impl KeyboardRemove {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub const fn selective(mut self, val: bool) -> Self {
|
pub const fn selective(mut self, val: bool) -> Self {
|
||||||
self.selective = Some(val);
|
self.selective = Some(val);
|
||||||
self
|
self
|
||||||
|
|
|
@ -50,6 +50,7 @@ impl ReplyMarkup {
|
||||||
/// `ReplyMarkup::KeyboardRemove(ReplyKeyboardRemove::new()))`.
|
/// `ReplyMarkup::KeyboardRemove(ReplyKeyboardRemove::new()))`.
|
||||||
///
|
///
|
||||||
/// [`KeyboardRemove`]: ReplyMarkup::KeyboardRemove
|
/// [`KeyboardRemove`]: ReplyMarkup::KeyboardRemove
|
||||||
|
#[must_use]
|
||||||
pub fn kb_remove() -> Self {
|
pub fn kb_remove() -> Self {
|
||||||
Self::KeyboardRemove(KeyboardRemove::new())
|
Self::KeyboardRemove(KeyboardRemove::new())
|
||||||
}
|
}
|
||||||
|
@ -59,6 +60,7 @@ impl ReplyMarkup {
|
||||||
/// This is a shortcut to `ReplyMarkup::ForceReply(ForceReply::new())`.
|
/// This is a shortcut to `ReplyMarkup::ForceReply(ForceReply::new())`.
|
||||||
///
|
///
|
||||||
/// [`ForceReply`]: ReplyMarkup::KeyboardRemove
|
/// [`ForceReply`]: ReplyMarkup::KeyboardRemove
|
||||||
|
#[must_use]
|
||||||
pub fn force_reply() -> Self {
|
pub fn force_reply() -> Self {
|
||||||
Self::ForceReply(ForceReply::new())
|
Self::ForceReply(ForceReply::new())
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ impl Deref for Sticker {
|
||||||
|
|
||||||
impl StickerKind {
|
impl StickerKind {
|
||||||
/// Returns `true` is this is a "normal" raster sticker.
|
/// Returns `true` is this is a "normal" raster sticker.
|
||||||
|
#[must_use]
|
||||||
pub fn is_webp(&self) -> bool {
|
pub fn is_webp(&self) -> bool {
|
||||||
matches!(self, Self::Webp)
|
matches!(self, Self::Webp)
|
||||||
}
|
}
|
||||||
|
@ -91,6 +92,7 @@ impl StickerKind {
|
||||||
/// Returns `true` is this is an [animated] sticker.
|
/// Returns `true` is this is an [animated] sticker.
|
||||||
///
|
///
|
||||||
/// [animated]: https://telegram.org/blog/animated-stickers
|
/// [animated]: https://telegram.org/blog/animated-stickers
|
||||||
|
#[must_use]
|
||||||
pub fn is_animated(&self) -> bool {
|
pub fn is_animated(&self) -> bool {
|
||||||
matches!(self, Self::Animated)
|
matches!(self, Self::Animated)
|
||||||
}
|
}
|
||||||
|
@ -98,6 +100,7 @@ impl StickerKind {
|
||||||
/// Returns `true` is this is a [video] sticker.
|
/// Returns `true` is this is a [video] sticker.
|
||||||
///
|
///
|
||||||
/// [video]: https://telegram.org/blog/video-stickers-better-reactions
|
/// [video]: https://telegram.org/blog/video-stickers-better-reactions
|
||||||
|
#[must_use]
|
||||||
pub fn is_video(&self) -> bool {
|
pub fn is_video(&self) -> bool {
|
||||||
matches!(self, Self::Video)
|
matches!(self, Self::Video)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ pub struct Update {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Update {
|
impl Update {
|
||||||
|
#[must_use]
|
||||||
pub fn user(&self) -> Option<&User> {
|
pub fn user(&self) -> Option<&User> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
UpdateKind::Message(m) => m.from(),
|
UpdateKind::Message(m) => m.from(),
|
||||||
|
@ -43,6 +44,7 @@ impl Update {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn chat(&self) -> Option<&Chat> {
|
pub fn chat(&self) -> Option<&Chat> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
UpdateKind::Message(m) => Some(&m.chat),
|
UpdateKind::Message(m) => Some(&m.chat),
|
||||||
|
|
|
@ -40,27 +40,31 @@ pub struct User {
|
||||||
impl User {
|
impl User {
|
||||||
/// Returns full name of this user, ie first and last names joined with a
|
/// Returns full name of this user, ie first and last names joined with a
|
||||||
/// space.
|
/// space.
|
||||||
|
#[must_use]
|
||||||
pub fn full_name(&self) -> String {
|
pub fn full_name(&self) -> String {
|
||||||
match &self.last_name {
|
match &self.last_name {
|
||||||
Some(last_name) => (format!("{0} {1}", self.first_name, last_name)),
|
Some(last_name) => format!("{0} {1}", self.first_name, last_name),
|
||||||
None => self.first_name.clone(),
|
None => self.first_name.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a username mention of this user. Returns `None` if
|
/// Returns a username mention of this user. Returns `None` if
|
||||||
/// `self.username.is_none()`.
|
/// `self.username.is_none()`.
|
||||||
|
#[must_use]
|
||||||
pub fn mention(&self) -> Option<String> {
|
pub fn mention(&self) -> Option<String> {
|
||||||
Some(format!("@{}", self.username.as_ref()?))
|
Some(format!("@{}", self.username.as_ref()?))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an URL that links to this user in the form of
|
/// Returns an URL that links to this user in the form of
|
||||||
/// `tg://user/?id=<...>`.
|
/// `tg://user/?id=<...>`.
|
||||||
|
#[must_use]
|
||||||
pub fn url(&self) -> reqwest::Url {
|
pub fn url(&self) -> reqwest::Url {
|
||||||
self.id.url()
|
self.id.url()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an URL that links to this user in the form of `t.me/<...>`.
|
/// Returns an URL that links to this user in the form of `t.me/<...>`.
|
||||||
/// Returns `None` if `self.username.is_none()`.
|
/// Returns `None` if `self.username.is_none()`.
|
||||||
|
#[must_use]
|
||||||
pub fn tme_url(&self) -> Option<reqwest::Url> {
|
pub fn tme_url(&self) -> Option<reqwest::Url> {
|
||||||
Some(
|
Some(
|
||||||
format!("https://t.me/{}", self.username.as_ref()?)
|
format!("https://t.me/{}", self.username.as_ref()?)
|
||||||
|
@ -71,12 +75,14 @@ impl User {
|
||||||
|
|
||||||
/// Returns an URL that links to this user in the form of `t.me/<...>` or
|
/// Returns an URL that links to this user in the form of `t.me/<...>` or
|
||||||
/// `tg://user/?id=<...>`, preferring `t.me` one when possible.
|
/// `tg://user/?id=<...>`, preferring `t.me` one when possible.
|
||||||
|
#[must_use]
|
||||||
pub fn preferably_tme_url(&self) -> reqwest::Url {
|
pub fn preferably_tme_url(&self) -> reqwest::Url {
|
||||||
self.tme_url().unwrap_or_else(|| self.url())
|
self.tme_url().unwrap_or_else(|| self.url())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this is the special user used by telegram bot API to
|
/// Returns `true` if this is the special user used by telegram bot API to
|
||||||
/// denote an anonymous user that sends messages on behalf of a group.
|
/// denote an anonymous user that sends messages on behalf of a group.
|
||||||
|
#[must_use]
|
||||||
pub fn is_anonymous(&self) -> bool {
|
pub fn is_anonymous(&self) -> bool {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
|
@ -92,6 +98,7 @@ impl User {
|
||||||
|
|
||||||
/// Returns `true` if this is the special user used by telegram bot API to
|
/// Returns `true` if this is the special user used by telegram bot API to
|
||||||
/// denote an anonymous user that sends messages on behalf of a channel.
|
/// denote an anonymous user that sends messages on behalf of a channel.
|
||||||
|
#[must_use]
|
||||||
pub fn is_channel(&self) -> bool {
|
pub fn is_channel(&self) -> bool {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
|
@ -110,6 +117,7 @@ impl User {
|
||||||
/// It is sometimes also used as a fallback, for example when a channel post
|
/// It is sometimes also used as a fallback, for example when a channel post
|
||||||
/// is automatically forwarded to a group, bots in a group will get a
|
/// is automatically forwarded to a group, bots in a group will get a
|
||||||
/// message where `from` is the Telegram user.
|
/// message where `from` is the Telegram user.
|
||||||
|
#[must_use]
|
||||||
pub fn is_telegram(&self) -> bool {
|
pub fn is_telegram(&self) -> bool {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub struct UserId(pub u64);
|
||||||
impl UserId {
|
impl UserId {
|
||||||
/// Returns an URL that links to the user with this id in the form of
|
/// Returns an URL that links to the user with this id in the form of
|
||||||
/// `tg://user/?id=<...>`.
|
/// `tg://user/?id=<...>`.
|
||||||
|
#[must_use]
|
||||||
pub fn url(self) -> reqwest::Url {
|
pub fn url(self) -> reqwest::Url {
|
||||||
reqwest::Url::parse(&format!("tg://user/?id={}", self)).unwrap()
|
reqwest::Url::parse(&format!("tg://user/?id={}", self)).unwrap()
|
||||||
}
|
}
|
||||||
|
@ -18,6 +19,7 @@ impl UserId {
|
||||||
/// Returns `true` if this is the id of the special user used by telegram
|
/// Returns `true` if this is the id of the special user used by telegram
|
||||||
/// bot API to denote an anonymous user that sends messages on behalf of
|
/// bot API to denote an anonymous user that sends messages on behalf of
|
||||||
/// a group.
|
/// a group.
|
||||||
|
#[must_use]
|
||||||
pub fn is_anonymous(self) -> bool {
|
pub fn is_anonymous(self) -> bool {
|
||||||
// https://github.com/tdlib/td/blob/4791fb6a2af0257f6cad8396e10424a79ee5f768/td/telegram/ContactsManager.cpp#L4941-L4943
|
// https://github.com/tdlib/td/blob/4791fb6a2af0257f6cad8396e10424a79ee5f768/td/telegram/ContactsManager.cpp#L4941-L4943
|
||||||
const ANON_ID: UserId = UserId(1087968824);
|
const ANON_ID: UserId = UserId(1087968824);
|
||||||
|
@ -28,6 +30,7 @@ impl UserId {
|
||||||
/// Returns `true` if this is the id of the special user used by telegram
|
/// Returns `true` if this is the id of the special user used by telegram
|
||||||
/// bot API to denote an anonymous user that sends messages on behalf of
|
/// bot API to denote an anonymous user that sends messages on behalf of
|
||||||
/// a channel.
|
/// a channel.
|
||||||
|
#[must_use]
|
||||||
pub fn is_channel(self) -> bool {
|
pub fn is_channel(self) -> bool {
|
||||||
// https://github.com/tdlib/td/blob/4791fb6a2af0257f6cad8396e10424a79ee5f768/td/telegram/ContactsManager.cpp#L4945-L4947
|
// https://github.com/tdlib/td/blob/4791fb6a2af0257f6cad8396e10424a79ee5f768/td/telegram/ContactsManager.cpp#L4945-L4947
|
||||||
const ANON_CHANNEL_ID: UserId = UserId(136817688);
|
const ANON_CHANNEL_ID: UserId = UserId(136817688);
|
||||||
|
@ -41,6 +44,7 @@ impl UserId {
|
||||||
/// It is sometimes also used as a fallback, for example when a channel post
|
/// It is sometimes also used as a fallback, for example when a channel post
|
||||||
/// is automatically forwarded to a group, bots in a group will get a
|
/// is automatically forwarded to a group, bots in a group will get a
|
||||||
/// message where `from` is the Telegram user.
|
/// message where `from` is the Telegram user.
|
||||||
|
#[must_use]
|
||||||
pub fn is_telegram(self) -> bool {
|
pub fn is_telegram(self) -> bool {
|
||||||
const TELEGRAM_USER_ID: UserId = UserId(777000);
|
const TELEGRAM_USER_ID: UserId = UserId(777000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue