mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 05:19:25 +01:00
opers: Allow setting custom whois lines
This commit is contained in:
parent
64bdedaee2
commit
f3459830e7
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user