mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-22 12:50:27 +00:00
92d9db5a2d
Expects uppercase environment variables of MATTERBRIDGE_PROTOCOL_ACCOUNT_KEY="value" e.g. you can override this config [mattermost] [mattermost.work] Team="yourteam" Login="yourlogin" Password="yourpass" by using MATTERBRIDGE_MATTERMOST_WORK_TEAM="newteam" MATTERBRIDGE_MATTERMOST_WORK_LOGIN="newlogin" MATTERBRIDGE_MATTERMOST_WORK_PASSWORD="newpassword"
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package bridge
|
|
|
|
import (
|
|
"github.com/42wim/matterbridge/bridge/config"
|
|
"github.com/42wim/matterbridge/bridge/discord"
|
|
"github.com/42wim/matterbridge/bridge/gitter"
|
|
"github.com/42wim/matterbridge/bridge/irc"
|
|
"github.com/42wim/matterbridge/bridge/mattermost"
|
|
"github.com/42wim/matterbridge/bridge/slack"
|
|
"github.com/42wim/matterbridge/bridge/xmpp"
|
|
"strings"
|
|
)
|
|
|
|
type Bridge interface {
|
|
Send(msg config.Message) error
|
|
Name() string
|
|
Connect() error
|
|
FullOrigin() string
|
|
Origin() string
|
|
Protocol() string
|
|
JoinChannel(channel string) error
|
|
}
|
|
|
|
func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) Bridge {
|
|
accInfo := strings.Split(bridge.Account, ".")
|
|
protocol := accInfo[0]
|
|
name := accInfo[1]
|
|
// override config from environment
|
|
config.OverrideCfgFromEnv(cfg, protocol, name)
|
|
switch protocol {
|
|
case "mattermost":
|
|
return bmattermost.New(cfg.Mattermost[name], name, c)
|
|
case "irc":
|
|
return birc.New(cfg.IRC[name], name, c)
|
|
case "gitter":
|
|
return bgitter.New(cfg.Gitter[name], name, c)
|
|
case "slack":
|
|
return bslack.New(cfg.Slack[name], name, c)
|
|
case "xmpp":
|
|
return bxmpp.New(cfg.Xmpp[name], name, c)
|
|
case "discord":
|
|
return bdiscord.New(cfg.Discord[name], name, c)
|
|
}
|
|
return nil
|
|
}
|