3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00
HELP responses weren't taking the client nickname as a parameter,
as is standard.
This commit is contained in:
Shivaram Lingamneni 2020-12-29 05:20:18 -05:00
parent a7c5696517
commit 6965031aa9
2 changed files with 13 additions and 17 deletions

View File

@ -1015,16 +1015,17 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
}
// HELP [<query>]
// HELPOP [<query>]
func helpHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
argument := strings.ToLower(strings.TrimSpace(strings.Join(msg.Params, " ")))
if len(argument) < 1 {
if len(msg.Params) == 0 {
client.sendHelp("HELPOP", client.t(`HELPOP <argument>
Get an explanation of <argument>, or "index" for a list of help topics.`), rb)
return false
}
argument := strings.ToLower(strings.TrimSpace(msg.Params[0]))
// handle index
if argument == "index" {
client.sendHelp("HELP", server.helpIndexManager.GetIndex(client.Languages(), client.HasMode(modes.Operator)), rb)
@ -1035,14 +1036,12 @@ Get an explanation of <argument>, or "index" for a list of help topics.`), rb)
if exists && (!helpHandler.oper || (helpHandler.oper && client.HasMode(modes.Operator))) {
if helpHandler.textGenerator != nil {
client.sendHelp(strings.ToUpper(argument), helpHandler.textGenerator(client), rb)
client.sendHelp(argument, helpHandler.textGenerator(client), rb)
} else {
client.sendHelp(strings.ToUpper(argument), client.t(helpHandler.text), rb)
client.sendHelp(argument, client.t(helpHandler.text), rb)
}
} else {
args := msg.Params
args = append(args, client.t("Help not found"))
rb.Add(nil, server.name, ERR_HELPNOTFOUND, args...)
rb.Add(nil, server.name, ERR_HELPNOTFOUND, utils.SafeErrorParam(argument), client.t("Help not found"))
}
return false

View File

@ -752,22 +752,19 @@ func (hm *HelpIndexManager) GenerateIndices(lm *languages.Manager) {
}
// sendHelp sends the client help of the given string.
func (client *Client) sendHelp(name string, text string, rb *ResponseBuffer) {
splitName := strings.Split(name, " ")
func (client *Client) sendHelp(helpEntry string, text string, rb *ResponseBuffer) {
helpEntry = strings.ToUpper(helpEntry)
nick := client.Nick()
textLines := strings.Split(text, "\n")
for i, line := range textLines {
args := splitName
args = append(args, line)
if i == 0 {
rb.Add(nil, client.server.name, RPL_HELPSTART, args...)
rb.Add(nil, client.server.name, RPL_HELPSTART, nick, helpEntry, line)
} else {
rb.Add(nil, client.server.name, RPL_HELPTXT, args...)
rb.Add(nil, client.server.name, RPL_HELPTXT, nick, helpEntry, line)
}
}
args := splitName
args = append(args, client.t("End of /HELPOP"))
rb.Add(nil, client.server.name, RPL_ENDOFHELP, args...)
rb.Add(nil, client.server.name, RPL_ENDOFHELP, nick, helpEntry, client.t("End of /HELPOP"))
}
// GetHelpIndex returns the help index for the given language.