mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-06-26 07:29:24 +00:00
Add Enable per section (protocol) instead of in general section
This commit is contained in:
@ -14,47 +14,33 @@ type Bridge struct {
|
||||
*config.Config
|
||||
Source string
|
||||
Bridges []Bridger
|
||||
kind string
|
||||
Channels []map[string]string
|
||||
ignoreNicks map[string][]string
|
||||
}
|
||||
|
||||
type FancyLog struct {
|
||||
irc *log.Entry
|
||||
mm *log.Entry
|
||||
xmpp *log.Entry
|
||||
}
|
||||
|
||||
type Bridger interface {
|
||||
Send(msg config.Message) error
|
||||
Name() string
|
||||
Connect() error
|
||||
//Command(cmd string) string
|
||||
}
|
||||
|
||||
var flog FancyLog
|
||||
|
||||
const Legacy = "legacy"
|
||||
|
||||
func initFLog() {
|
||||
flog.irc = log.WithFields(log.Fields{"module": "irc"})
|
||||
flog.mm = log.WithFields(log.Fields{"module": "mattermost"})
|
||||
flog.xmpp = log.WithFields(log.Fields{"module": "xmpp"})
|
||||
}
|
||||
|
||||
func NewBridge(cfg *config.Config) error {
|
||||
c := make(chan config.Message)
|
||||
initFLog()
|
||||
b := &Bridge{}
|
||||
b.Config = cfg
|
||||
if cfg.General.Irc {
|
||||
if cfg.IRC.Enable {
|
||||
b.Bridges = append(b.Bridges, birc.New(cfg, c))
|
||||
}
|
||||
if cfg.General.Mattermost {
|
||||
if cfg.Mattermost.Enable {
|
||||
b.Bridges = append(b.Bridges, bmattermost.New(cfg, c))
|
||||
}
|
||||
if cfg.General.Xmpp {
|
||||
if cfg.Xmpp.Enable {
|
||||
b.Bridges = append(b.Bridges, bxmpp.New(cfg, c))
|
||||
}
|
||||
if len(b.Bridges) < 2 {
|
||||
log.Fatalf("only %d sections enabled. Need at least 2 sections enabled (eg [IRC] and [mattermost]", len(b.Bridges))
|
||||
}
|
||||
b.mapChannels()
|
||||
b.mapIgnores()
|
||||
b.handleReceive(c)
|
||||
|
@ -26,6 +26,7 @@ type Config struct {
|
||||
NickServPassword string
|
||||
RemoteNickFormat string
|
||||
IgnoreNicks string
|
||||
Enable bool
|
||||
}
|
||||
Mattermost struct {
|
||||
URL string
|
||||
@ -44,6 +45,7 @@ type Config struct {
|
||||
RemoteNickFormat string
|
||||
IgnoreNicks string
|
||||
NoTLS bool
|
||||
Enable bool
|
||||
}
|
||||
Xmpp struct {
|
||||
Jid string
|
||||
@ -52,6 +54,7 @@ type Config struct {
|
||||
Muc string
|
||||
Nick string
|
||||
RemoteNickFormat string
|
||||
Enable bool
|
||||
}
|
||||
Channel map[string]*struct {
|
||||
IRC string
|
||||
|
Reference in New Issue
Block a user