|
@@ -5,6 +5,7 @@ package irc
|
5
|
5
|
|
6
|
6
|
import (
|
7
|
7
|
"fmt"
|
|
8
|
+ "regexp"
|
8
|
9
|
"strconv"
|
9
|
10
|
"strings"
|
10
|
11
|
"time"
|
|
@@ -97,6 +98,17 @@ certfp (your client certificate) if a password is not given.`,
|
97
|
98
|
enabled: servCmdRequiresAuthEnabled,
|
98
|
99
|
minParams: 1,
|
99
|
100
|
},
|
|
101
|
+ "list": {
|
|
102
|
+ handler: nsListHandler,
|
|
103
|
+ help: `Syntax: $bLIST [regex]$b
|
|
104
|
+
|
|
105
|
+LIST returns the list of registered nicknames, which match the given regex.
|
|
106
|
+If no regex is provided, all registered nicknames are returned.`,
|
|
107
|
+ helpShort: `$bLIST$b searches the list of registered nicknames.`,
|
|
108
|
+ enabled: servCmdRequiresAuthEnabled,
|
|
109
|
+ capabs: []string{"accreg"},
|
|
110
|
+ minParams: 0,
|
|
111
|
+ },
|
100
|
112
|
"info": {
|
101
|
113
|
handler: nsInfoHandler,
|
102
|
114
|
help: `Syntax: $bINFO [username]$b
|
|
@@ -681,6 +693,34 @@ func nsIdentifyHandler(server *Server, client *Client, command string, params []
|
681
|
693
|
}
|
682
|
694
|
}
|
683
|
695
|
|
|
696
|
+func nsListHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
|
697
|
+ if !client.HasRoleCapabs("accreg") {
|
|
698
|
+ nsNotice(rb, client.t("Insufficient privileges"))
|
|
699
|
+ return
|
|
700
|
+ }
|
|
701
|
+
|
|
702
|
+ var searchRegex *regexp.Regexp
|
|
703
|
+ if len(params) > 0 {
|
|
704
|
+ var err error
|
|
705
|
+ searchRegex, err = regexp.Compile(params[0])
|
|
706
|
+ if err != nil {
|
|
707
|
+ nsNotice(rb, client.t("Invalid regex"))
|
|
708
|
+ return
|
|
709
|
+ }
|
|
710
|
+ }
|
|
711
|
+
|
|
712
|
+ nsNotice(rb, ircfmt.Unescape(client.t("*** $bNickServ LIST$b ***")))
|
|
713
|
+
|
|
714
|
+ nicks := server.accounts.AllNicks()
|
|
715
|
+ for _, nick := range nicks {
|
|
716
|
+ if searchRegex == nil || searchRegex.MatchString(nick) {
|
|
717
|
+ nsNotice(rb, fmt.Sprintf(" %s", nick))
|
|
718
|
+ }
|
|
719
|
+ }
|
|
720
|
+
|
|
721
|
+ nsNotice(rb, ircfmt.Unescape(client.t("*** $bEnd of NickServ LIST$b ***")))
|
|
722
|
+}
|
|
723
|
+
|
684
|
724
|
func nsInfoHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
685
|
725
|
if !server.Config().Accounts.AuthenticationEnabled && !client.HasRoleCapabs("accreg") {
|
686
|
726
|
nsNotice(rb, client.t("This command has been disabled by the server administrators"))
|