From f5c504389675b02bd6ec028a2fc2f8b7925e516d Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 26 Feb 2023 19:52:28 +0100 Subject: [PATCH] Implement Command for ShortHelp --- CHANGELOG.md | 1 + src/bot/botrulez/short_help.rs | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b3841..cb91675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Procedure when bumping the version number: ### Added - `bot::botrulez::Ping` now implements `bot::command::Command` +- `bot::botrulez::ShortHelp` now implements `bot::command::Command` ### Changed - Instances log to target `euphoxide::live::` diff --git a/src/bot/botrulez/short_help.rs b/src/bot/botrulez/short_help.rs index d8d1d73..028c1d1 100644 --- a/src/bot/botrulez/short_help.rs +++ b/src/bot/botrulez/short_help.rs @@ -2,13 +2,9 @@ use async_trait::async_trait; use clap::Parser; use crate::api::Message; -use crate::bot::command::{ClapCommand, Context}; +use crate::bot::command::{ClapCommand, Command, Context}; use crate::conn; -/// Show short bot help. -#[derive(Parser)] -pub struct Args {} - pub struct ShortHelp(pub String); impl ShortHelp { @@ -17,6 +13,29 @@ impl ShortHelp { } } +#[async_trait] +impl Command for ShortHelp +where + E: From, +{ + async fn execute( + &self, + arg: &str, + msg: &Message, + ctx: &Context, + _bot: &mut B, + ) -> Result<(), E> { + if arg.trim().is_empty() { + ctx.reply(msg.id, &self.0).await?; + } + Ok(()) + } +} + +/// Show short bot help. +#[derive(Parser)] +pub struct Args {} + #[async_trait] impl ClapCommand for ShortHelp where