diff --git a/irc/client.go b/irc/client.go index 937cf1a7..9502bf9b 100644 --- a/irc/client.go +++ b/irc/client.go @@ -61,6 +61,7 @@ type Client struct { server *Server socket *Socket username string + whoisLine string } // NewClient returns a client with all the appropriate info setup. diff --git a/irc/config.go b/irc/config.go index 60da5532..30e9503d 100644 --- a/irc/config.go +++ b/irc/config.go @@ -11,6 +11,7 @@ import ( "fmt" "io/ioutil" "log" + "strings" "gopkg.in/yaml.v2" ) @@ -68,14 +69,16 @@ type AccountRegistrationConfig struct { type OperClassConfig struct { Title string + WhoisLine string Extends string Capabilities []string } type OperConfig struct { - Class string - Vhost string - Password string + Class string + Vhost string + WhoisLine string `yaml:"whois-line"` + Password string } func (conf *OperConfig) PasswordBytes() []byte { @@ -130,6 +133,7 @@ type Config struct { type OperClass struct { Title string + WhoisLine string `yaml:"whois-line"` Capabilities map[string]bool // map to make lookups much easier } @@ -179,6 +183,16 @@ func (conf *Config) OperatorClasses() (*map[string]OperClass, error) { for _, capab := range info.Capabilities { oc.Capabilities[capab] = true } + if len(info.WhoisLine) > 0 { + oc.WhoisLine = info.WhoisLine + } else { + oc.WhoisLine = "is a" + if strings.Contains(strings.ToLower(string(oc.Title[0])), "aeiou") { + oc.WhoisLine += "n" + } + oc.WhoisLine += " " + oc.WhoisLine += oc.Title + } ocs[name] = oc } @@ -193,8 +207,9 @@ func (conf *Config) OperatorClasses() (*map[string]OperClass, error) { } type Oper struct { - Class *OperClass - Pass []byte + Class *OperClass + WhoisLine string + Pass []byte } func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error) { @@ -214,6 +229,11 @@ func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error) return nil, fmt.Errorf("Could not load operator [%s] - they use operclass [%s] which does not exist", name, opConf.Class) } oper.Class = &class + if len(opConf.WhoisLine) > 0 { + oper.WhoisLine = opConf.WhoisLine + } else { + oper.WhoisLine = class.WhoisLine + } // successful, attach to list of opers operators[name] = oper diff --git a/irc/server.go b/irc/server.go index 6c979a28..63c3bad7 100644 --- a/irc/server.go +++ b/irc/server.go @@ -799,8 +799,8 @@ func (client *Client) getWhoisOf(target *Client) { for _, line := range client.WhoisChannelsNames(target) { client.Send(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, line) } - if target.flags[Operator] { - client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, "is an IRC operator") + if target.class != nil { + client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine) } if target.certfp != "" && (client.flags[Operator] || client == target) { client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf("has client certificate fingerprint %s", target.certfp)) @@ -902,6 +902,7 @@ func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { client.operName = name client.class = server.operators[name].Class server.currentOpers[client] = true + client.whoisLine = server.operators[name].WhoisLine //TODO(dan): push out CHGHOST if vhost is applied diff --git a/oragono.yaml b/oragono.yaml index ee452687..953a0e80 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -106,6 +106,9 @@ opers: # which capabilities this oper has access to class: "server-admin" + # custom whois line + whois-line: is a cool dude + # custom hostname vhost: "n"