feat(new command): add privacy command

This commit is contained in:
doryan 2024-07-08 09:51:04 +04:00
parent b621a3af66
commit d9d65e8d58
6 changed files with 33 additions and 11 deletions

View File

@ -3,7 +3,11 @@
<code>/mute {ID | REPLY} &lt;DURATION&gt; [TIME METRIC]</code> - выдаёт мут на заданное время;
<code>/unmute {ID | REPLY}</code> - снимает мут;
Для более подробного описания, введите команды без аргументов.
Для более подробного описания, введите команды без аргументов.
<b>Команды (для всех)</b>
<code>/privacy</code> - политика конфиденциальности.
<b>Эмодзи (для админов)</b>

View File

@ -4,6 +4,7 @@ pub mod files {
use super::*;
pub const HELP_COMMAND_TEXT: &str = include_str!("help_command.html");
pub const PRIVACY_COMMAND_TEXT: &str = include_str!("privacy_command.html");
pub const MUTE_COMMAND_HELP: &str = include_str!("mute_command_help.html");
pub const UNMUTE_COMMAND_HELP: &str = include_str!("unmute_command_help.html");
}

View File

@ -0,0 +1 @@
В боте <strong>Gluon v.0.1</strong> ни где не предусмотрено хранение данных о пользователе.

View File

@ -5,11 +5,11 @@ use telers::{
Bot,
};
use crate::{assets::files::HELP_COMMAND_TEXT, types::structs::message_sender::MessageSender};
use crate::types::structs::message_sender::MessageSender;
pub async fn help(bot: Bot, message: Message) -> HandlerResult {
pub async fn send_info(bot: Bot, message: Message, info_text: &'static str) -> HandlerResult {
MessageSender::builder(message.chat().id())
.text(HELP_COMMAND_TEXT)
.text(info_text)
.parse_mode(ParseMode::HTML)
.build()
.send(&bot)

View File

@ -1,3 +1,3 @@
pub mod help_command;
pub mod info_commands_template;
pub mod mute_command;
pub mod unmute_command;

View File

@ -4,6 +4,7 @@ use telers::{
enums::ContentType,
event::ToServiceProvider,
filters::{content_type::ContentType as CT, Command},
types::Message,
Bot, Dispatcher, Router,
};
@ -14,9 +15,13 @@ mod utils;
use middlewares::admin_check_middleware::AdminCheck;
use assets::files::{HELP_COMMAND_TEXT, PRIVACY_COMMAND_TEXT};
mod handlers;
use handlers::{
command_handlers::{help_command::help, mute_command::mute, unmute_command::unmute},
command_handlers::{
info_commands_template::send_info, mute_command::mute, unmute_command::unmute,
},
dice_handler::dice::dice_handler,
};
@ -64,6 +69,22 @@ async fn main() {
let mut admin_commands = Router::new("admin_commands");
let mut default_commands = Router::new("default_commands");
let help =
|bot: Bot, msg: Message| async { send_info(bot, msg, HELP_COMMAND_TEXT).await };
let privacy =
|bot: Bot, msg: Message| async { send_info(bot, msg, PRIVACY_COMMAND_TEXT).await };
default_commands
.message
.register(help)
.filter(Command::one("help"));
default_commands
.message
.register(privacy)
.filter(Command::one("privacy"));
admin_commands
.message
.register(unmute)
@ -79,11 +100,6 @@ async fn main() {
.inner_middlewares
.register(AdminCheck {});
default_commands
.message
.register(help)
.filter(Command::one("help"));
command.include(admin_commands).include(default_commands);
route.include(command);