commit 95ef37603be4cb17ec90eb07751cc745d9b8d3d3
Author: Wim <wim@42.be>
Date: Sun Feb 17 21:50:05 2019 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 3d1206c..98f3f2a 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -1466 +1467 @@ type Protocol struct {
type ChannelOptions struct {
Key string // irc, xmpp
WebhookURL string // discord
+ Topic string // zulip
}
type Bridge struct {
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go
index 3c6c7ec..89c3b05 100644
--- a/bridge/zulip/zulip.go
+++ b/bridge/zulip/zulip.go
@@ -46 +47 @@ import (
"encoding/json"
"io/ioutil"
"strconv"
+ "sync"
"time"
"github.com/42wim/matterbridge/bridge"
@@ -1710 +1812 @@ type Bzulip struct {
bot *gzb.Bot
streams map[int]string
*bridge.Config
+ channelToTopic map[string]string
+ sync.RWMutex
}
func New(cfg *bridge.Config) bridge.Bridger {
- return &Bzulip{Config: cfg, streams: make(map[int]string)}
+ return &Bzulip{Config: cfg, streams: make(map[int]string), channelToTopic: make(map[string]string)}
}
func (b *Bzulip) Connect() error {
@@ -456 +489 @@ func (b *Bzulip) Disconnect() error {
}
func (b *Bzulip) JoinChannel(channel config.ChannelInfo) error {
+ b.Lock()
+ defer b.Unlock()
+ b.channelToTopic[channel.Name] = channel.Options.Topic
return nil
}
@@ -1456 +1519 @@ func (b *Bzulip) sendMessage(msg config.Message) (string, error) {
if b.GetString("topic") != "" {
topic = b.GetString("topic")
}
+ if res := b.getTopic(msg.Channel); res != "" {
+ topic = res
+ }
m := gzb.Message{
Stream: msg.Channel,
Topic: topic,
@@ -1913 +2009 @@ func (b *Bzulip) handleUploadFile(msg *config.Message) (string, error) {
}
return "", nil
}
+
+func (b *Bzulip) getTopic(channel string) string {
+ b.RLock()
+ defer b.RUnlock()
+ return b.channelToTopic[channel]
+}
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index b3851a0..d6c091d 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -11966 +11968 @@ Server="https://yourserver.zulipchat.com"
#Topic of the messages matterbridge will use
#OPTIONAL (default "matterbridge")
+#You can specify a specific topic for each channel using [gateway.inout.options]
+#See more information below at the gateway configuration
Topic="matterbridge"
## RELOADABLE SETTINGS
@@ -14386 +144013 @@ enable=true
+ [[gateway.inout]]
+ account="zulip.streamchat"
+ channel="general"
+ #OPTIONAL - topic only works for zulip
+ [gateway.inout.options]
+ topic="topic1"
+