telers/types/
bot_command_scope.rs1use super::{
2 BotCommandScopeAllChatAdministrators, BotCommandScopeAllGroupChats,
3 BotCommandScopeAllPrivateChats, BotCommandScopeChat, BotCommandScopeChatAdministrators,
4 BotCommandScopeChatMember, BotCommandScopeDefault, ChatIdKind,
5};
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Hash, PartialEq, Eq, Deserialize, Serialize)]
20#[serde(tag = "type", rename_all = "snake_case")]
21pub enum BotCommandScope {
22 Default(BotCommandScopeDefault),
23 AllPrivateChats(BotCommandScopeAllPrivateChats),
24 AllGroupChats(BotCommandScopeAllGroupChats),
25 AllChatAdministrators(BotCommandScopeAllChatAdministrators),
26 Chat(BotCommandScopeChat),
27 ChatAdministrators(BotCommandScopeChatAdministrators),
28 ChatMember(BotCommandScopeChatMember),
29}
30
31impl BotCommandScope {
32 #[must_use]
33 pub const fn default() -> Self {
34 Self::Default(BotCommandScopeDefault::new())
35 }
36
37 #[must_use]
38 pub const fn all_private_chats() -> Self {
39 Self::AllPrivateChats(BotCommandScopeAllPrivateChats::new())
40 }
41
42 #[must_use]
43 pub const fn all_group_chats() -> Self {
44 Self::AllGroupChats(BotCommandScopeAllGroupChats::new())
45 }
46
47 #[must_use]
48 pub const fn all_chat_administrators() -> Self {
49 Self::AllChatAdministrators(BotCommandScopeAllChatAdministrators::new())
50 }
51
52 #[must_use]
53 pub fn chat(chat_id: impl Into<ChatIdKind>) -> Self {
54 Self::Chat(BotCommandScopeChat::new(chat_id))
55 }
56
57 #[must_use]
58 pub fn chat_administrators(chat_id: impl Into<ChatIdKind>) -> Self {
59 Self::ChatAdministrators(BotCommandScopeChatAdministrators::new(chat_id))
60 }
61
62 #[must_use]
63 pub fn chat_member(chat_id: impl Into<ChatIdKind>, user_id: i64) -> Self {
64 Self::ChatMember(BotCommandScopeChatMember::new(chat_id, user_id))
65 }
66}
67
68impl Default for BotCommandScope {
69 fn default() -> Self {
70 Self::default()
71 }
72}
73
74impl From<BotCommandScopeDefault> for BotCommandScope {
75 fn from(scope: BotCommandScopeDefault) -> Self {
76 BotCommandScope::Default(scope)
77 }
78}
79
80impl From<BotCommandScopeAllPrivateChats> for BotCommandScope {
81 fn from(scope: BotCommandScopeAllPrivateChats) -> Self {
82 BotCommandScope::AllPrivateChats(scope)
83 }
84}
85
86impl From<BotCommandScopeAllGroupChats> for BotCommandScope {
87 fn from(scope: BotCommandScopeAllGroupChats) -> Self {
88 BotCommandScope::AllGroupChats(scope)
89 }
90}
91
92impl From<BotCommandScopeAllChatAdministrators> for BotCommandScope {
93 fn from(scope: BotCommandScopeAllChatAdministrators) -> Self {
94 BotCommandScope::AllChatAdministrators(scope)
95 }
96}
97
98impl From<BotCommandScopeChat> for BotCommandScope {
99 fn from(scope: BotCommandScopeChat) -> Self {
100 BotCommandScope::Chat(scope)
101 }
102}
103
104impl From<BotCommandScopeChatAdministrators> for BotCommandScope {
105 fn from(scope: BotCommandScopeChatAdministrators) -> Self {
106 BotCommandScope::ChatAdministrators(scope)
107 }
108}
109
110impl From<BotCommandScopeChatMember> for BotCommandScope {
111 fn from(scope: BotCommandScopeChatMember) -> Self {
112 BotCommandScope::ChatMember(scope)
113 }
114}