mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-25 22:31:35 +00:00
Add Enable per section (protocol) instead of in general section
This commit is contained in:
parent
131826e1d1
commit
9cb3413d9c
@ -14,47 +14,33 @@ type Bridge struct {
|
|||||||
*config.Config
|
*config.Config
|
||||||
Source string
|
Source string
|
||||||
Bridges []Bridger
|
Bridges []Bridger
|
||||||
kind string
|
|
||||||
Channels []map[string]string
|
Channels []map[string]string
|
||||||
ignoreNicks map[string][]string
|
ignoreNicks map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type FancyLog struct {
|
|
||||||
irc *log.Entry
|
|
||||||
mm *log.Entry
|
|
||||||
xmpp *log.Entry
|
|
||||||
}
|
|
||||||
|
|
||||||
type Bridger interface {
|
type Bridger interface {
|
||||||
Send(msg config.Message) error
|
Send(msg config.Message) error
|
||||||
Name() string
|
Name() string
|
||||||
|
Connect() error
|
||||||
//Command(cmd string) string
|
//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 {
|
func NewBridge(cfg *config.Config) error {
|
||||||
c := make(chan config.Message)
|
c := make(chan config.Message)
|
||||||
initFLog()
|
|
||||||
b := &Bridge{}
|
b := &Bridge{}
|
||||||
b.Config = cfg
|
b.Config = cfg
|
||||||
if cfg.General.Irc {
|
if cfg.IRC.Enable {
|
||||||
b.Bridges = append(b.Bridges, birc.New(cfg, c))
|
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))
|
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))
|
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.mapChannels()
|
||||||
b.mapIgnores()
|
b.mapIgnores()
|
||||||
b.handleReceive(c)
|
b.handleReceive(c)
|
||||||
|
@ -26,6 +26,7 @@ type Config struct {
|
|||||||
NickServPassword string
|
NickServPassword string
|
||||||
RemoteNickFormat string
|
RemoteNickFormat string
|
||||||
IgnoreNicks string
|
IgnoreNicks string
|
||||||
|
Enable bool
|
||||||
}
|
}
|
||||||
Mattermost struct {
|
Mattermost struct {
|
||||||
URL string
|
URL string
|
||||||
@ -44,6 +45,7 @@ type Config struct {
|
|||||||
RemoteNickFormat string
|
RemoteNickFormat string
|
||||||
IgnoreNicks string
|
IgnoreNicks string
|
||||||
NoTLS bool
|
NoTLS bool
|
||||||
|
Enable bool
|
||||||
}
|
}
|
||||||
Xmpp struct {
|
Xmpp struct {
|
||||||
Jid string
|
Jid string
|
||||||
@ -52,6 +54,7 @@ type Config struct {
|
|||||||
Muc string
|
Muc string
|
||||||
Nick string
|
Nick string
|
||||||
RemoteNickFormat string
|
RemoteNickFormat string
|
||||||
|
Enable bool
|
||||||
}
|
}
|
||||||
Channel map[string]*struct {
|
Channel map[string]*struct {
|
||||||
IRC string
|
IRC string
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#IRC section
|
#IRC section
|
||||||
###################################################################
|
###################################################################
|
||||||
[IRC]
|
[IRC]
|
||||||
|
#Enable enables this bridge
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
Enable=true
|
||||||
#irc server to connect to.
|
#irc server to connect to.
|
||||||
#REQUIRED
|
#REQUIRED
|
||||||
Server="irc.freenode.net:6667"
|
Server="irc.freenode.net:6667"
|
||||||
@ -45,6 +48,10 @@ IgnoreNicks="ircspammer1 ircspammer2"
|
|||||||
#XMPP section
|
#XMPP section
|
||||||
###################################################################
|
###################################################################
|
||||||
[XMPP]
|
[XMPP]
|
||||||
|
#Enable enables this bridge
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
Enable=true
|
||||||
|
|
||||||
#xmpp server to connect to.
|
#xmpp server to connect to.
|
||||||
#REQUIRED
|
#REQUIRED
|
||||||
Server="jabber.example.com:5222"
|
Server="jabber.example.com:5222"
|
||||||
@ -71,6 +78,10 @@ Nick="xmppbot"
|
|||||||
###################################################################
|
###################################################################
|
||||||
|
|
||||||
[mattermost]
|
[mattermost]
|
||||||
|
#Enable enables this bridge
|
||||||
|
#OPTIONAL (default false)
|
||||||
|
Enable=true
|
||||||
|
|
||||||
#### Settings for webhook matterbridge.
|
#### Settings for webhook matterbridge.
|
||||||
#### These settings will not be used when using -plus switch which doesn't use
|
#### These settings will not be used when using -plus switch which doesn't use
|
||||||
#### webhooks.
|
#### webhooks.
|
||||||
@ -174,9 +185,3 @@ GiphyApiKey="dc6zaTOxFJmzC"
|
|||||||
|
|
||||||
#Enabling plus means you'll use the API version instead of the webhooks one
|
#Enabling plus means you'll use the API version instead of the webhooks one
|
||||||
Plus=false
|
Plus=false
|
||||||
|
|
||||||
#Choose protocols to bridge. You need to specify at least two
|
|
||||||
#REQUIRED
|
|
||||||
Irc=true
|
|
||||||
Xmpp=false
|
|
||||||
Mattermost=true
|
|
||||||
|
Loading…
Reference in New Issue
Block a user