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

View File

@ -5,6 +5,7 @@ import "net"
const (
VERSION = "1.0.0"
APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION
BLESSED_CHANNEL = "#chat"
)
type Server struct {