mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 21:39:25 +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>]
|
// HELP [<query>]
|
||||||
|
// HELPOP [<query>]
|
||||||
func helpHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
func helpHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
||||||
argument := strings.ToLower(strings.TrimSpace(strings.Join(msg.Params, " ")))
|
if len(msg.Params) == 0 {
|
||||||
|
|
||||||
if len(argument) < 1 {
|
|
||||||
client.sendHelp("HELPOP", client.t(`HELPOP <argument>
|
client.sendHelp("HELPOP", client.t(`HELPOP <argument>
|
||||||
|
|
||||||
Get an explanation of <argument>, or "index" for a list of help topics.`), rb)
|
Get an explanation of <argument>, or "index" for a list of help topics.`), rb)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argument := strings.ToLower(strings.TrimSpace(msg.Params[0]))
|
||||||
|
|
||||||
// handle index
|
// handle index
|
||||||
if argument == "index" {
|
if argument == "index" {
|
||||||
client.sendHelp("HELP", server.helpIndexManager.GetIndex(client.Languages(), client.HasMode(modes.Operator)), rb)
|
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 exists && (!helpHandler.oper || (helpHandler.oper && client.HasMode(modes.Operator))) {
|
||||||
if helpHandler.textGenerator != nil {
|
if helpHandler.textGenerator != nil {
|
||||||
client.sendHelp(strings.ToUpper(argument), helpHandler.textGenerator(client), rb)
|
client.sendHelp(argument, helpHandler.textGenerator(client), rb)
|
||||||
} else {
|
} else {
|
||||||
client.sendHelp(strings.ToUpper(argument), client.t(helpHandler.text), rb)
|
client.sendHelp(argument, client.t(helpHandler.text), rb)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args := msg.Params
|
rb.Add(nil, server.name, ERR_HELPNOTFOUND, utils.SafeErrorParam(argument), client.t("Help not found"))
|
||||||
args = append(args, client.t("Help not found"))
|
|
||||||
rb.Add(nil, server.name, ERR_HELPNOTFOUND, args...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
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.
|
// sendHelp sends the client help of the given string.
|
||||||
func (client *Client) sendHelp(name string, text string, rb *ResponseBuffer) {
|
func (client *Client) sendHelp(helpEntry string, text string, rb *ResponseBuffer) {
|
||||||
splitName := strings.Split(name, " ")
|
helpEntry = strings.ToUpper(helpEntry)
|
||||||
|
nick := client.Nick()
|
||||||
textLines := strings.Split(text, "\n")
|
textLines := strings.Split(text, "\n")
|
||||||
|
|
||||||
for i, line := range textLines {
|
for i, line := range textLines {
|
||||||
args := splitName
|
|
||||||
args = append(args, line)
|
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
rb.Add(nil, client.server.name, RPL_HELPSTART, args...)
|
rb.Add(nil, client.server.name, RPL_HELPSTART, nick, helpEntry, line)
|
||||||
} else {
|
} else {
|
||||||
rb.Add(nil, client.server.name, RPL_HELPTXT, args...)
|
rb.Add(nil, client.server.name, RPL_HELPTXT, nick, helpEntry, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args := splitName
|
rb.Add(nil, client.server.name, RPL_ENDOFHELP, nick, helpEntry, client.t("End of /HELPOP"))
|
||||||
args = append(args, client.t("End of /HELPOP"))
|
|
||||||
rb.Add(nil, client.server.name, RPL_ENDOFHELP, args...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHelpIndex returns the help index for the given language.
|
// GetHelpIndex returns the help index for the given language.
|
||||||
|
Loading…
Reference in New Issue
Block a user