mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
refactor DEOP
DEOP is now pure syntactic sugar for /mode #channel -o nick, the change is attributed to the originating user and not to ChanServ.
This commit is contained in:
parent
f010914965
commit
610fc5068d
@ -42,10 +42,9 @@ this command if you're the founder of the channel.`,
|
|||||||
|
|
||||||
DEOP removes the given nickname, or yourself, the channel admin. You can only use
|
DEOP removes the given nickname, or yourself, the channel admin. You can only use
|
||||||
this command if you're the founder of the channel.`,
|
this command if you're the founder of the channel.`,
|
||||||
helpShort: `$bDEOP$b removes the given user (or yourself) from a channel admin.`,
|
helpShort: `$bDEOP$b removes the given user (or yourself) from a channel admin.`,
|
||||||
authRequired: true,
|
enabled: chanregEnabled,
|
||||||
enabled: chanregEnabled,
|
minParams: 1,
|
||||||
minParams: 1,
|
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
handler: csRegisterHandler,
|
handler: csRegisterHandler,
|
||||||
@ -194,7 +193,6 @@ func csNotice(rb *ResponseBuffer, text string) {
|
|||||||
rb.Add(nil, chanservMask, "NOTICE", rb.target.Nick(), text)
|
rb.Add(nil, chanservMask, "NOTICE", rb.target.Nick(), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func csAmodeHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func csAmodeHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
channelName := params[0]
|
channelName := params[0]
|
||||||
|
|
||||||
@ -325,16 +323,13 @@ func csOpHandler(server *Server, client *Client, command string, params []string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func csDeopHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func csDeopHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
channelInfo := server.channels.Get(params[0])
|
channel := server.channels.Get(params[0])
|
||||||
if channelInfo == nil {
|
if channel == nil {
|
||||||
csNotice(rb, client.t("Channel does not exist"))
|
csNotice(rb, client.t("Channel does not exist"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
channelName := channelInfo.Name()
|
if !channel.hasClient(client) {
|
||||||
|
csNotice(rb, client.t("You're not on that channel"))
|
||||||
clientAccount := client.Account()
|
|
||||||
if clientAccount == "" || clientAccount != channelInfo.Founder() {
|
|
||||||
csNotice(rb, client.t("Only the channel founder can do this"))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,29 +344,35 @@ func csDeopHandler(server *Server, client *Client, command string, params []stri
|
|||||||
target = client
|
target = client
|
||||||
}
|
}
|
||||||
|
|
||||||
// give them privs
|
present, cumodes := channel.ClientStatus(target)
|
||||||
givenMode := modes.ChannelOperator
|
if !present || len(cumodes) == 0 {
|
||||||
if clientAccount == target.Account() {
|
csNotice(rb, client.t("Target has no privileges to remove"))
|
||||||
givenMode = modes.ChannelFounder
|
return
|
||||||
}
|
}
|
||||||
applied, change := channelInfo.applyModeToMember(client,
|
|
||||||
modes.ModeChange{Mode: givenMode,
|
tnick := target.Nick()
|
||||||
Op: modes.Remove,
|
modeChanges := make(modes.ModeChanges, len(cumodes))
|
||||||
Arg: target.NickCasefolded(),
|
for i, mode := range cumodes {
|
||||||
},
|
modeChanges[i] = modes.ModeChange{
|
||||||
rb)
|
Mode: mode,
|
||||||
if applied {
|
Op: modes.Remove,
|
||||||
announceCmodeChanges(channelInfo, modes.ModeChanges{change}, chanservMask, "*", "", rb)
|
Arg: tnick,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the user's own permissions for the check, then announce
|
||||||
|
// the changes as coming from chanserv
|
||||||
|
applied := channel.ApplyChannelModeChanges(client, false, modeChanges, rb)
|
||||||
|
details := client.Details()
|
||||||
|
announceCmodeChanges(channel, applied, details.nickMask, details.accountName, details.account, rb)
|
||||||
|
|
||||||
|
if len(applied) == 0 {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
csNotice(rb, client.t("Successfully removed operator privileges"))
|
csNotice(rb, client.t("Successfully removed operator privileges"))
|
||||||
|
|
||||||
tnick := target.Nick()
|
|
||||||
server.logger.Info("services", fmt.Sprintf("Client %s deop'd [%s] in channel %s", client.Nick(), tnick, channelName))
|
|
||||||
server.snomasks.Send(sno.LocalChannels, fmt.Sprintf(ircfmt.Unescape("Client $c[grey][$r%s$c[grey]] CS deOP'd $c[grey][$r%s$c[grey]] in channel $c[grey][$r%s$c[grey]]"), client.NickMaskString(), tnick, channelName))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func csRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func csRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
if server.Config().Channels.Registration.OperatorOnly && !client.HasRoleCapabs("chanreg") {
|
if server.Config().Channels.Registration.OperatorOnly && !client.HasRoleCapabs("chanreg") {
|
||||||
csNotice(rb, client.t("Channel registration is restricted to server operators"))
|
csNotice(rb, client.t("Channel registration is restricted to server operators"))
|
||||||
|
Loading…
Reference in New Issue
Block a user