only list our blessed channel

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
. 2016-05-02 19:13:09 +12:00
parent 10e9aa473d
commit cb3ba59cf7
2 changed files with 16 additions and 38 deletions

View File

@ -120,18 +120,14 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
return return
} }
if args[0] == "0" { switch args[0] {
// Intend to quit all channels case BLESSED_CHANNEL:
// But we don't allow that // That's fine, but they're already there
return case "0":
} // Intend to quit all channels, but we don't allow that
default:
channels := strings.Split(args[0], ",") client.reply(rplKill, "There is only '"+BLESSED_CHANNEL+"'.", "")
for _, channel := range channels { client.disconnect()
//Join the channel if it's valid
if channelRegexp.MatchString(channel) {
client.joinChannel(channel)
}
} }
case "PART": case "PART":
@ -227,31 +223,12 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
return return
} }
if len(args) == 0 { // FIXME
for channelName, channel := range s.channelMap { channel := s.channelMap[BLESSED_CHANNEL]
if channel.mode.secret { listItem := fmt.Sprintf("%s %d :%s", channel.name, len(channel.clientMap), channel.topic)
if _, inChannel := channel.clientMap[client.key]; !inChannel { client.reply(rplList, listItem)
//Not in the channel, skip client.reply(rplListEnd)
continue
}
}
listItem := fmt.Sprintf("%s %d :%s", channelName, len(channel.clientMap), channel.topic)
client.reply(rplList, listItem)
}
client.reply(rplListEnd)
} else {
channels := strings.Split(args[0], ",")
for _, channelName := range channels {
if channel, exists := s.channelMap[strings.ToLower(channelName)]; exists {
listItem := fmt.Sprintf("%s %d :%s", channelName, len(channel.clientMap), channel.topic)
client.reply(rplList, listItem)
}
}
client.reply(rplListEnd)
}
case "OPER": case "OPER":
if client.registered == false { if client.registered == false {
client.reply(errNotReg) client.reply(errNotReg)

View File

@ -3,8 +3,9 @@ package main
import "net" import "net"
const ( const (
VERSION = "1.0.0" VERSION = "1.0.0"
APP_DESCRIPTION = "nmdc-ircfrontend v"+VERSION APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION
BLESSED_CHANNEL = "#chat"
) )
type Server struct { type Server struct {