add support for ircv3's userhost-in-names
This commit is contained in:
parent
8489a4860e
commit
03d0b5de8c
17
cap.go
17
cap.go
|
@ -12,14 +12,15 @@ import (
|
|||
)
|
||||
|
||||
var possibleCap = map[string][]string{
|
||||
"account-notify": nil,
|
||||
"account-tag": nil,
|
||||
"away-notify": nil,
|
||||
"batch": nil,
|
||||
"cap-notify": nil,
|
||||
"chghost": nil,
|
||||
"extended-join": nil,
|
||||
"message-tags": nil,
|
||||
"account-notify": nil,
|
||||
"account-tag": nil,
|
||||
"away-notify": nil,
|
||||
"batch": nil,
|
||||
"cap-notify": nil,
|
||||
"chghost": nil,
|
||||
"extended-join": nil,
|
||||
"message-tags": nil,
|
||||
"userhost-in-names": nil,
|
||||
}
|
||||
|
||||
func (c *Client) listCAP() error {
|
||||
|
|
29
handlers.go
29
handlers.go
|
@ -338,18 +338,45 @@ func handleNAMES(c *Client, e Event) {
|
|||
|
||||
parts := strings.Split(e.Trailing, " ")
|
||||
|
||||
var host, ident, modes, nick string
|
||||
var ok bool
|
||||
|
||||
c.state.mu.Lock()
|
||||
for i := 0; i < len(parts); i++ {
|
||||
modes, nick, ok := parseUserPrefix(parts[i])
|
||||
modes, nick, ok = parseUserPrefix(parts[i])
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// If userhost-in-names.
|
||||
if strings.Contains(nick, "@") {
|
||||
s := ParseSource(nick)
|
||||
if s == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
host = s.Host
|
||||
nick = s.Name
|
||||
ident = s.Ident
|
||||
}
|
||||
|
||||
if !IsValidNick(nick) {
|
||||
continue
|
||||
}
|
||||
|
||||
user := c.state.createUserIfNotExists(e.Params[len(e.Params)-1], nick)
|
||||
if user == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Add necessary userhost-in-names data into the user.
|
||||
if host != "" {
|
||||
user.Host = host
|
||||
}
|
||||
if ident != "" {
|
||||
user.Ident = ident
|
||||
}
|
||||
|
||||
// Don't append modes, overwrite them.
|
||||
user.Perms.set(modes, false)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue