mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Add SAMODE command, restricted by oper capab
This commit is contained in:
parent
c8b5fb65e0
commit
9e65d9b87e
@ -187,6 +187,11 @@ var Commands = map[string]Command{
|
||||
minParams: 2,
|
||||
oper: true,
|
||||
},
|
||||
"SAMODE": {
|
||||
handler: modeHandler,
|
||||
minParams: 1,
|
||||
capabs: []string{"samode"},
|
||||
},
|
||||
"SCENE": {
|
||||
handler: sceneHandler,
|
||||
minParams: 2,
|
||||
|
@ -295,6 +295,14 @@ Sends the text to the given targets as a PRIVMSG.`,
|
||||
text: `SANICK <currentnick> <newnick>
|
||||
|
||||
Gives the given user a new nickname.`,
|
||||
},
|
||||
"samode": {
|
||||
oper: true,
|
||||
text: `SAMODE <target> [<modestring> [<mode arguments>...]]
|
||||
|
||||
Forcibly sets and removes modes from the given target -- only available to
|
||||
opers. For more specific information on mode characters, see the help for
|
||||
"cmode" and "umode".`,
|
||||
},
|
||||
"scene": {
|
||||
text: `SCENE <target> <text to be sent>
|
||||
|
10
irc/modes.go
10
irc/modes.go
@ -263,9 +263,7 @@ func umodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
//TODO(dan): restricting to Operator here should be done with SAMODE only
|
||||
// point SAMODE at this handler too, if they are operator and SAMODE was called then fine
|
||||
if client != target && !client.flags[Operator] {
|
||||
if client != target && msg.Command != "SAMODE" {
|
||||
if len(msg.Params) > 1 {
|
||||
client.Send(nil, server.name, ERR_USERSDONTMATCH, client.nick, "Can't change modes for other users")
|
||||
} else {
|
||||
@ -420,7 +418,7 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
for _, change := range changes {
|
||||
// chan priv modes are checked specially so ignore them
|
||||
// means regular users can't view ban/except lists... but I'm not worried about that
|
||||
if ChannelModePrefixes[change.mode] == "" && !clientIsOp {
|
||||
if msg.Command != "SAMODE" && ChannelModePrefixes[change.mode] == "" && !clientIsOp {
|
||||
if !alreadySentPrivError {
|
||||
alreadySentPrivError = true
|
||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.name, "You're not a channel operator")
|
||||
@ -512,6 +510,9 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
// make sure client has privs to edit the given prefix
|
||||
var hasPrivs bool
|
||||
|
||||
if msg.Command == "SAMODE" {
|
||||
hasPrivs = true
|
||||
} else {
|
||||
for _, mode := range ChannelPrivModes {
|
||||
if channel.members[client][mode] {
|
||||
hasPrivs = true
|
||||
@ -527,6 +528,7 @@ func cmodeHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
casefoldedName, err := CasefoldName(change.arg)
|
||||
if err != nil {
|
||||
|
@ -154,6 +154,7 @@ oper-classes:
|
||||
capabilities:
|
||||
- "oper:rehash"
|
||||
- "oper:die"
|
||||
- "samode"
|
||||
|
||||
# ircd operators
|
||||
opers:
|
||||
|
Loading…
Reference in New Issue
Block a user