diff options
author | Wim <wim@42.be> | 2017-02-03 16:40:15 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-02-03 16:40:15 +0100 |
commit | 2b0f178ba3936aedaac5e35ce382633001b01664 (patch) | |
tree | 91b0b705fe5117d53ec51a94280f702e98358a2a | |
parent | 79e6c9fa6cfca4bfe8913fd891fd9b12bd5bb505 (diff) | |
download | matterbridge-msglm-2b0f178ba3936aedaac5e35ce382633001b01664.tar.gz matterbridge-msglm-2b0f178ba3936aedaac5e35ce382633001b01664.tar.bz2 matterbridge-msglm-2b0f178ba3936aedaac5e35ce382633001b01664.zip |
Fix receiving messages from private channels (slack). See #118
-rw-r--r-- | bridge/slack/slack.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 6432ecc1..763231d8 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -147,6 +147,18 @@ func (b *Bslack) getChannelByName(name string) (*slack.Channel, error) { return nil, fmt.Errorf("%s: channel %s not found", b.Account, name) } +func (b *Bslack) getChannelByID(ID string) (*slack.Channel, error) { + if b.channels == nil { + return nil, fmt.Errorf("%s: channel %s not found (no channels found)", b.Account, ID) + } + for _, channel := range b.channels { + if channel.ID == ID { + return &channel, nil + } + } + return nil, fmt.Errorf("%s: channel %s not found", b.Account, ID) +} + func (b *Bslack) handleSlack() { flog.Debugf("Choosing API based slack connection: %t", b.Config.UseAPI) mchan := make(chan *MMMessage) @@ -178,8 +190,8 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) { // ignore first message if count > 0 { flog.Debugf("Receiving from slackclient %#v", ev) - //ev.ReplyTo - channel, err := b.rtm.GetChannelInfo(ev.Channel) + // use our own func because rtm.GetChannelInfo doesn't work for private channels + channel, err := b.getChannelByID(ev.Channel) if err != nil { continue } |