Refactor nickserv.go to better support NS HELP and translations

This commit is contained in:
Daniel Oaks 2018-04-01 11:22:06 +10:00
parent a39c46d470
commit 7b8c4e7e91
3 changed files with 351 additions and 218 deletions

View file

@ -3,6 +3,19 @@
package utils
import "strings"
// ExtractParam extracts a parameter from the given string, returning the param and the rest of the string.
func ExtractParam(line string) (string, string) {
rawParams := strings.SplitN(strings.TrimSpace(line), " ", 2)
param0 := rawParams[0]
var param1 string
if 1 < len(rawParams) {
param1 = strings.TrimSpace(rawParams[1])
}
return param0, param1
}
// ArgsToStrings takes the arguments and splits them into a series of strings,
// each argument separated by delim and each string bounded by maxLength.
func ArgsToStrings(maxLength int, arguments []string, delim string) []string {