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 {