mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-18 17:12:37 +01:00
parent
0bcb0b882f
commit
a8fe54a78d
@ -146,6 +146,7 @@ type Protocol struct {
|
|||||||
type ChannelOptions struct {
|
type ChannelOptions struct {
|
||||||
Key string // irc, xmpp
|
Key string // irc, xmpp
|
||||||
WebhookURL string // discord
|
WebhookURL string // discord
|
||||||
|
Topic string // zulip
|
||||||
}
|
}
|
||||||
|
|
||||||
type Bridge struct {
|
type Bridge struct {
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/42wim/matterbridge/bridge"
|
"github.com/42wim/matterbridge/bridge"
|
||||||
@ -17,10 +18,12 @@ type Bzulip struct {
|
|||||||
bot *gzb.Bot
|
bot *gzb.Bot
|
||||||
streams map[int]string
|
streams map[int]string
|
||||||
*bridge.Config
|
*bridge.Config
|
||||||
|
channelToTopic map[string]string
|
||||||
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(cfg *bridge.Config) bridge.Bridger {
|
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 {
|
func (b *Bzulip) Connect() error {
|
||||||
@ -45,6 +48,9 @@ func (b *Bzulip) Disconnect() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bzulip) JoinChannel(channel config.ChannelInfo) error {
|
func (b *Bzulip) JoinChannel(channel config.ChannelInfo) error {
|
||||||
|
b.Lock()
|
||||||
|
defer b.Unlock()
|
||||||
|
b.channelToTopic[channel.Name] = channel.Options.Topic
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +151,9 @@ func (b *Bzulip) sendMessage(msg config.Message) (string, error) {
|
|||||||
if b.GetString("topic") != "" {
|
if b.GetString("topic") != "" {
|
||||||
topic = b.GetString("topic")
|
topic = b.GetString("topic")
|
||||||
}
|
}
|
||||||
|
if res := b.getTopic(msg.Channel); res != "" {
|
||||||
|
topic = res
|
||||||
|
}
|
||||||
m := gzb.Message{
|
m := gzb.Message{
|
||||||
Stream: msg.Channel,
|
Stream: msg.Channel,
|
||||||
Topic: topic,
|
Topic: topic,
|
||||||
@ -191,3 +200,9 @@ func (b *Bzulip) handleUploadFile(msg *config.Message) (string, error) {
|
|||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bzulip) getTopic(channel string) string {
|
||||||
|
b.RLock()
|
||||||
|
defer b.RUnlock()
|
||||||
|
return b.channelToTopic[channel]
|
||||||
|
}
|
||||||
|
@ -1196,6 +1196,8 @@ Server="https://yourserver.zulipchat.com"
|
|||||||
|
|
||||||
#Topic of the messages matterbridge will use
|
#Topic of the messages matterbridge will use
|
||||||
#OPTIONAL (default "matterbridge")
|
#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"
|
Topic="matterbridge"
|
||||||
|
|
||||||
## RELOADABLE SETTINGS
|
## RELOADABLE SETTINGS
|
||||||
@ -1438,6 +1440,13 @@ enable=true
|
|||||||
[gateway.inout.options]
|
[gateway.inout.options]
|
||||||
webhookurl="https://discordapp.com/api/webhooks/123456789123456789/C9WPqExYWONPDZabcdef-def1434FGFjstasJX9pYht73y"
|
webhookurl="https://discordapp.com/api/webhooks/123456789123456789/C9WPqExYWONPDZabcdef-def1434FGFjstasJX9pYht73y"
|
||||||
|
|
||||||
|
[[gateway.inout]]
|
||||||
|
account="zulip.streamchat"
|
||||||
|
channel="general"
|
||||||
|
#OPTIONAL - topic only works for zulip
|
||||||
|
[gateway.inout.options]
|
||||||
|
topic="topic1"
|
||||||
|
|
||||||
#API example
|
#API example
|
||||||
#[[gateway.inout]]
|
#[[gateway.inout]]
|
||||||
#account="api.local"
|
#account="api.local"
|
||||||
|
Loading…
Reference in New Issue
Block a user