mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
I don't understand why USERHOST is working with spaces...
This commit is contained in:
parent
f3c9c2b4b5
commit
1bb9502206
@ -1843,12 +1843,13 @@ func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
}
|
||||
}
|
||||
client.Send(nil, server.name, RPL_LUSERCLIENT, client.nick, fmt.Sprintf("There are %d users and %d invisible on %d server(s)", totalcount, invisiblecount, 1))
|
||||
client.Send(nil, server.name, RPL_LUSEROP, client.nick, fmt.Sprintf("%d operators online", opercount))
|
||||
client.Send(nil, server.name, RPL_LUSEROP, client.nick, fmt.Sprintf("%d IRC Operators online", opercount))
|
||||
client.Send(nil, server.name, RPL_LUSERCHANNELS, client.nick, fmt.Sprintf("%d channels formed", len(server.channels)))
|
||||
client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf("I have %d clients and %d servers", totalcount, 1))
|
||||
return false
|
||||
}
|
||||
|
||||
// USERHOST <nickname> [<nickname> <nickname> ...]
|
||||
func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
nickname := msg.Params[0]
|
||||
|
||||
@ -1860,9 +1861,9 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool
|
||||
}
|
||||
|
||||
if target.flags[Away] {
|
||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf(strings.TrimSpace("%s =- %s @ %s"), target.nick, target.username, target.hostname))
|
||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf("%s =- %s @ %s", target.nick, target.username, target.hostname))
|
||||
} else {
|
||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf(strings.TrimSpace("%s =+ %s @ %s"), target.nick, target.username, target.hostname))
|
||||
client.Send(nil, client.server.name, RPL_USERHOST, client.nick, fmt.Sprintf("%s =- %s @ %s", target.nick, target.username, target.hostname))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
17
irc/util.go
17
irc/util.go
@ -3,6 +3,11 @@
|
||||
|
||||
package irc
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
@ -33,3 +38,15 @@ func argsToStrings(maxLength int, arguments []string, delim string) []string {
|
||||
|
||||
return messages
|
||||
}
|
||||
|
||||
// stripSpaces removes all whitespaces inside a string
|
||||
func stripSpaces(str string) string {
|
||||
return strings.Map(func(r rune) rune {
|
||||
if unicode.IsSpace(r) {
|
||||
// if the character is a space, drop it
|
||||
return -1
|
||||
}
|
||||
// else keep it in the string
|
||||
return r
|
||||
}, str)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user