From 2b7eab629d959b10388d21cf6242fdfbdbe0e197 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Sun, 22 Mar 2020 17:34:14 +0000 Subject: [PATCH] Add support for build tags (#1054) 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 --- gateway/bridgemap/api.go | 11 +++++++++ gateway/bridgemap/bdiscord.go | 12 +++++++++ gateway/bridgemap/bgitter.go | 11 +++++++++ gateway/bridgemap/birc.go | 11 +++++++++ gateway/bridgemap/bkeybase.go | 11 +++++++++ gateway/bridgemap/bmatrix.go | 11 +++++++++ gateway/bridgemap/bmattermost.go | 11 +++++++++ gateway/bridgemap/bmsteams.go | 11 +++++++++ gateway/bridgemap/bridgemap.go | 42 ++------------------------------ gateway/bridgemap/brocketchat.go | 11 +++++++++ gateway/bridgemap/bslack.go | 13 ++++++++++ gateway/bridgemap/bsshchat.go | 11 +++++++++ gateway/bridgemap/bsteam.go | 11 +++++++++ gateway/bridgemap/btelegram.go | 11 +++++++++ gateway/bridgemap/bwhatsapp.go | 11 +++++++++ gateway/bridgemap/bxmpp.go | 11 +++++++++ gateway/bridgemap/bzulip.go | 11 +++++++++ 17 files changed, 181 insertions(+), 40 deletions(-) create mode 100644 gateway/bridgemap/api.go create mode 100644 gateway/bridgemap/bdiscord.go create mode 100644 gateway/bridgemap/bgitter.go create mode 100644 gateway/bridgemap/birc.go create mode 100644 gateway/bridgemap/bkeybase.go create mode 100644 gateway/bridgemap/bmatrix.go create mode 100644 gateway/bridgemap/bmattermost.go create mode 100644 gateway/bridgemap/bmsteams.go create mode 100644 gateway/bridgemap/brocketchat.go create mode 100644 gateway/bridgemap/bslack.go create mode 100644 gateway/bridgemap/bsshchat.go create mode 100644 gateway/bridgemap/bsteam.go create mode 100644 gateway/bridgemap/btelegram.go create mode 100644 gateway/bridgemap/bwhatsapp.go create mode 100644 gateway/bridgemap/bxmpp.go create mode 100644 gateway/bridgemap/bzulip.go diff --git a/gateway/bridgemap/api.go b/gateway/bridgemap/api.go new file mode 100644 index 00000000..a8b6e61f --- /dev/null +++ b/gateway/bridgemap/api.go @@ -0,0 +1,11 @@ +// +build !noapi + +package bridgemap + +import ( + "github.com/42wim/matterbridge/bridge/api" +) + +func init() { + FullMap["api"] = api.New +} diff --git a/gateway/bridgemap/bdiscord.go b/gateway/bridgemap/bdiscord.go new file mode 100644 index 00000000..92b14ac1 --- /dev/null +++ b/gateway/bridgemap/bdiscord.go @@ -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{}{} +} diff --git a/gateway/bridgemap/bgitter.go b/gateway/bridgemap/bgitter.go new file mode 100644 index 00000000..64b3c259 --- /dev/null +++ b/gateway/bridgemap/bgitter.go @@ -0,0 +1,11 @@ +// +build !nogitter + +package bridgemap + +import ( + bgitter "github.com/42wim/matterbridge/bridge/gitter" +) + +func init() { + FullMap["gitter"] = bgitter.New +} diff --git a/gateway/bridgemap/birc.go b/gateway/bridgemap/birc.go new file mode 100644 index 00000000..9e2bc33e --- /dev/null +++ b/gateway/bridgemap/birc.go @@ -0,0 +1,11 @@ +// +build !noirc + +package bridgemap + +import ( + birc "github.com/42wim/matterbridge/bridge/irc" +) + +func init() { + FullMap["irc"] = birc.New +} diff --git a/gateway/bridgemap/bkeybase.go b/gateway/bridgemap/bkeybase.go new file mode 100644 index 00000000..5dcdcda7 --- /dev/null +++ b/gateway/bridgemap/bkeybase.go @@ -0,0 +1,11 @@ +// +build !nokeybase + +package bridgemap + +import ( + bkeybase "github.com/42wim/matterbridge/bridge/keybase" +) + +func init() { + FullMap["keybase"] = bkeybase.New +} diff --git a/gateway/bridgemap/bmatrix.go b/gateway/bridgemap/bmatrix.go new file mode 100644 index 00000000..e1d761eb --- /dev/null +++ b/gateway/bridgemap/bmatrix.go @@ -0,0 +1,11 @@ +// +build !nomatrix + +package bridgemap + +import ( + bmatrix "github.com/42wim/matterbridge/bridge/matrix" +) + +func init() { + FullMap["matrix"] = bmatrix.New +} diff --git a/gateway/bridgemap/bmattermost.go b/gateway/bridgemap/bmattermost.go new file mode 100644 index 00000000..3f0f0449 --- /dev/null +++ b/gateway/bridgemap/bmattermost.go @@ -0,0 +1,11 @@ +// +build !nomattermost + +package bridgemap + +import ( + bmattermost "github.com/42wim/matterbridge/bridge/mattermost" +) + +func init() { + FullMap["mattermost"] = bmattermost.New +} diff --git a/gateway/bridgemap/bmsteams.go b/gateway/bridgemap/bmsteams.go new file mode 100644 index 00000000..56da2119 --- /dev/null +++ b/gateway/bridgemap/bmsteams.go @@ -0,0 +1,11 @@ +// +build !nomsteams + +package bridgemap + +import ( + bmsteams "github.com/42wim/matterbridge/bridge/msteams" +) + +func init() { + FullMap["msteams"] = bmsteams.New +} diff --git a/gateway/bridgemap/bridgemap.go b/gateway/bridgemap/bridgemap.go index 88d777b6..88514695 100644 --- a/gateway/bridgemap/bridgemap.go +++ b/gateway/bridgemap/bridgemap.go @@ -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{}{} ) diff --git a/gateway/bridgemap/brocketchat.go b/gateway/bridgemap/brocketchat.go new file mode 100644 index 00000000..6af4e8d3 --- /dev/null +++ b/gateway/bridgemap/brocketchat.go @@ -0,0 +1,11 @@ +// +build !norocketchat + +package bridgemap + +import ( + brocketchat "github.com/42wim/matterbridge/bridge/rocketchat" +) + +func init() { + FullMap["rocketchat"] = brocketchat.New +} diff --git a/gateway/bridgemap/bslack.go b/gateway/bridgemap/bslack.go new file mode 100644 index 00000000..fdea80c8 --- /dev/null +++ b/gateway/bridgemap/bslack.go @@ -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{}{} +} diff --git a/gateway/bridgemap/bsshchat.go b/gateway/bridgemap/bsshchat.go new file mode 100644 index 00000000..14d42288 --- /dev/null +++ b/gateway/bridgemap/bsshchat.go @@ -0,0 +1,11 @@ +// +build !nosshchat + +package bridgemap + +import ( + bsshchat "github.com/42wim/matterbridge/bridge/sshchat" +) + +func init() { + FullMap["sshchat"] = bsshchat.New +} diff --git a/gateway/bridgemap/bsteam.go b/gateway/bridgemap/bsteam.go new file mode 100644 index 00000000..c2654737 --- /dev/null +++ b/gateway/bridgemap/bsteam.go @@ -0,0 +1,11 @@ +// +build !nosteam + +package bridgemap + +import ( + bsteam "github.com/42wim/matterbridge/bridge/steam" +) + +func init() { + FullMap["steam"] = bsteam.New +} diff --git a/gateway/bridgemap/btelegram.go b/gateway/bridgemap/btelegram.go new file mode 100644 index 00000000..ec0bbe60 --- /dev/null +++ b/gateway/bridgemap/btelegram.go @@ -0,0 +1,11 @@ +// +build !notelegram + +package bridgemap + +import ( + btelegram "github.com/42wim/matterbridge/bridge/telegram" +) + +func init() { + FullMap["telegram"] = btelegram.New +} diff --git a/gateway/bridgemap/bwhatsapp.go b/gateway/bridgemap/bwhatsapp.go new file mode 100644 index 00000000..ef6d6f73 --- /dev/null +++ b/gateway/bridgemap/bwhatsapp.go @@ -0,0 +1,11 @@ +// +build !nowhatsapp + +package bridgemap + +import ( + bwhatsapp "github.com/42wim/matterbridge/bridge/whatsapp" +) + +func init() { + FullMap["whatsapp"] = bwhatsapp.New +} diff --git a/gateway/bridgemap/bxmpp.go b/gateway/bridgemap/bxmpp.go new file mode 100644 index 00000000..6988a7d4 --- /dev/null +++ b/gateway/bridgemap/bxmpp.go @@ -0,0 +1,11 @@ +// +build !noxmpp + +package bridgemap + +import ( + bxmpp "github.com/42wim/matterbridge/bridge/xmpp" +) + +func init() { + FullMap["xmpp"] = bxmpp.New +} diff --git a/gateway/bridgemap/bzulip.go b/gateway/bridgemap/bzulip.go new file mode 100644 index 00000000..967f0dde --- /dev/null +++ b/gateway/bridgemap/bzulip.go @@ -0,0 +1,11 @@ +// +build !nozulip + +package bridgemap + +import ( + bzulip "github.com/42wim/matterbridge/bridge/zulip" +) + +func init() { + FullMap["zulip"] = bzulip.New +}