Implement Command for Ping
This commit is contained in:
parent
5b4bf87506
commit
8b8d281f8a
2 changed files with 27 additions and 5 deletions
|
|
@ -13,6 +13,9 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `bot::botrulez::Ping` now implements `bot::command::Command`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Instances log to target `euphoxide::live::<name>`
|
- Instances log to target `euphoxide::live::<name>`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,9 @@ use async_trait::async_trait;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use crate::api::Message;
|
use crate::api::Message;
|
||||||
use crate::bot::command::{ClapCommand, Context};
|
use crate::bot::command::{ClapCommand, Command, Context};
|
||||||
use crate::conn;
|
use crate::conn;
|
||||||
|
|
||||||
/// Trigger a short reply.
|
|
||||||
#[derive(Parser)]
|
|
||||||
pub struct Args {}
|
|
||||||
|
|
||||||
pub struct Ping(pub String);
|
pub struct Ping(pub String);
|
||||||
|
|
||||||
impl Ping {
|
impl Ping {
|
||||||
|
|
@ -23,6 +19,29 @@ impl Default for Ping {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<B, E> Command<B, E> for Ping
|
||||||
|
where
|
||||||
|
E: From<conn::Error>,
|
||||||
|
{
|
||||||
|
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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Trigger a short reply.
|
||||||
|
#[derive(Parser)]
|
||||||
|
pub struct Args {}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<B, E> ClapCommand<B, E> for Ping
|
impl<B, E> ClapCommand<B, E> for Ping
|
||||||
where
|
where
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue