Skip to content

Commit

Permalink
Add support for build tags (#1054)
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. "nodiscord" as a build tag.

    go build -tags nomsteams,noapi
  • Loading branch information
qaisjp authored Mar 22, 2020
1 parent 0e4973e commit 2b7eab6
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 !noapi

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 !nodiscord

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 !nogitter

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 !noirc

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 !nokeybase

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 !nomatrix

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 !nomattermost

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 !nomsteams

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 !norocketchat

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 !noslack

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 !nosshchat

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 !nosteam

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 !notelegram

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 !nowhatsapp

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 !noxmpp

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 !nozulip

package bridgemap

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

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

0 comments on commit 2b7eab6

Please sign in to comment.