threadsafe access to upstream userlist
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
e2c2953fc5
commit
3cda342302
4
TODO.txt
4
TODO.txt
@ -4,16 +4,12 @@ PRE-RELEASE
|
||||
|
||||
- detect our own /me messages + don't echo back
|
||||
|
||||
- threadsafe access to libnmdc hub options
|
||||
|
||||
- client descriptions (CTCP USERINFO)
|
||||
|
||||
- expose upstream op status
|
||||
|
||||
- remove color code escape sequences
|
||||
|
||||
---- libnmdc no alert on bad nick
|
||||
|
||||
|
||||
WISHLIST
|
||||
========
|
||||
|
37
server.go
37
server.go
@ -302,7 +302,7 @@ func (s *Server) handleRegisteredCommand(command string, args []string) {
|
||||
if s.upstream == nil {
|
||||
s.reply(rplList, fmt.Sprintf("%s %d :%s", BLESSED_CHANNEL, 1, "-"))
|
||||
} else {
|
||||
s.reply(rplList, fmt.Sprintf("%s %d :%s", BLESSED_CHANNEL, len(s.upstream.Users), s.upstream.HubName))
|
||||
s.reply(rplList, fmt.Sprintf("%s %d :%s", BLESSED_CHANNEL, s.upstream.UserCount(), s.upstream.HubName))
|
||||
}
|
||||
s.reply(rplListEnd)
|
||||
|
||||
@ -392,7 +392,7 @@ func (s *Server) handleJoinedCommand(command string, args []string) {
|
||||
if strings.ToLower(args[0]) == BLESSED_CHANNEL {
|
||||
s.upstream.SayPublic(message)
|
||||
|
||||
} else if _, clientExists := s.upstream.Users[args[0]]; clientExists {
|
||||
} else if s.upstream.UserExists(args[0]) {
|
||||
s.upstream.SayPrivate(args[0], message)
|
||||
|
||||
} else {
|
||||
@ -486,11 +486,14 @@ func (s *Server) DisconnectClient() {
|
||||
func (s *Server) sendNames() {
|
||||
names := s.upstreamLauncher.Self.Nick // always include ourselves
|
||||
if s.upstream != nil {
|
||||
for nick, _ := range s.upstream.Users {
|
||||
if nick != s.upstreamLauncher.Self.Nick { // but don't repeat ourselves
|
||||
names += " " + nick
|
||||
s.upstream.Users(func(u *map[string]libnmdc.UserInfo) error {
|
||||
for nick, _ := range *u {
|
||||
if nick != s.upstreamLauncher.Self.Nick { // but don't repeat ourselves
|
||||
names += " " + nick
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
s.reply(rplNames, BLESSED_CHANNEL, names)
|
||||
@ -506,18 +509,24 @@ func (s *Server) sendWho(arg string) {
|
||||
// always include ourselves
|
||||
s.reply(rplWho, s.upstreamLauncher.Self.Nick, arg)
|
||||
|
||||
for nick, _ := range s.upstream.Users {
|
||||
if nick != s.upstreamLauncher.Self.Nick { // but don't repeat ourselves
|
||||
s.reply(rplWho, nick, arg)
|
||||
s.upstream.Users(func(u *map[string]libnmdc.UserInfo) error {
|
||||
for nick, _ := range *u {
|
||||
if nick != s.upstreamLauncher.Self.Nick { // but don't repeat ourselves
|
||||
s.reply(rplWho, nick, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
} else {
|
||||
// argument is a filter
|
||||
for nick, _ := range s.upstream.Users {
|
||||
if strings.Contains(nick, arg) {
|
||||
s.reply(rplWho, nick, arg)
|
||||
s.upstream.Users(func(u *map[string]libnmdc.UserInfo) error {
|
||||
for nick, _ := range *u {
|
||||
if strings.Contains(nick, arg) {
|
||||
s.reply(rplWho, nick, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
s.reply(rplEndOfWho, arg)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user