updateNicks

This commit is contained in:
blackbeard420 2020-01-06 19:45:31 -05:00
parent f1a12eacee
commit ae3a7cdecb

19
irc.go
View File

@ -114,6 +114,18 @@ func GetNick(name string) string {
return strings.Split(name, "!")[0]
}
func (c *Connection) updateNicks(channel string, names []string) {
for _, i := range names {
for _, n := range c.userList[channel] {
if n == i {
continue
}
c.userList[channel] = append(c.userList[channel], i)
log.Printf("added nick: %s to channel %s\n", channel, i)
}
}
}
//TODO: simplify this to pass gocyclo
func (c *Connection) parseMessage(line string) {
if line[0] == ':' {
@ -138,12 +150,7 @@ func (c *Connection) parseMessage(line string) {
idx := strings.Index(args, "=")
idx += 2
s := strings.Split(args[idx:], ":")
log.Printf("names: %s: %s\n", s[0], s[1])
names := strings.Split(s[1], " ")
ch := strings.ToLower(s[0])
for _, i := range names {
c.userList[ch] = append(c.userList[ch], i)
}
c.updateNicks(strings.ToLower(s[0]), strings.Split(s[1], " "))
}
if c.NumericCallback != nil {