Compare commits

...

2 Commits

Author SHA1 Message Date
Akulij
e74f875e3b create /commit command to get commit hash from which this bot was built
All checks were successful
Build && Deploy / cargo build (push) Successful in 1m7s
2025-06-01 17:37:58 +05:00
Akulij
1669327df2 cargo add git-const 2025-06-01 17:37:49 +05:00
3 changed files with 17 additions and 0 deletions

7
Cargo.lock generated
View File

@ -897,6 +897,12 @@ version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "git-const"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4f63cc0cd93d91bcc11b46f61db771bc36c405d96043506ae40facd87b31f7"
[[package]] [[package]]
name = "glob" name = "glob"
version = "0.3.2" version = "0.3.2"
@ -915,6 +921,7 @@ dependencies = [
"enum_stringify", "enum_stringify",
"envconfig", "envconfig",
"futures", "futures",
"git-const",
"itertools 0.14.0", "itertools 0.14.0",
"lazy_static", "lazy_static",
"log", "log",

View File

@ -14,6 +14,7 @@ dotenvy = "0.15.7"
enum_stringify = "0.6.3" enum_stringify = "0.6.3"
envconfig = "0.11.0" envconfig = "0.11.0"
futures = "0.3.31" futures = "0.3.31"
git-const = "1.1.0"
itertools = "0.14.0" itertools = "0.14.0"
lazy_static = "1.5.0" lazy_static = "1.5.0"
log = "0.4.27" log = "0.4.27"

View File

@ -1,3 +1,4 @@
use git_const::git_hash;
use itertools::Itertools; use itertools::Itertools;
use teloxide::{ use teloxide::{
prelude::*, prelude::*,
@ -44,6 +45,8 @@ pub enum AdminCommands {
Cancel, Cancel,
/// Create new instance of telegram bot /// Create new instance of telegram bot
Deploy { token: String }, Deploy { token: String },
/// Get commit hash of this bot
Commit,
} }
pub async fn admin_command_handler( pub async fn admin_command_handler(
@ -189,6 +192,12 @@ pub async fn admin_command_handler(
.await?; .await?;
Ok(()) Ok(())
} }
AdminCommands::Commit => {
let hash = git_hash!();
bot.send_message(msg.chat.id, format!("Commit: {hash}"))
.await?;
Ok(())
}
} }
} }