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