mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-26 12:42:50 +01:00
fix #1472
HELP responses weren't taking the client nickname as a parameter, as is standard.
This commit is contained in:
parent
a7c5696517
commit
6965031aa9
@ -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
|
||||
|
15
irc/help.go
15
irc/help.go
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user