diff options
author | Wim <wim@42.be> | 2019-03-20 23:19:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-20 23:19:27 +0100 |
commit | 77516c97db0da515ba01dd9764df0581730ddcc3 (patch) | |
tree | a714c8d6e545708e6daad37cdba1e47c6c467098 /bridge/rocketchat/rocketchat.go | |
parent | cba01f0865d2d78d95825eb844419efe6479c225 (diff) | |
download | matterbridge-msglm-77516c97db0da515ba01dd9764df0581730ddcc3.tar.gz matterbridge-msglm-77516c97db0da515ba01dd9764df0581730ddcc3.tar.bz2 matterbridge-msglm-77516c97db0da515ba01dd9764df0581730ddcc3.zip |
Allow the # in rocketchat channels (backward compatible) (#769)
Diffstat (limited to 'bridge/rocketchat/rocketchat.go')
-rw-r--r-- | bridge/rocketchat/rocketchat.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go index dac05644..fa1dd281 100644 --- a/bridge/rocketchat/rocketchat.go +++ b/bridge/rocketchat/rocketchat.go @@ -2,6 +2,7 @@ package brocketchat import ( "errors" + "strings" "sync" "github.com/42wim/matterbridge/bridge" @@ -85,14 +86,14 @@ func (b *Brocketchat) JoinChannel(channel config.ChannelInfo) error { if b.c == nil { return nil } - id, err := b.c.GetChannelId(channel.Name) + id, err := b.c.GetChannelId(strings.TrimPrefix(channel.Name, "#")) if err != nil { return err } b.Lock() b.channelMap[id] = channel.Name b.Unlock() - mychannel := &models.Channel{ID: id, Name: channel.Name} + mychannel := &models.Channel{ID: id, Name: strings.TrimPrefix(channel.Name, "#")} if err := b.c.JoinChannel(id); err != nil { return err } @@ -103,6 +104,8 @@ func (b *Brocketchat) JoinChannel(channel config.ChannelInfo) error { } func (b *Brocketchat) Send(msg config.Message) (string, error) { + // strip the # if people has set this + msg.Channel = strings.TrimPrefix(msg.Channel, "#") channel := &models.Channel{ID: b.getChannelID(msg.Channel), Name: msg.Channel} // Delete message @@ -131,6 +134,8 @@ func (b *Brocketchat) Send(msg config.Message) (string, error) { // Upload a file if it exists if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) { + // strip the # if people has set this + rmsg.Channel = strings.TrimPrefix(rmsg.Channel, "#") smsg := &models.Message{ RoomID: b.getChannelID(rmsg.Channel), Msg: rmsg.Username + rmsg.Text, |