WIP work on WHO support
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
479fbf104b
commit
114823b0cc
21
server.go
21
server.go
@ -77,7 +77,7 @@ func (s *Server) RunWorker() {
|
|||||||
|
|
||||||
// Send the connection handshake.
|
// Send the connection handshake.
|
||||||
// Can't connect to the upstream server yet, until we've recieved a nick.
|
// Can't connect to the upstream server yet, until we've recieved a nick.
|
||||||
s.sendClientGlobalMessage(s.motd)
|
s.sendMOTD(s.motd)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if s.clientConn == nil {
|
if s.clientConn == nil {
|
||||||
@ -152,7 +152,7 @@ func (s *Server) upstreamWorker() {
|
|||||||
// description change - no relevance for IRC users
|
// description change - no relevance for IRC users
|
||||||
|
|
||||||
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
|
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
|
||||||
s.sendClientGlobalMessage("Upstream: " + hubEvent.StateChange.Format())
|
s.reply(rplMsg, "", BLESSED_CHANNEL, "* Upstream: "+hubEvent.StateChange.Format())
|
||||||
|
|
||||||
case libnmdc.EVENT_HUBNAME_CHANGED:
|
case libnmdc.EVENT_HUBNAME_CHANGED:
|
||||||
s.sendChannelTopic(hubEvent.Nick)
|
s.sendChannelTopic(hubEvent.Nick)
|
||||||
@ -168,8 +168,7 @@ func (s *Server) upstreamWorker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case libnmdc.EVENT_SYSTEM_MESSAGE_FROM_CONN, libnmdc.EVENT_SYSTEM_MESSAGE_FROM_HUB:
|
case libnmdc.EVENT_SYSTEM_MESSAGE_FROM_CONN, libnmdc.EVENT_SYSTEM_MESSAGE_FROM_HUB:
|
||||||
s.reply(rplMsg, "", BLESSED_CHANNEL, hubEvent.Message) // experimental
|
s.reply(rplMsg, "", BLESSED_CHANNEL, hubEvent.Message)
|
||||||
// s.sendClientGlobalMessage(hubEvent.Message)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,22 +359,22 @@ func (s *Server) handleRegisteredCommand(command string, args []string) {
|
|||||||
|
|
||||||
if args[0] == BLESSED_CHANNEL {
|
if args[0] == BLESSED_CHANNEL {
|
||||||
// always include ourselves
|
// always include ourselves
|
||||||
s.reply(rplWho, s.upstreamLauncher.Self.Nick)
|
s.reply(rplWho, s.upstreamLauncher.Self.Nick, args[0])
|
||||||
|
|
||||||
for nick, _ := range s.upstream.Users {
|
for nick, _ := range s.upstream.Users {
|
||||||
if nick != s.upstreamLauncher.Self.Nick { // but don't repeat ourselves
|
if nick != s.upstreamLauncher.Self.Nick { // but don't repeat ourselves
|
||||||
s.reply(rplWho, nick)
|
s.reply(rplWho, nick, args[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// argument is a filter
|
// argument is a filter
|
||||||
for nick, _ := range s.upstream.Users {
|
for nick, _ := range s.upstream.Users {
|
||||||
if strings.Contains(nick, args[0]) {
|
if strings.Contains(nick, args[0]) {
|
||||||
s.reply(rplWho, nick)
|
s.reply(rplWho, nick, args[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.reply(rplEndOfWho)
|
s.reply(rplEndOfWho, args[0])
|
||||||
|
|
||||||
case "MODE":
|
case "MODE":
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
@ -420,7 +419,7 @@ func (s *Server) sendChannelTopic(topic string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) sendClientGlobalMessage(motd string) {
|
func (s *Server) sendMOTD(motd string) {
|
||||||
s.reply(rplMOTDStart)
|
s.reply(rplMOTDStart)
|
||||||
|
|
||||||
for len(motd) > 80 {
|
for len(motd) > 80 {
|
||||||
@ -455,9 +454,9 @@ func (s *Server) reply(code replyCode, args ...string) {
|
|||||||
s.writeClient(fmt.Sprintf(":%s 366 %s %s :End of NAMES list", s.name, s.upstreamLauncher.Self.Nick, args[0]))
|
s.writeClient(fmt.Sprintf(":%s 366 %s %s :End of NAMES list", s.name, s.upstreamLauncher.Self.Nick, args[0]))
|
||||||
|
|
||||||
case rplWho:
|
case rplWho:
|
||||||
s.writeClient(fmt.Sprintf(":%s 352 %s %s %s %s %s %s H :0 %s", s.name, s.upstreamLauncher.Self.Nick, BLESSED_CHANNEL, args[0], args[0], s.name, args[0], args[0]))
|
s.writeClient(fmt.Sprintf(":%s 352 %s %s %s %s %s %s H :0 %s", s.name, s.upstreamLauncher.Self.Nick, args[1], args[0], args[0], s.name, args[0], args[0]))
|
||||||
case rplEndOfWho:
|
case rplEndOfWho:
|
||||||
s.writeClient(fmt.Sprintf(":%s 315 :End of WHO list", s.name))
|
s.writeClient(fmt.Sprintf(":%s 315 %s %s :End of WHO list", s.name, s.upstreamLauncher.Self.Nick, args[0]))
|
||||||
|
|
||||||
case rplNickChange:
|
case rplNickChange:
|
||||||
s.writeClient(fmt.Sprintf(":%s NICK %s", args[0], args[1]))
|
s.writeClient(fmt.Sprintf(":%s NICK %s", args[0], args[1]))
|
||||||
|
Loading…
Reference in New Issue
Block a user