mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
TBA 5.3: Add BotCommandScope
This commit is contained in:
parent
ef84162314
commit
27f5875b42
2 changed files with 57 additions and 0 deletions
|
@ -4,6 +4,7 @@ pub use allowed_update::*;
|
|||
pub use animation::*;
|
||||
pub use audio::*;
|
||||
pub use bot_command::*;
|
||||
pub use bot_command_scope::*;
|
||||
pub use callback_game::*;
|
||||
pub use callback_query::*;
|
||||
pub use chat::*;
|
||||
|
@ -108,6 +109,7 @@ mod allowed_update;
|
|||
mod animation;
|
||||
mod audio;
|
||||
mod bot_command;
|
||||
mod bot_command_scope;
|
||||
mod callback_game;
|
||||
mod callback_query;
|
||||
mod chat;
|
||||
|
|
55
src/types/bot_command_scope.rs
Normal file
55
src/types/bot_command_scope.rs
Normal file
|
@ -0,0 +1,55 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::ChatId;
|
||||
|
||||
/// This object represents the scope to which bot commands are applied.
|
||||
///
|
||||
/// ## Determining list of commands
|
||||
///
|
||||
/// The following algorithm is used to determine the list of commands for a
|
||||
/// particular user viewing the bot menu. The first list of commands which is
|
||||
/// set is returned:
|
||||
///
|
||||
/// ### Commands in the chat with the bot
|
||||
///
|
||||
/// - [`Chat`] + `language_code`
|
||||
/// - [`Chat`]
|
||||
/// - [`AllPrivateChats`] + `language_code`
|
||||
/// - [`AllPrivateChats`]
|
||||
/// - [`Default`] + `language_code`
|
||||
/// - [`Default`]
|
||||
///
|
||||
/// ### Commands in group and supergroup chats
|
||||
///
|
||||
/// - [`ChatMember`] + `language_code`
|
||||
/// - [`ChatMember`]
|
||||
/// - [`ChatAdministrators`] + `language_code` (admins only)
|
||||
/// - [`ChatAdministrators`] (admins only)
|
||||
/// - [`Chat`] + `language_code`
|
||||
/// - [`Chat`]
|
||||
/// - [`AllChatAdministrators`] + `language_code` (admins only)
|
||||
/// - [`AllChatAdministrators`] (admins only)
|
||||
/// - [`AllGroupChats`] + `language_code`
|
||||
/// - [`AllGroupChats`]
|
||||
/// - [`Default`] + `language_code`
|
||||
/// - [`Default`]
|
||||
///
|
||||
/// [`Default`]: BotCommandScope::Default
|
||||
/// [`AllPrivateChats`]: BotCommandScope::AllPrivateChats
|
||||
/// [`AllGroupChats`]: BotCommandScope::AllGroupChats
|
||||
/// [`AllChatAdministrators`]: BotCommandScope::AllChatAdministrators
|
||||
/// [`Chat`]: BotCommandScope::Chat
|
||||
/// [`ChatAdministrators`]: BotCommandScope::ChatAdministrators
|
||||
/// [`ChatMember`]: BotCommandScope::ChatMember
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum BotCommandScope {
|
||||
Default,
|
||||
AllPrivateChats,
|
||||
AllGroupChats,
|
||||
AllChatAdministrators,
|
||||
Chat(#[serde(rename = "chat_id")] ChatId),
|
||||
ChatAdministrators(#[serde(rename = "chat_id")] ChatId),
|
||||
ChatMember { chat_id: ChatId, user_id: i64 },
|
||||
}
|
Loading…
Add table
Reference in a new issue