From a2b90b7ac6c8326b6966ed77f1ce76a1a1349c97 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Thu, 29 Aug 2013 16:58:50 +0100 Subject: [PATCH] Added the "n" no external mode. --- rosella.go | 32 ++++++++++++++++++-------------- server.go | 9 +++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/rosella.go b/rosella.go index c99ba25..de7f159 100644 --- a/rosella.go +++ b/rosella.go @@ -41,23 +41,27 @@ type ChannelMode struct { secret bool //Channel is hidden from LIST topicLocked bool //Only ops may change topic moderated bool //Only ops and voiced may speak + noExternal bool //Only users in the channel may talk to it } func (m *ChannelMode) String() string { - modeStr := "" - if m.anonymous { - modeStr += "a" - } - if m.secret { - modeStr += "s" - } - if m.topicLocked { - modeStr += "t" - } - if m.moderated { - modeStr += "m" - } - return modeStr + modeStr := "" + if m.anonymous { + modeStr += "a" + } + if m.secret { + modeStr += "s" + } + if m.topicLocked { + modeStr += "t" + } + if m.moderated { + modeStr += "m" + } + if m.noExternal { + modeStr += "n" + } + return modeStr } type ClientMode struct { diff --git a/server.go b/server.go index f5ddd7d..bc36a52 100644 --- a/server.go +++ b/server.go @@ -153,6 +153,13 @@ func (s *Server) handleEvent(e Event) { client, clientExists := s.clientMap[strings.ToLower(args[0])] if chanExists { + if channel.mode.noExternal { + if _, inChannel := channel.clientMap[strings.ToLower(e.client.nick)]; !inChannel { + //Not in channel, not allowed to send + e.client.reply(errCannotSend, args[0]) + return + } + } if channel.mode.moderated { clientMode := channel.modeMap[strings.ToLower(e.client.nick)] if !clientMode.operator && !clientMode.voice { @@ -164,6 +171,8 @@ func (s *Server) handleEvent(e Event) { for _, c := range channel.clientMap { if c != e.client { c.reply(rplMsg, e.client.nick, args[0], message) + e.client.reply(errCannotSend, args[0]) + return } } } else if clientExists {