|
@@ -114,28 +114,19 @@ To cancel a pending transfer, transfer the channel to yourself.`,
|
114
|
114
|
},
|
115
|
115
|
"purge": {
|
116
|
116
|
handler: csPurgeHandler,
|
117
|
|
- help: `Syntax: $bPURGE #channel [reason]$b
|
|
117
|
+ help: `Syntax: $bPURGE <ADD | DEL | LIST> #channel [code] [reason]$b
|
118
|
118
|
|
119
|
|
-PURGE blacklists a channel from the server, making it impossible to join
|
|
119
|
+PURGE ADD blacklists a channel from the server, making it impossible to join
|
120
|
120
|
or otherwise interact with the channel. If the channel currently has members,
|
121
|
121
|
they will be kicked from it. PURGE may also be applied preemptively to
|
122
|
|
-channels that do not currently have members.`,
|
|
122
|
+channels that do not currently have members. A purge can be undone with
|
|
123
|
+PURGE DEL. To list purged channels, use PURGE LIST.`,
|
123
|
124
|
helpShort: `$bPURGE$b blacklists a channel from the server.`,
|
124
|
125
|
capabs: []string{"chanreg"},
|
125
|
126
|
minParams: 1,
|
126
|
|
- maxParams: 2,
|
|
127
|
+ maxParams: 3,
|
127
|
128
|
unsplitFinalParam: true,
|
128
|
129
|
},
|
129
|
|
- "unpurge": {
|
130
|
|
- handler: csUnpurgeHandler,
|
131
|
|
- help: `Syntax: $bUNPURGE #channel$b
|
132
|
|
-
|
133
|
|
-UNPURGE removes any blacklisting of a channel that was previously
|
134
|
|
-set using PURGE.`,
|
135
|
|
- helpShort: `$bUNPURGE$b undoes a previous PURGE command.`,
|
136
|
|
- capabs: []string{"chanreg"},
|
137
|
|
- minParams: 1,
|
138
|
|
- },
|
139
|
130
|
"list": {
|
140
|
131
|
handler: csListHandler,
|
141
|
132
|
help: `Syntax: $bLIST [regex]$b
|
|
@@ -587,19 +578,53 @@ func csPurgeHandler(service *ircService, server *Server, client *Client, command
|
587
|
578
|
return // should be impossible because you need oper capabs for this
|
588
|
579
|
}
|
589
|
580
|
|
|
581
|
+ switch strings.ToLower(params[0]) {
|
|
582
|
+ case "add":
|
|
583
|
+ csPurgeAddHandler(service, client, params[1:], oper.Name, rb)
|
|
584
|
+ case "del", "remove":
|
|
585
|
+ csPurgeDelHandler(service, client, params[1:], oper.Name, rb)
|
|
586
|
+ case "list":
|
|
587
|
+ csPurgeListHandler(service, client, rb)
|
|
588
|
+ default:
|
|
589
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
|
590
|
+ }
|
|
591
|
+}
|
|
592
|
+
|
|
593
|
+func csPurgeAddHandler(service *ircService, client *Client, params []string, operName string, rb *ResponseBuffer) {
|
|
594
|
+ if len(params) == 0 {
|
|
595
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
|
596
|
+ return
|
|
597
|
+ }
|
|
598
|
+
|
590
|
599
|
chname := params[0]
|
|
600
|
+ params = params[1:]
|
|
601
|
+ channel := client.server.channels.Get(chname) // possibly nil
|
|
602
|
+ var ctime time.Time
|
|
603
|
+ if channel != nil {
|
|
604
|
+ chname = channel.Name()
|
|
605
|
+ ctime = channel.Ctime()
|
|
606
|
+ }
|
|
607
|
+ code := utils.ConfirmationCode(chname, ctime)
|
|
608
|
+
|
|
609
|
+ if len(params) == 0 || params[0] != code {
|
|
610
|
+ service.Notice(rb, ircfmt.Unescape(client.t("$bWarning: you are about to empty this channel and remove it from the server.$b")))
|
|
611
|
+ service.Notice(rb, fmt.Sprintf(client.t("To confirm, run this command: %s"), fmt.Sprintf("/CS PURGE ADD %s %s", chname, code)))
|
|
612
|
+ return
|
|
613
|
+ }
|
|
614
|
+ params = params[1:]
|
|
615
|
+
|
591
|
616
|
var reason string
|
592
|
617
|
if 1 < len(params) {
|
593
|
618
|
reason = params[1]
|
594
|
619
|
}
|
|
620
|
+
|
595
|
621
|
purgeRecord := ChannelPurgeRecord{
|
596
|
|
- Oper: oper.Name,
|
|
622
|
+ Oper: operName,
|
597
|
623
|
PurgedAt: time.Now().UTC(),
|
598
|
624
|
Reason: reason,
|
599
|
625
|
}
|
600
|
|
- switch server.channels.Purge(chname, purgeRecord) {
|
|
626
|
+ switch client.server.channels.Purge(chname, purgeRecord) {
|
601
|
627
|
case nil:
|
602
|
|
- channel := server.channels.Get(chname)
|
603
|
628
|
if channel != nil { // channel need not exist to be purged
|
604
|
629
|
for _, target := range channel.Members() {
|
605
|
630
|
channel.Kick(client, target, "Cleared by ChanServ", rb, true)
|
|
@@ -613,9 +638,14 @@ func csPurgeHandler(service *ircService, server *Server, client *Client, command
|
613
|
638
|
}
|
614
|
639
|
}
|
615
|
640
|
|
616
|
|
-func csUnpurgeHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
641
|
+func csPurgeDelHandler(service *ircService, client *Client, params []string, operName string, rb *ResponseBuffer) {
|
|
642
|
+ if len(params) == 0 {
|
|
643
|
+ service.Notice(rb, client.t("Invalid parameters"))
|
|
644
|
+ return
|
|
645
|
+ }
|
|
646
|
+
|
617
|
647
|
chname := params[0]
|
618
|
|
- switch server.channels.Unpurge(chname) {
|
|
648
|
+ switch client.server.channels.Unpurge(chname) {
|
619
|
649
|
case nil:
|
620
|
650
|
service.Notice(rb, fmt.Sprintf(client.t("Successfully unpurged channel %s from the server"), chname))
|
621
|
651
|
case errNoSuchChannel:
|
|
@@ -625,6 +655,14 @@ func csUnpurgeHandler(service *ircService, server *Server, client *Client, comma
|
625
|
655
|
}
|
626
|
656
|
}
|
627
|
657
|
|
|
658
|
+func csPurgeListHandler(service *ircService, client *Client, rb *ResponseBuffer) {
|
|
659
|
+ l := client.server.channels.ListPurged()
|
|
660
|
+ service.Notice(rb, fmt.Sprintf(client.t("There are %d purged channel(s)."), len(l)))
|
|
661
|
+ for i, c := range l {
|
|
662
|
+ service.Notice(rb, fmt.Sprintf("%d: %s", i+1, c))
|
|
663
|
+ }
|
|
664
|
+}
|
|
665
|
+
|
628
|
666
|
func csListHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
629
|
667
|
if !client.HasRoleCapabs("chanreg") {
|
630
|
668
|
service.Notice(rb, client.t("Insufficient privileges"))
|