|
@@ -42,10 +42,9 @@ this command if you're the founder of the channel.`,
|
42
|
42
|
|
43
|
43
|
DEOP removes the given nickname, or yourself, the channel admin. You can only use
|
44
|
44
|
this command if you're the founder of the channel.`,
|
45
|
|
- helpShort: `$bDEOP$b removes the given user (or yourself) from a channel admin.`,
|
46
|
|
- authRequired: true,
|
47
|
|
- enabled: chanregEnabled,
|
48
|
|
- minParams: 1,
|
|
45
|
+ helpShort: `$bDEOP$b removes the given user (or yourself) from a channel admin.`,
|
|
46
|
+ enabled: chanregEnabled,
|
|
47
|
+ minParams: 1,
|
49
|
48
|
},
|
50
|
49
|
"register": {
|
51
|
50
|
handler: csRegisterHandler,
|
|
@@ -194,7 +193,6 @@ func csNotice(rb *ResponseBuffer, text string) {
|
194
|
193
|
rb.Add(nil, chanservMask, "NOTICE", rb.target.Nick(), text)
|
195
|
194
|
}
|
196
|
195
|
|
197
|
|
-
|
198
|
196
|
func csAmodeHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
199
|
197
|
channelName := params[0]
|
200
|
198
|
|
|
@@ -325,16 +323,13 @@ func csOpHandler(server *Server, client *Client, command string, params []string
|
325
|
323
|
}
|
326
|
324
|
|
327
|
325
|
func csDeopHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
328
|
|
- channelInfo := server.channels.Get(params[0])
|
329
|
|
- if channelInfo == nil {
|
|
326
|
+ channel := server.channels.Get(params[0])
|
|
327
|
+ if channel == nil {
|
330
|
328
|
csNotice(rb, client.t("Channel does not exist"))
|
331
|
329
|
return
|
332
|
330
|
}
|
333
|
|
- channelName := channelInfo.Name()
|
334
|
|
-
|
335
|
|
- clientAccount := client.Account()
|
336
|
|
- if clientAccount == "" || clientAccount != channelInfo.Founder() {
|
337
|
|
- csNotice(rb, client.t("Only the channel founder can do this"))
|
|
331
|
+ if !channel.hasClient(client) {
|
|
332
|
+ csNotice(rb, client.t("You're not on that channel"))
|
338
|
333
|
return
|
339
|
334
|
}
|
340
|
335
|
|
|
@@ -349,29 +344,35 @@ func csDeopHandler(server *Server, client *Client, command string, params []stri
|
349
|
344
|
target = client
|
350
|
345
|
}
|
351
|
346
|
|
352
|
|
- // give them privs
|
353
|
|
- givenMode := modes.ChannelOperator
|
354
|
|
- if clientAccount == target.Account() {
|
355
|
|
- givenMode = modes.ChannelFounder
|
|
347
|
+ present, cumodes := channel.ClientStatus(target)
|
|
348
|
+ if !present || len(cumodes) == 0 {
|
|
349
|
+ csNotice(rb, client.t("Target has no privileges to remove"))
|
|
350
|
+ return
|
356
|
351
|
}
|
357
|
|
- applied, change := channelInfo.applyModeToMember(client,
|
358
|
|
- modes.ModeChange{Mode: givenMode,
|
359
|
|
- Op: modes.Remove,
|
360
|
|
- Arg: target.NickCasefolded(),
|
361
|
|
- },
|
362
|
|
- rb)
|
363
|
|
- if applied {
|
364
|
|
- announceCmodeChanges(channelInfo, modes.ModeChanges{change}, chanservMask, "*", "", rb)
|
|
352
|
+
|
|
353
|
+ tnick := target.Nick()
|
|
354
|
+ modeChanges := make(modes.ModeChanges, len(cumodes))
|
|
355
|
+ for i, mode := range cumodes {
|
|
356
|
+ modeChanges[i] = modes.ModeChange{
|
|
357
|
+ Mode: mode,
|
|
358
|
+ Op: modes.Remove,
|
|
359
|
+ Arg: tnick,
|
|
360
|
+ }
|
|
361
|
+ }
|
|
362
|
+
|
|
363
|
+ // use the user's own permissions for the check, then announce
|
|
364
|
+ // the changes as coming from chanserv
|
|
365
|
+ applied := channel.ApplyChannelModeChanges(client, false, modeChanges, rb)
|
|
366
|
+ details := client.Details()
|
|
367
|
+ announceCmodeChanges(channel, applied, details.nickMask, details.accountName, details.account, rb)
|
|
368
|
+
|
|
369
|
+ if len(applied) == 0 {
|
|
370
|
+ return
|
365
|
371
|
}
|
366
|
372
|
|
367
|
373
|
csNotice(rb, client.t("Successfully removed operator privileges"))
|
368
|
|
-
|
369
|
|
- tnick := target.Nick()
|
370
|
|
- server.logger.Info("services", fmt.Sprintf("Client %s deop'd [%s] in channel %s", client.Nick(), tnick, channelName))
|
371
|
|
- 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))
|
372
|
374
|
}
|
373
|
375
|
|
374
|
|
-
|
375
|
376
|
func csRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
376
|
377
|
if server.Config().Channels.Registration.OperatorOnly && !client.HasRoleCapabs("chanreg") {
|
377
|
378
|
csNotice(rb, client.t("Channel registration is restricted to server operators"))
|