You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.6 KiB
Go
82 lines
1.6 KiB
Go
8 years ago
|
package config
|
||
8 years ago
|
|
||
|
import (
|
||
|
"gopkg.in/gcfg.v1"
|
||
|
"io/ioutil"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
8 years ago
|
type Message struct {
|
||
|
Text string
|
||
|
Channel string
|
||
|
Username string
|
||
|
Origin string
|
||
|
}
|
||
|
|
||
8 years ago
|
type Config struct {
|
||
|
IRC struct {
|
||
8 years ago
|
UseTLS bool
|
||
8 years ago
|
UseSASL bool
|
||
8 years ago
|
SkipTLSVerify bool
|
||
|
Server string
|
||
|
Nick string
|
||
|
Password string
|
||
|
Channel string
|
||
|
NickServNick string
|
||
|
NickServPassword string
|
||
|
RemoteNickFormat string
|
||
|
IgnoreNicks string
|
||
8 years ago
|
}
|
||
|
Mattermost struct {
|
||
|
URL string
|
||
|
ShowJoinPart bool
|
||
|
IconURL string
|
||
|
SkipTLSVerify bool
|
||
|
BindAddress string
|
||
|
Channel string
|
||
|
PrefixMessagesWithNick bool
|
||
|
NicksPerRow int
|
||
|
NickFormatter string
|
||
|
Server string
|
||
|
Team string
|
||
|
Login string
|
||
|
Password string
|
||
8 years ago
|
RemoteNickFormat string
|
||
8 years ago
|
IgnoreNicks string
|
||
|
NoTLS bool
|
||
|
}
|
||
8 years ago
|
Xmpp struct {
|
||
8 years ago
|
Jid string
|
||
|
Password string
|
||
|
Server string
|
||
|
Muc string
|
||
|
Nick string
|
||
|
RemoteNickFormat string
|
||
8 years ago
|
}
|
||
8 years ago
|
Channel map[string]*struct {
|
||
|
IRC string
|
||
|
Mattermost string
|
||
8 years ago
|
Xmpp string
|
||
8 years ago
|
}
|
||
|
General struct {
|
||
|
GiphyAPIKey string
|
||
8 years ago
|
Xmpp bool
|
||
|
Irc bool
|
||
8 years ago
|
Mattermost bool
|
||
|
Plus bool
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
|
func NewConfig(cfgfile string) *Config {
|
||
|
var cfg Config
|
||
|
content, err := ioutil.ReadFile(cfgfile)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
err = gcfg.ReadStringInto(&cfg, string(content))
|
||
|
if err != nil {
|
||
|
log.Fatal("Failed to parse "+cfgfile+":", err)
|
||
|
}
|
||
|
return &cfg
|
||
|
}
|