remove support for channel modes
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
e866451b7a
commit
cb736df27c
33
server.go
33
server.go
@ -22,7 +22,6 @@ func NewServer(name string) *Server {
|
||||
name: BLESSED_CHANNEL,
|
||||
topic: name,
|
||||
clientMap: make(map[string]*Client),
|
||||
mode: ChannelMode{},
|
||||
modeMap: make(map[string]*ClientMode),
|
||||
},
|
||||
}
|
||||
@ -157,30 +156,18 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
|
||||
message := strings.Join(args[1:], " ")
|
||||
|
||||
if strings.ToLower(args[0]) == BLESSED_CHANNEL {
|
||||
if s.channel.mode.noExternal {
|
||||
if _, inChannel := s.channel.clientMap[client.key]; !inChannel {
|
||||
//Not in channel, not allowed to send
|
||||
client.reply(errCannotSend, args[0])
|
||||
return
|
||||
}
|
||||
}
|
||||
if s.channel.mode.moderated {
|
||||
clientMode := s.channel.modeMap[client.key]
|
||||
if !clientMode.operator && !clientMode.voice {
|
||||
//It's moderated and we're not +v or +o, do nothing
|
||||
client.reply(errCannotSend, args[0])
|
||||
return
|
||||
}
|
||||
}
|
||||
for _, c := range s.channel.clientMap {
|
||||
if c != client {
|
||||
c.reply(rplMsg, client.nick, args[0], message)
|
||||
}
|
||||
}
|
||||
|
||||
} else if client2, clientExists := s.clientMap[strings.ToLower(args[0])]; clientExists {
|
||||
client2.reply(rplMsg, client.nick, client2.nick, message)
|
||||
|
||||
} else {
|
||||
client.reply(errNoSuchNick, args[0])
|
||||
|
||||
}
|
||||
|
||||
case "QUIT":
|
||||
@ -300,23 +287,19 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
|
||||
return
|
||||
}
|
||||
|
||||
channelKey := strings.ToLower(args[0])
|
||||
|
||||
channelExists := channelKey == BLESSED_CHANNEL
|
||||
if !channelExists {
|
||||
if strings.ToLower(args[0]) != BLESSED_CHANNEL {
|
||||
client.reply(errNoSuchNick, args[0])
|
||||
return
|
||||
}
|
||||
mode := s.channel.mode
|
||||
|
||||
if len(args) == 1 {
|
||||
//No more args, they just want the mode
|
||||
client.reply(rplChannelModeIs, args[0], mode.String(), "")
|
||||
return
|
||||
client.reply(rplChannelModeIs, args[0], BLESSED_CHANNEL_MODE, "")
|
||||
} else {
|
||||
// Setting modes is disallowed
|
||||
client.reply(errNoPriv)
|
||||
}
|
||||
|
||||
// Setting modes is disallowed
|
||||
client.reply(errNoPriv)
|
||||
return
|
||||
|
||||
default:
|
||||
|
32
typedefs.go
32
typedefs.go
@ -3,9 +3,10 @@ package main
|
||||
import "net"
|
||||
|
||||
const (
|
||||
VERSION = "1.0.0"
|
||||
APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION
|
||||
BLESSED_CHANNEL = "#chat"
|
||||
VERSION = "1.0.0"
|
||||
APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION
|
||||
BLESSED_CHANNEL = "#chat" // must be lowercase
|
||||
BLESSED_CHANNEL_MODE = "n" // means that you have to be in the channel to chat, but that's it
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@ -47,34 +48,9 @@ type Channel struct {
|
||||
name string
|
||||
topic string
|
||||
clientMap map[string]*Client
|
||||
mode ChannelMode
|
||||
modeMap map[string]*ClientMode
|
||||
}
|
||||
|
||||
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.secret {
|
||||
modeStr += "s"
|
||||
}
|
||||
if m.topicLocked {
|
||||
modeStr += "t"
|
||||
}
|
||||
if m.moderated {
|
||||
modeStr += "m"
|
||||
}
|
||||
if m.noExternal {
|
||||
modeStr += "n"
|
||||
}
|
||||
return modeStr
|
||||
}
|
||||
|
||||
type ClientMode struct {
|
||||
operator bool //Channel operator
|
||||
voice bool //Has voice
|
||||
|
Loading…
Reference in New Issue
Block a user