diff --git a/blastmud_game/src/message_handler/user_commands.rs b/blastmud_game/src/message_handler/user_commands.rs index c3702a4d..f175465f 100644 --- a/blastmud_game/src/message_handler/user_commands.rs +++ b/blastmud_game/src/message_handler/user_commands.rs @@ -62,7 +62,7 @@ pub async fn handle(session: &ListenerSession, msg: &str, pool: &DBPool) -> DRes match handler.handle(&VerbContext { session, pool }, cmd, params).await { Ok(()) => {} Err(UserError(err_msg)) => { - pool.queue_for_session(session, &err_msg).await?; + pool.queue_for_session(session, &(err_msg + "\r\n")).await?; } Err(SystemError(e)) => Err(e)? } diff --git a/blastmud_game/src/message_handler/user_commands/help.rs b/blastmud_game/src/message_handler/user_commands/help.rs index b182cc54..eae2485e 100644 --- a/blastmud_game/src/message_handler/user_commands/help.rs +++ b/blastmud_game/src/message_handler/user_commands/help.rs @@ -1,11 +1,31 @@ -use super::{VerbContext, UserVerb, UserVerbRef, UResult, user_error}; +use super::{ + VerbContext, UserVerb, UserVerbRef, UResult, + CommandHandlingError::UserError +}; use async_trait::async_trait; +use ansi_macro::ansi; +use phf::phf_map; + +static HELP_PAGES: phf::Map<&'static str, &'static str> = phf_map! { + "" => + ansi!("Type help topicname> to learn about a topic. Most \ + commands can be used as a topicname.\r\n\ + Topics of interest to new users:\r\n\ + \tregister\tLearn about the register command.\r\n\ + \tnewbie\tLearn how to survive as a newb."), + "" => + ansi!("You are supposed to replace topicname> with the topic you want \ + to learn about. Example:\r\n\ + \thelp register will tell you about the register command.") +}; pub struct Verb; #[async_trait] impl UserVerb for Verb { async fn handle(self: &Self, ctx: &VerbContext, _verb: &str, remaining: &str) -> UResult<()> { - user_error("Not implemented yet\r\n".to_string())?; + let help = HELP_PAGES.get(remaining).ok_or( + UserError("No help available on that".to_string()))?; + ctx.pool.queue_for_session(ctx.session, &(help.to_string() + "\r\n")).await?; Ok(()) } }