From cb3ba59cf7542416d56b0f91ed5da0cec9765963 Mon Sep 17 00:00:00 2001 From: "." <.@.> Date: Mon, 2 May 2016 19:13:09 +1200 Subject: [PATCH] only list our blessed channel --HG-- branch : nmdc-ircfrontend --- server.go | 49 +++++++++++++------------------------------------ typedefs.go | 5 +++-- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/server.go b/server.go index 55cbc93..87754dc 100644 --- a/server.go +++ b/server.go @@ -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) - client.reply(rplList, listItem) - } + // 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) - 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) diff --git a/typedefs.go b/typedefs.go index 017c8cf..4504d48 100644 --- a/typedefs.go +++ b/typedefs.go @@ -3,8 +3,9 @@ package main import "net" const ( - VERSION = "1.0.0" - APP_DESCRIPTION = "nmdc-ircfrontend v"+VERSION + VERSION = "1.0.0" + APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION + BLESSED_CHANNEL = "#chat" ) type Server struct {