Set default channel modes to +nt

This commit is contained in:
Daniel Oaks 2016-04-21 19:29:50 +10:00
parent 99d442196f
commit cd7d30a997
3 changed files with 13 additions and 3 deletions

View File

@ -18,7 +18,7 @@ type Channel struct {
// NewChannel creates a new channel from a `Server` and a `name` // NewChannel creates a new channel from a `Server` and a `name`
// string, which must be unique on the server. // string, which must be unique on the server.
func NewChannel(s *Server, name Name) *Channel { func NewChannel(s *Server, name Name, addDefaultModes bool) *Channel {
channel := &Channel{ channel := &Channel{
flags: make(ChannelModeSet), flags: make(ChannelModeSet),
lists: map[ChannelMode]*UserMaskSet{ lists: map[ChannelMode]*UserMaskSet{
@ -31,6 +31,12 @@ func NewChannel(s *Server, name Name) *Channel {
server: s, server: s,
} }
if addDefaultModes {
for _, mode := range DefaultChannelModes {
channel.flags[mode] = true
}
}
s.channels.Add(channel) s.channels.Add(channel)
return channel return channel

View File

@ -94,6 +94,10 @@ var (
OpOnlyTopic, Persistent, Secret, Theater, UserLimit, OpOnlyTopic, Persistent, Secret, Theater, UserLimit,
} }
DefaultChannelModes = ChannelModes{
NoOutside, OpOnlyTopic,
}
// ChannelPrivModes holds the list of modes that are privileged, ie founder/op/halfop, in order. // ChannelPrivModes holds the list of modes that are privileged, ie founder/op/halfop, in order.
// voice is not in this list because it cannot perform channel operator actions. // voice is not in this list because it cannot perform channel operator actions.
ChannelPrivModes = ChannelModes{ ChannelPrivModes = ChannelModes{

View File

@ -156,7 +156,7 @@ func (server *Server) loadChannels() {
continue continue
} }
channel := NewChannel(server, NewName(name)) channel := NewChannel(server, NewName(name), false)
for _, flag := range flags { for _, flag := range flags {
channel.flags[ChannelMode(flag)] = true channel.flags[ChannelMode(flag)] = true
} }
@ -449,7 +449,7 @@ func (m *JoinCommand) HandleServer(s *Server) {
channel := s.channels.Get(name) channel := s.channels.Get(name)
if channel == nil { if channel == nil {
channel = NewChannel(s, name) channel = NewChannel(s, name, true)
} }
channel.Join(client, key) channel.Join(client, key)
} }