Skip to content

Commit

Permalink
Add support for build tags
Browse files Browse the repository at this point in the history
By default all bridges are available.

You can turn off certain bridges by providing
e.g. "withoutdiscord" as a build tag.

    go build -tags withoutmsteams,withoutapi
  • Loading branch information
qaisjp committed Mar 22, 2020
1 parent 76e5fe5 commit 6dcec8d
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 40 deletions.
11 changes: 11 additions & 0 deletions gateway/bridgemap/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutapi

package bridgemap

import (
"github.com/42wim/matterbridge/bridge/api"
)

func init() {
FullMap["api"] = api.New
}
12 changes: 12 additions & 0 deletions gateway/bridgemap/bdiscord.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build !withoutdiscord

package bridgemap

import (
bdiscord "github.com/42wim/matterbridge/bridge/discord"
)

func init() {
FullMap["discord"] = bdiscord.New
UserTypingSupport["discord"] = struct{}{}
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bgitter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutgitter

package bridgemap

import (
bgitter "github.com/42wim/matterbridge/bridge/gitter"
)

func init() {
FullMap["gitter"] = bgitter.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/birc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutirc

package bridgemap

import (
birc "github.com/42wim/matterbridge/bridge/irc"
)

func init() {
FullMap["irc"] = birc.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bkeybase.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutkeybase

package bridgemap

import (
bkeybase "github.com/42wim/matterbridge/bridge/keybase"
)

func init() {
FullMap["keybase"] = bkeybase.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bmatrix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutmatrix

package bridgemap

import (
bmatrix "github.com/42wim/matterbridge/bridge/matrix"
)

func init() {
FullMap["matrix"] = bmatrix.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bmattermost.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutmattermost

package bridgemap

import (
bmattermost "github.com/42wim/matterbridge/bridge/mattermost"
)

func init() {
FullMap["mattermost"] = bmattermost.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bmsteams.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutmsteams

package bridgemap

import (
bmsteams "github.com/42wim/matterbridge/bridge/msteams"
)

func init() {
FullMap["msteams"] = bmsteams.New
}
42 changes: 2 additions & 40 deletions gateway/bridgemap/bridgemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,9 @@ package bridgemap

import (
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/api"
bdiscord "github.com/42wim/matterbridge/bridge/discord"
bgitter "github.com/42wim/matterbridge/bridge/gitter"
birc "github.com/42wim/matterbridge/bridge/irc"
bkeybase "github.com/42wim/matterbridge/bridge/keybase"
bmatrix "github.com/42wim/matterbridge/bridge/matrix"
bmattermost "github.com/42wim/matterbridge/bridge/mattermost"
bmsteams "github.com/42wim/matterbridge/bridge/msteams"
brocketchat "github.com/42wim/matterbridge/bridge/rocketchat"
bslack "github.com/42wim/matterbridge/bridge/slack"
bsshchat "github.com/42wim/matterbridge/bridge/sshchat"
bsteam "github.com/42wim/matterbridge/bridge/steam"
btelegram "github.com/42wim/matterbridge/bridge/telegram"
bwhatsapp "github.com/42wim/matterbridge/bridge/whatsapp"
bxmpp "github.com/42wim/matterbridge/bridge/xmpp"
bzulip "github.com/42wim/matterbridge/bridge/zulip"
)

var (
FullMap = map[string]bridge.Factory{
"api": api.New,
"discord": bdiscord.New,
"gitter": bgitter.New,
"irc": birc.New,
"mattermost": bmattermost.New,
"matrix": bmatrix.New,
"rocketchat": brocketchat.New,
"slack-legacy": bslack.NewLegacy,
"slack": bslack.New,
"sshchat": bsshchat.New,
"steam": bsteam.New,
"telegram": btelegram.New,
"whatsapp": bwhatsapp.New,
"xmpp": bxmpp.New,
"zulip": bzulip.New,
"keybase": bkeybase.New,
"msteams": bmsteams.New,
}

UserTypingSupport = map[string]struct{}{
"slack": {},
"discord": {},
}
FullMap = map[string]bridge.Factory{}
UserTypingSupport = map[string]struct{}{}
)
11 changes: 11 additions & 0 deletions gateway/bridgemap/brocketchat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutrocketchat

package bridgemap

import (
brocketchat "github.com/42wim/matterbridge/bridge/rocketchat"
)

func init() {
FullMap["rocketchat"] = brocketchat.New
}
13 changes: 13 additions & 0 deletions gateway/bridgemap/bslack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// +build !withoutslack

package bridgemap

import (
bslack "github.com/42wim/matterbridge/bridge/slack"
)

func init() {
FullMap["slack-legacy"] = bslack.NewLegacy
FullMap["slack"] = bslack.New
UserTypingSupport["slack"] = struct{}{}
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bsshchat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutsshchat

package bridgemap

import (
bsshchat "github.com/42wim/matterbridge/bridge/sshchat"
)

func init() {
FullMap["sshchat"] = bsshchat.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bsteam.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutsteam

package bridgemap

import (
bsteam "github.com/42wim/matterbridge/bridge/steam"
)

func init() {
FullMap["steam"] = bsteam.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/btelegram.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withouttelegram

package bridgemap

import (
btelegram "github.com/42wim/matterbridge/bridge/telegram"
)

func init() {
FullMap["telegram"] = btelegram.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bwhatsapp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutwhatsapp

package bridgemap

import (
bwhatsapp "github.com/42wim/matterbridge/bridge/whatsapp"
)

func init() {
FullMap["whatsapp"] = bwhatsapp.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bxmpp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutxmpp

package bridgemap

import (
bxmpp "github.com/42wim/matterbridge/bridge/xmpp"
)

func init() {
FullMap["xmpp"] = bxmpp.New
}
11 changes: 11 additions & 0 deletions gateway/bridgemap/bzulip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !withoutzulip

package bridgemap

import (
bzulip "github.com/42wim/matterbridge/bridge/zulip"
)

func init() {
FullMap["zulip"] = bzulip.New
}

0 comments on commit 6dcec8d

Please sign in to comment.