Browse Source

opers: Allow setting custom whois lines

tags/v0.4.0
Daniel Oaks 7 years ago
parent
commit
f3459830e7
4 changed files with 32 additions and 7 deletions
  1. 1
    0
      irc/client.go
  2. 25
    5
      irc/config.go
  3. 3
    2
      irc/server.go
  4. 3
    0
      oragono.yaml

+ 1
- 0
irc/client.go View File

61
 	server             *Server
61
 	server             *Server
62
 	socket             *Socket
62
 	socket             *Socket
63
 	username           string
63
 	username           string
64
+	whoisLine          string
64
 }
65
 }
65
 
66
 
66
 // NewClient returns a client with all the appropriate info setup.
67
 // NewClient returns a client with all the appropriate info setup.

+ 25
- 5
irc/config.go View File

11
 	"fmt"
11
 	"fmt"
12
 	"io/ioutil"
12
 	"io/ioutil"
13
 	"log"
13
 	"log"
14
+	"strings"
14
 
15
 
15
 	"gopkg.in/yaml.v2"
16
 	"gopkg.in/yaml.v2"
16
 )
17
 )
68
 
69
 
69
 type OperClassConfig struct {
70
 type OperClassConfig struct {
70
 	Title        string
71
 	Title        string
72
+	WhoisLine    string
71
 	Extends      string
73
 	Extends      string
72
 	Capabilities []string
74
 	Capabilities []string
73
 }
75
 }
74
 
76
 
75
 type OperConfig struct {
77
 type OperConfig struct {
76
-	Class    string
77
-	Vhost    string
78
-	Password string
78
+	Class     string
79
+	Vhost     string
80
+	WhoisLine string `yaml:"whois-line"`
81
+	Password  string
79
 }
82
 }
80
 
83
 
81
 func (conf *OperConfig) PasswordBytes() []byte {
84
 func (conf *OperConfig) PasswordBytes() []byte {
130
 
133
 
131
 type OperClass struct {
134
 type OperClass struct {
132
 	Title        string
135
 	Title        string
136
+	WhoisLine    string          `yaml:"whois-line"`
133
 	Capabilities map[string]bool // map to make lookups much easier
137
 	Capabilities map[string]bool // map to make lookups much easier
134
 }
138
 }
135
 
139
 
179
 			for _, capab := range info.Capabilities {
183
 			for _, capab := range info.Capabilities {
180
 				oc.Capabilities[capab] = true
184
 				oc.Capabilities[capab] = true
181
 			}
185
 			}
186
+			if len(info.WhoisLine) > 0 {
187
+				oc.WhoisLine = info.WhoisLine
188
+			} else {
189
+				oc.WhoisLine = "is a"
190
+				if strings.Contains(strings.ToLower(string(oc.Title[0])), "aeiou") {
191
+					oc.WhoisLine += "n"
192
+				}
193
+				oc.WhoisLine += " "
194
+				oc.WhoisLine += oc.Title
195
+			}
182
 
196
 
183
 			ocs[name] = oc
197
 			ocs[name] = oc
184
 		}
198
 		}
193
 }
207
 }
194
 
208
 
195
 type Oper struct {
209
 type Oper struct {
196
-	Class *OperClass
197
-	Pass  []byte
210
+	Class     *OperClass
211
+	WhoisLine string
212
+	Pass      []byte
198
 }
213
 }
199
 
214
 
200
 func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error) {
215
 func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error) {
214
 			return nil, fmt.Errorf("Could not load operator [%s] - they use operclass [%s] which does not exist", name, opConf.Class)
229
 			return nil, fmt.Errorf("Could not load operator [%s] - they use operclass [%s] which does not exist", name, opConf.Class)
215
 		}
230
 		}
216
 		oper.Class = &class
231
 		oper.Class = &class
232
+		if len(opConf.WhoisLine) > 0 {
233
+			oper.WhoisLine = opConf.WhoisLine
234
+		} else {
235
+			oper.WhoisLine = class.WhoisLine
236
+		}
217
 
237
 
218
 		// successful, attach to list of opers
238
 		// successful, attach to list of opers
219
 		operators[name] = oper
239
 		operators[name] = oper

+ 3
- 2
irc/server.go View File

799
 	for _, line := range client.WhoisChannelsNames(target) {
799
 	for _, line := range client.WhoisChannelsNames(target) {
800
 		client.Send(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, line)
800
 		client.Send(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, line)
801
 	}
801
 	}
802
-	if target.flags[Operator] {
803
-		client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, "is an IRC operator")
802
+	if target.class != nil {
803
+		client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine)
804
 	}
804
 	}
805
 	if target.certfp != "" && (client.flags[Operator] || client == target) {
805
 	if target.certfp != "" && (client.flags[Operator] || client == target) {
806
 		client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf("has client certificate fingerprint %s", target.certfp))
806
 		client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf("has client certificate fingerprint %s", target.certfp))
902
 	client.operName = name
902
 	client.operName = name
903
 	client.class = server.operators[name].Class
903
 	client.class = server.operators[name].Class
904
 	server.currentOpers[client] = true
904
 	server.currentOpers[client] = true
905
+	client.whoisLine = server.operators[name].WhoisLine
905
 
906
 
906
 	//TODO(dan): push out CHGHOST if vhost is applied
907
 	//TODO(dan): push out CHGHOST if vhost is applied
907
 
908
 

+ 3
- 0
oragono.yaml View File

106
         # which capabilities this oper has access to
106
         # which capabilities this oper has access to
107
         class: "server-admin"
107
         class: "server-admin"
108
 
108
 
109
+        # custom whois line
110
+        whois-line: is a cool dude
111
+
109
         # custom hostname
112
         # custom hostname
110
         vhost: "n"
113
         vhost: "n"
111
 
114
 

Loading…
Cancel
Save