Add botrulez
This commit is contained in:
parent
5655fa7c4a
commit
a0d55482cc
7 changed files with 266 additions and 1 deletions
43
src/bot/botrulez/ping.rs
Normal file
43
src/bot/botrulez/ping.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use async_trait::async_trait;
|
||||
use clap::Parser;
|
||||
|
||||
use crate::api::Message;
|
||||
use crate::bot::command::{ClapCommand, Context};
|
||||
use crate::conn;
|
||||
|
||||
/// Trigger a short reply.
|
||||
#[derive(Parser)]
|
||||
pub struct Args {}
|
||||
|
||||
pub struct Ping(pub String);
|
||||
|
||||
impl Ping {
|
||||
pub fn new<S: ToString>(reply: S) -> Self {
|
||||
Self(reply.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Ping {
|
||||
fn default() -> Self {
|
||||
Self::new("Pong!")
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<B, E> ClapCommand<B, E> for Ping
|
||||
where
|
||||
E: From<conn::Error>,
|
||||
{
|
||||
type Args = Args;
|
||||
|
||||
async fn execute(
|
||||
&self,
|
||||
_args: Self::Args,
|
||||
msg: &Message,
|
||||
ctx: &Context,
|
||||
_bot: &mut B,
|
||||
) -> Result<(), E> {
|
||||
ctx.reply(msg.id, &self.0).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue