implement versioning

This commit is contained in:
mykola2312 2024-03-15 20:18:00 +02:00
parent d45ae2b6bd
commit 27228df2d5
3 changed files with 19 additions and 4 deletions

View file

@ -7,6 +7,7 @@ pub mod request_chat;
pub mod sanitize;
pub mod start;
pub mod types;
pub mod version;
#[macro_export]
macro_rules! reply_i18n_and_return {

View file

@ -8,6 +8,7 @@ use teloxide::{prelude::*, update_listeners::Polling, utils::command::BotCommand
use tracing::{event, Level};
use super::start::handle_new_chat_member;
use super::version::cmd_version;
use super::types::*;
use crate::db::DbPool;
use crate::util::{parse_env, unwrap_env};
@ -48,6 +49,7 @@ fn schema() -> UpdateHandler<HandlerErr> {
let command_handler = teloxide::filter_command::<Command, _>()
.branch(case![Command::Test].endpoint(cmd_test))
.branch(case![Command::Version].endpoint(cmd_version))
.branch(case![Command::Start].endpoint(cmd_start))
.branch(case![Command::Download(url)].endpoint(cmd_download))
.branch(case![Command::OP].endpoint(cmd_op))
@ -102,20 +104,21 @@ async fn handle_message(
#[command(rename_rule = "lowercase")]
enum Command {
Test,
#[command(alias = "start")]
Start,
Version,
#[command(alias = "dl")]
Download(String),
#[command(alias = "op")]
OP,
#[command(alias = "request")]
Request(String),
#[command(alias = "listrequests")]
ListRequests,
#[command(alias = "approve")]
Approve(String),
#[command(alias = "decline")]
Decline(String),
#[command(alias = "request_chat")]

11
src/bot/version.rs Normal file
View file

@ -0,0 +1,11 @@
use teloxide::prelude::*;
use super::types::HandlerResult;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub async fn cmd_version(bot: Bot, msg: Message) -> HandlerResult {
bot.send_message(msg.chat.id, VERSION).await?;
Ok(())
}