create /editbutton cmd for admin
This commit is contained in:
parent
c6468269e7
commit
fed5d8f5b7
11
src/admin.rs
11
src/admin.rs
@ -3,11 +3,11 @@ use teloxide::{
|
||||
utils::{command::BotCommands, render::RenderMessageTextHelper},
|
||||
};
|
||||
|
||||
use crate::LogMsg;
|
||||
use crate::{
|
||||
db::{CallDB, DB},
|
||||
BotResult,
|
||||
};
|
||||
use crate::{BotDialogue, LogMsg, State};
|
||||
use log::info;
|
||||
|
||||
// These are should not appear in /help
|
||||
@ -27,6 +27,8 @@ pub enum AdminCommands {
|
||||
Pin,
|
||||
/// Removes your admin privileges
|
||||
Deop,
|
||||
/// Send command and then click button to edits text in it
|
||||
EditButton,
|
||||
}
|
||||
|
||||
pub async fn admin_command_handler(
|
||||
@ -34,6 +36,7 @@ pub async fn admin_command_handler(
|
||||
bot: Bot,
|
||||
msg: Message,
|
||||
cmd: AdminCommands,
|
||||
dialogue: BotDialogue,
|
||||
) -> BotResult<()> {
|
||||
let tguser = match msg.from.clone() {
|
||||
Some(user) => user,
|
||||
@ -69,6 +72,12 @@ pub async fn admin_command_handler(
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
AdminCommands::EditButton => {
|
||||
dialogue.update(State::EditButton).await?;
|
||||
bot.send_message(msg.chat.id, "Click button which text should be edited")
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ pub enum State {
|
||||
lang: String,
|
||||
is_caption_set: bool,
|
||||
},
|
||||
EditButton,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@ -432,6 +433,7 @@ fn command_handler(
|
||||
user.map(|u| u.is_admin).unwrap_or(false)
|
||||
})
|
||||
.filter_command::<AdminCommands>()
|
||||
.enter_dialogue::<Message, MongodbStorage<Json>, State>()
|
||||
.endpoint(admin_command_handler),
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user