remove support for kicking other users and changing their mode
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
f8a06775f5
commit
eb597a6592
124
server.go
124
server.go
@ -89,10 +89,13 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
|
|||||||
switch command {
|
switch command {
|
||||||
case "PING":
|
case "PING":
|
||||||
client.reply(rplPong)
|
client.reply(rplPong)
|
||||||
|
|
||||||
case "INFO":
|
case "INFO":
|
||||||
client.reply(rplInfo, APP_DESCRIPTION)
|
client.reply(rplInfo, APP_DESCRIPTION)
|
||||||
|
|
||||||
case "VERSION":
|
case "VERSION":
|
||||||
client.reply(rplVersion, VERSION)
|
client.reply(rplVersion, VERSION)
|
||||||
|
|
||||||
case "NICK":
|
case "NICK":
|
||||||
client.reply(rplKill, "Can't change nicks on this server", "")
|
client.reply(rplKill, "Can't change nicks on this server", "")
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
@ -338,42 +341,8 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 2 {
|
client.reply(errNoPriv)
|
||||||
client.reply(errMoreArgs)
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
channelKey := strings.ToLower(args[0])
|
|
||||||
targetKey := strings.ToLower(args[1])
|
|
||||||
|
|
||||||
channel, channelExists := s.channelMap[channelKey]
|
|
||||||
if !channelExists {
|
|
||||||
client.reply(errNoSuchNick, args[0])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
target, targetExists := channel.clientMap[targetKey]
|
|
||||||
if !targetExists {
|
|
||||||
client.reply(errNoSuchNick, args[1])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
clientMode := channel.modeMap[client.key]
|
|
||||||
if !clientMode.operator && !client.operator {
|
|
||||||
client.reply(errNoPriv)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
reason := strings.Join(args[2:], " ")
|
|
||||||
|
|
||||||
//It worked
|
|
||||||
for _, client := range channel.clientMap {
|
|
||||||
client.reply(rplKick, client.nick, channel.name, target.nick, reason)
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(channel.clientMap, targetKey)
|
|
||||||
delete(channel.modeMap, targetKey)
|
|
||||||
delete(target.channelMap, channelKey)
|
|
||||||
|
|
||||||
case "MODE":
|
case "MODE":
|
||||||
if client.registered == false {
|
if client.registered == false {
|
||||||
@ -401,86 +370,9 @@ func (s *Server) handleCommand(client *Client, command string, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if cm, ok := channel.modeMap[client.key]; !ok || !cm.operator {
|
// Setting modes is disallowed
|
||||||
//Not a channel operator.
|
client.reply(errNoPriv)
|
||||||
|
return
|
||||||
//If they're not an irc operator either, they'll fail
|
|
||||||
if !client.operator {
|
|
||||||
client.reply(errNoPriv)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hasClient := false
|
|
||||||
var oldClientMode, newClientMode *ClientMode
|
|
||||||
var targetClient *Client
|
|
||||||
if len(args) >= 3 {
|
|
||||||
clientKey := strings.ToLower(args[2])
|
|
||||||
oldClientMode, hasClient = channel.modeMap[clientKey]
|
|
||||||
if hasClient {
|
|
||||||
targetClient = channel.clientMap[clientKey]
|
|
||||||
newClientMode = new(ClientMode)
|
|
||||||
*newClientMode = *oldClientMode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod := strings.ToLower(args[1])
|
|
||||||
if strings.HasPrefix(mod, "+") {
|
|
||||||
for _, char := range mod {
|
|
||||||
switch char {
|
|
||||||
case 's':
|
|
||||||
mode.secret = true
|
|
||||||
case 't':
|
|
||||||
mode.topicLocked = true
|
|
||||||
case 'm':
|
|
||||||
mode.moderated = true
|
|
||||||
case 'n':
|
|
||||||
mode.noExternal = true
|
|
||||||
case 'o':
|
|
||||||
if hasClient {
|
|
||||||
newClientMode.operator = true
|
|
||||||
}
|
|
||||||
case 'v':
|
|
||||||
if hasClient {
|
|
||||||
newClientMode.voice = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if strings.HasPrefix(mod, "-") {
|
|
||||||
for _, char := range mod {
|
|
||||||
switch char {
|
|
||||||
case 's':
|
|
||||||
mode.secret = false
|
|
||||||
case 't':
|
|
||||||
mode.topicLocked = false
|
|
||||||
case 'm':
|
|
||||||
mode.moderated = false
|
|
||||||
case 'n':
|
|
||||||
mode.noExternal = false
|
|
||||||
case 'o':
|
|
||||||
if hasClient {
|
|
||||||
newClientMode.operator = false
|
|
||||||
}
|
|
||||||
case 'v':
|
|
||||||
if hasClient {
|
|
||||||
newClientMode.voice = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if hasClient {
|
|
||||||
*oldClientMode = *newClientMode
|
|
||||||
}
|
|
||||||
channel.mode = mode
|
|
||||||
|
|
||||||
for _, client := range channel.clientMap {
|
|
||||||
if hasClient {
|
|
||||||
client.reply(rplChannelModeIs, channel.name, args[1], targetClient.nick)
|
|
||||||
} else {
|
|
||||||
client.reply(rplChannelModeIs, channel.name, args[1], "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
client.reply(errUnknownCommand, command)
|
client.reply(errUnknownCommand, command)
|
||||||
|
Loading…
Reference in New Issue
Block a user