-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dec6b6
commit 6cdd411
Showing
6 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use super::*; | ||
|
||
use std::collections::HashMap; | ||
|
||
use itertools::Itertools; | ||
|
||
#[command_handler("HELP")] | ||
/// Syntax: HELP [<subject>] | ||
fn help_handler( | ||
response: &dyn CommandResponse, | ||
server: &ClientServer, | ||
subject: Option<&str>, | ||
) -> CommandResult { | ||
// TODO: oper help? (and if oper help is on the same command, UHELP like solanum?) | ||
// TODO: get this from doc comments | ||
// TODO: how to add non-command topics? | ||
// TODO: or btreemap (presorted)? | ||
//let mut help_topics = HashMap::from([ | ||
// ("HELP".to_string(), "HELP [<subject>]\n\nGet information about subject.\nIf subject is not given, list available topics."), | ||
// ("INFO".to_string(), "INFO\n\nShow information about this server."), | ||
// ("asdfadsf".to_string(), "INFO\n\nShow information about this server."), | ||
// ("asdf".to_string(), "INFO\n\nShow information about this server."), | ||
// ("hfasdfxdv".to_string(), "INFO\n\nShow information about this server."), | ||
// ("dfadfNFO".to_string(), "INFO\n\nShow information about this server."), | ||
// ("dfdfdf".to_string(), "INFO\n\nShow information about this server."), | ||
// ("nxcnjvxc".to_string(), "INFO\n\nShow information about this server."), | ||
//]); | ||
|
||
match subject { | ||
Some(s) => { | ||
let subject = s.to_ascii_uppercase(); | ||
let subject = match subject.split_once(' ') { | ||
Some((subj, _)) => subj.to_string(), | ||
None => subject, | ||
}; | ||
|
||
for reg in inventory::iter::<CommandRegistration> { | ||
if reg.command == subject { | ||
let mut lines = reg.help.iter(); | ||
response.numeric(make_numeric!(HelpStart, &subject, lines.next().unwrap_or(&subject.as_str()))); | ||
for line in lines { | ||
response.numeric(make_numeric!(HelpText, &subject, line)); | ||
} | ||
response.numeric(make_numeric!(EndOfHelp, &subject)); | ||
} else { | ||
response.numeric(make_numeric!(HelpNotFound, &subject)) | ||
} | ||
} | ||
}, | ||
None => { | ||
let subject = "*"; | ||
response.numeric(make_numeric!(HelpStart, subject, "Available help topics:")); | ||
response.numeric(make_numeric!(HelpText, subject, "")); | ||
for chunk in &inventory::iter::<CommandRegistration>.into_iter().map(|v| v.command.to_ascii_uppercase()).chunks(4) { | ||
let line = format!("{:16}", chunk.format(" ")); | ||
response.numeric(make_numeric!(HelpText, subject, &line)); | ||
} | ||
response.numeric(make_numeric!(EndOfHelp, subject)); | ||
}, | ||
}; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ mod handlers { | |
mod ban; | ||
mod cap; | ||
mod chathistory; | ||
mod help; | ||
mod invite; | ||
mod join; | ||
mod kick; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters