diff options
Diffstat (limited to 'src/plugins/help.rs')
| -rw-r--r-- | src/plugins/help.rs | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/plugins/help.rs b/src/plugins/help.rs index 7e3658d..d54008a 100644 --- a/src/plugins/help.rs +++ b/src/plugins/help.rs @@ -1,36 +1,51 @@ +use std::marker::PhantomData; + use irc::client::prelude::*; use plugin::*; +use FrippyClient; -use error::FrippyError; use error::ErrorKind as FrippyErrorKind; +use error::FrippyError; use failure::ResultExt; #[derive(PluginName, Default, Debug)] -pub struct Help; +pub struct Help<C> { + phantom: PhantomData<C>, +} -impl Help { - pub fn new() -> Help { - Help {} +impl<C: FrippyClient> Help<C> { + pub fn new() -> Self { + Help { + phantom: PhantomData, + } } } -impl Plugin for Help { - fn execute(&self, _: &IrcClient, _: &Message) -> ExecutionStatus { +impl<C: FrippyClient> Plugin for Help<C> { + type Client = C; + fn execute(&self, _: &Self::Client, _: &Message) -> ExecutionStatus { ExecutionStatus::Done } - fn execute_threaded(&self, _: &IrcClient, _: &Message) -> Result<(), FrippyError> { + fn execute_threaded(&self, _: &Self::Client, _: &Message) -> Result<(), FrippyError> { panic!("Help should not use threading") } - fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError> { - Ok(client - .send_notice(&command.source, "Help has not been added yet.") - .context(FrippyErrorKind::Connection)?) + fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { + client + .send_notice( + &command.source, + "Available commands: help, tell, factoids, remind, quote, unicode\r\n\ + For more detailed help call help on the specific command.\r\n\ + Example: 'remind help'", + ) + .context(FrippyErrorKind::Connection)?; + + Ok(()) } - fn evaluate(&self, _: &IrcClient, _: PluginCommand) -> Result<String, String> { + fn evaluate(&self, _: &Self::Client, _: PluginCommand) -> Result<String, String> { Err(String::from("Help has not been added yet.")) } } |
