Removed +q and +a channel modes for admins and server operators

This commit is contained in:
Andreas Neue 2016-08-03 09:21:44 +02:00
parent 1e96d0c9d7
commit e6579a4b9a
3 changed files with 22 additions and 22 deletions

View File

@ -24,8 +24,6 @@ type Client interface {
} }
type RemoteClient struct { type RemoteClient struct {
Registered chan bool
server *Server server *Server
name string name string

View File

@ -55,7 +55,7 @@ func handleCmdPrivmsg(sv *Server, msg *irc.Message) {
clid := strings.ToLower(msg.Pre) clid := strings.ToLower(msg.Pre)
chid := strings.ToLower(msg.Args[0]) chid := strings.ToLower(msg.Args[0])
if sv.channelCheckMode(chid, "m") && if sv.channelCheckMode(chid, "m") &&
!sv.channelCheckPerm(chid, clid, "qaohv") { !sv.channelCheckPerm(chid, clid, "ohv") {
sv.sendReply(clid, ERR_CANNOTSENDTOCHAN, chid, "Cannot send to channel") sv.sendReply(clid, ERR_CANNOTSENDTOCHAN, chid, "Cannot send to channel")
return return
} }
@ -86,17 +86,17 @@ func handleCmdJoin(sv *Server, msg *irc.Message) {
sv.channelNames(msg.Pre, msg.Args[0]) sv.channelNames(msg.Pre, msg.Args[0])
_, isadm := sv.admins[clid] _, isadm := sv.admins[clid]
if isadm { if isadm {
mode := "q " + clid mode := "o " + clid
sv.chModes[chid][mode] = true sv.chModes[chid][mode] = true
sv.sendMsg(irc.M(sv.host, "MODE", chid+" +q "+clid, "")) sv.sendMsg(irc.M(sv.host, "MODE", chid+" +o "+clid, ""))
sv.sendMsg(irc.M(sv.host, "PRIVMSG", chid, clid+" is a server administrator")) sv.sendMsg(irc.M(sv.host, "PRIVMSG", chid, clid+" is a server administrator"))
return return
} }
_, isop := sv.opers[clid] _, isop := sv.opers[clid]
if isop { if isop {
mode := "a " + clid mode := "o " + clid
sv.chModes[chid][mode] = true sv.chModes[chid][mode] = true
sv.sendMsg(irc.M(sv.host, "MODE", chid+" +a "+clid, "")) sv.sendMsg(irc.M(sv.host, "MODE", chid+" +o "+clid, ""))
sv.sendMsg(irc.M(sv.host, "PRIVMSG", chid, clid+" is a server operator")) sv.sendMsg(irc.M(sv.host, "PRIVMSG", chid, clid+" is a server operator"))
return return
} }
@ -120,8 +120,8 @@ func handleCmdPart(sv *Server, msg *irc.Message) {
} }
sv.sendMsg(msg) sv.sendMsg(msg)
delete(sv.chUsers[chid], clid) delete(sv.chUsers[chid], clid)
delete(sv.chModes[chid], "q "+clid) //delete(sv.chModes[chid], "q "+clid)
delete(sv.chModes[chid], "a "+clid) //delete(sv.chModes[chid], "a "+clid)
delete(sv.chModes[chid], "o "+clid) delete(sv.chModes[chid], "o "+clid)
delete(sv.chModes[chid], "h "+clid) delete(sv.chModes[chid], "h "+clid)
delete(sv.chModes[chid], "v "+clid) delete(sv.chModes[chid], "v "+clid)
@ -158,27 +158,27 @@ func handleCmdMode(sv *Server, msg *irc.Message) {
switch modeSwitch[1] { switch modeSwitch[1] {
// maybe this can be done more elegant // maybe this can be done more elegant
case 'o': case 'o':
if !sv.channelCheckPerm(chid, clid, "qao") { if !sv.channelCheckPerm(chid, clid, "o") {
goto noPerm goto noPerm
} }
case 'h': case 'h':
if !sv.channelCheckPerm(chid, clid, "qao") { if !sv.channelCheckPerm(chid, clid, "o") {
goto noPerm goto noPerm
} }
case 'b': case 'b':
if !sv.channelCheckPerm(chid, clid, "qaoh") { if !sv.channelCheckPerm(chid, clid, "oh") {
goto noPerm goto noPerm
} }
case 'v': case 'v':
if !sv.channelCheckPerm(chid, clid, "qaoh") { if !sv.channelCheckPerm(chid, clid, "oh") {
goto noPerm goto noPerm
} }
case 'm': case 'm':
if !sv.channelCheckPerm(chid, clid, "qaoh") { if !sv.channelCheckPerm(chid, clid, "oh") {
goto noPerm goto noPerm
} }
case 't': case 't':
if !sv.channelCheckPerm(chid, clid, "qaoh") { if !sv.channelCheckPerm(chid, clid, "oh") {
goto noPerm goto noPerm
} }
default: default:
@ -210,7 +210,7 @@ func handleCmdTopic(sv *Server, msg *irc.Message) {
sv.sendReply(msg.Pre, RPL_TOPIC, chid, sv.chTopics[chid]) sv.sendReply(msg.Pre, RPL_TOPIC, chid, sv.chTopics[chid])
} else { } else {
if sv.channelCheckMode(chid, "t") && if sv.channelCheckMode(chid, "t") &&
!sv.channelCheckPerm(chid, clid, "qaoh") { !sv.channelCheckPerm(chid, clid, "oh") {
sv.sendReply(clid, ERR_CHANOPRIVSNEEDED, chid, "You're not channel operator") sv.sendReply(clid, ERR_CHANOPRIVSNEEDED, chid, "You're not channel operator")
return return
} }
@ -224,13 +224,13 @@ func handleCmdKick(sv *Server, msg *irc.Message) {
chid := strings.ToLower(msg.Args[0]) chid := strings.ToLower(msg.Args[0])
clid := strings.ToLower(msg.Pre) clid := strings.ToLower(msg.Pre)
target := strings.ToLower(msg.Args[1]) target := strings.ToLower(msg.Args[1])
if !sv.channelCheckPerm(chid, clid, "qaoh") { if !sv.channelCheckPerm(chid, clid, "oh") {
sv.sendReply(clid, ERR_CHANOPRIVSNEEDED, chid, "You're not channel operator") sv.sendReply(clid, ERR_CHANOPRIVSNEEDED, chid, "You're not channel operator")
} }
sv.sendMsg(msg) sv.sendMsg(msg)
delete(sv.chUsers[chid], target) delete(sv.chUsers[chid], target)
delete(sv.chModes[chid], "q "+target) //delete(sv.chModes[chid], "q "+target)
delete(sv.chModes[chid], "a "+target) //delete(sv.chModes[chid], "a "+target)
delete(sv.chModes[chid], "o "+target) delete(sv.chModes[chid], "o "+target)
delete(sv.chModes[chid], "h "+target) delete(sv.chModes[chid], "h "+target)
delete(sv.chModes[chid], "v "+target) delete(sv.chModes[chid], "v "+target)

View File

@ -22,7 +22,9 @@ const (
) )
var myinfo string = "%s %s/%s * *" var myinfo string = "%s %s/%s * *"
var isupport string = "CASEMAPPING=rfc1459 CHANTYPES=# NICKLEN=32 MODES=1 PREFIX=(qaohv)~&@%+"
//var isupport string = "CASEMAPPING=rfc1459 CHANTYPES=# NICKLEN=32 MODES=1 PREFIX=(qaohv)~&@%+"
var isupport string = "CASEMAPPING=rfc1459 CHANTYPES=# NICKLEN=32 MODES=1 PREFIX=(ohv)@%+"
type Server struct { type Server struct {
queue chan *irc.Message queue chan *irc.Message
@ -332,8 +334,8 @@ func (sv *Server) channelNames(nick, ch string) {
if names != "" { if names != "" {
names += " " names += " "
} }
modeFlags := "qaohv" modeFlags := "ohv"
modeChars := "~&@%+" modeChars := "@%+"
for i, mf := range modeFlags { for i, mf := range modeFlags {
if _, exists := sv.chModes[chid][string(mf)+" "+clid]; exists { if _, exists := sv.chModes[chid][string(mf)+" "+clid]; exists {
name = string(modeChars[i]) + name name = string(modeChars[i]) + name