Added the "n" no external mode.
This commit is contained in:
parent
0ad0dd2989
commit
a2b90b7ac6
32
rosella.go
32
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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user