Browse Source

fix #1472

HELP responses weren't taking the client nickname as a parameter,
as is standard.
tags/v2.5.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
6965031aa9
2 changed files with 13 additions and 17 deletions
  1. 7
    8
      irc/handlers.go
  2. 6
    9
      irc/help.go

+ 7
- 8
irc/handlers.go View File

@@ -1015,16 +1015,17 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
1015 1015
 }
1016 1016
 
1017 1017
 // HELP [<query>]
1018
+// HELPOP [<query>]
1018 1019
 func helpHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
1019
-	argument := strings.ToLower(strings.TrimSpace(strings.Join(msg.Params, " ")))
1020
-
1021
-	if len(argument) < 1 {
1020
+	if len(msg.Params) == 0 {
1022 1021
 		client.sendHelp("HELPOP", client.t(`HELPOP <argument>
1023 1022
 
1024 1023
 Get an explanation of <argument>, or "index" for a list of help topics.`), rb)
1025 1024
 		return false
1026 1025
 	}
1027 1026
 
1027
+	argument := strings.ToLower(strings.TrimSpace(msg.Params[0]))
1028
+
1028 1029
 	// handle index
1029 1030
 	if argument == "index" {
1030 1031
 		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)
1035 1036
 
1036 1037
 	if exists && (!helpHandler.oper || (helpHandler.oper && client.HasMode(modes.Operator))) {
1037 1038
 		if helpHandler.textGenerator != nil {
1038
-			client.sendHelp(strings.ToUpper(argument), helpHandler.textGenerator(client), rb)
1039
+			client.sendHelp(argument, helpHandler.textGenerator(client), rb)
1039 1040
 		} else {
1040
-			client.sendHelp(strings.ToUpper(argument), client.t(helpHandler.text), rb)
1041
+			client.sendHelp(argument, client.t(helpHandler.text), rb)
1041 1042
 		}
1042 1043
 	} else {
1043
-		args := msg.Params
1044
-		args = append(args, client.t("Help not found"))
1045
-		rb.Add(nil, server.name, ERR_HELPNOTFOUND, args...)
1044
+		rb.Add(nil, server.name, ERR_HELPNOTFOUND, utils.SafeErrorParam(argument), client.t("Help not found"))
1046 1045
 	}
1047 1046
 
1048 1047
 	return false

+ 6
- 9
irc/help.go View File

@@ -752,22 +752,19 @@ func (hm *HelpIndexManager) GenerateIndices(lm *languages.Manager) {
752 752
 }
753 753
 
754 754
 // sendHelp sends the client help of the given string.
755
-func (client *Client) sendHelp(name string, text string, rb *ResponseBuffer) {
756
-	splitName := strings.Split(name, " ")
755
+func (client *Client) sendHelp(helpEntry string, text string, rb *ResponseBuffer) {
756
+	helpEntry = strings.ToUpper(helpEntry)
757
+	nick := client.Nick()
757 758
 	textLines := strings.Split(text, "\n")
758 759
 
759 760
 	for i, line := range textLines {
760
-		args := splitName
761
-		args = append(args, line)
762 761
 		if i == 0 {
763
-			rb.Add(nil, client.server.name, RPL_HELPSTART, args...)
762
+			rb.Add(nil, client.server.name, RPL_HELPSTART, nick, helpEntry, line)
764 763
 		} else {
765
-			rb.Add(nil, client.server.name, RPL_HELPTXT, args...)
764
+			rb.Add(nil, client.server.name, RPL_HELPTXT, nick, helpEntry, line)
766 765
 		}
767 766
 	}
768
-	args := splitName
769
-	args = append(args, client.t("End of /HELPOP"))
770
-	rb.Add(nil, client.server.name, RPL_ENDOFHELP, args...)
767
+	rb.Add(nil, client.server.name, RPL_ENDOFHELP, nick, helpEntry, client.t("End of /HELPOP"))
771 768
 }
772 769
 
773 770
 // GetHelpIndex returns the help index for the given language.

Loading…
Cancel
Save