From 87601f172a968e29ebf90807c9037a12510cfaed Mon Sep 17 00:00:00 2001 From: Akulij Date: Thu, 3 Apr 2025 04:47:43 +0900 Subject: [PATCH] create deop command --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4a696a4..aeb5877 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,8 @@ enum AdminCommands { MyId, /// Pin replied message Pin, + /// Removes your admin privileges + Deop, } trait LogMsg { @@ -152,7 +154,6 @@ async fn admin_command_handler( cmd: AdminCommands, ) -> Result<(), teloxide::RequestError> { let tguser = msg.from.clone().unwrap(); - let user = db.get_or_init_user(tguser.id.0 as i64); println!("MSG: {}", msg.html_text().unwrap()); match cmd { AdminCommands::MyId => { @@ -167,8 +168,9 @@ async fn admin_command_handler( } Ok(()) }, - _ => { - bot.send_message(msg.chat.id, "Not yet implemented").await?; + AdminCommands::Deop => { + db.set_admin(tguser.id.0 as i64, false).await; + bot.send_message(msg.chat.id, "You are not an admin anymore").await?; Ok(()) } }