diff options
author | Wim <wim@42.be> | 2016-10-08 21:57:03 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-10-08 21:57:03 +0200 |
commit | db0e4ba8c5d290160411e7be889609bb41bef174 (patch) | |
tree | cd1026a1298fe7715cff83a401cd94c5f1269950 /bridge | |
parent | 2d6ed51d9407c2f6d8c065478d536ec3a019dade (diff) | |
download | matterbridge-msglm-db0e4ba8c5d290160411e7be889609bb41bef174.tar.gz matterbridge-msglm-db0e4ba8c5d290160411e7be889609bb41bef174.tar.bz2 matterbridge-msglm-db0e4ba8c5d290160411e7be889609bb41bef174.zip |
Add error message about non-existing channels (slack)
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/slack/slack.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index d0156ec8..62cb04b7 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -1,6 +1,7 @@ package bslack import ( + "fmt" "github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/matterhook" log "github.com/Sirupsen/logrus" @@ -115,21 +116,25 @@ func (b *Bslack) SendType(nick string, message string, channel string, mtype str } return nil } - newmsg := b.rtm.NewOutgoingMessage(message, b.getChannelByName(channel).ID) + schannel, err := b.getChannelByName(channel) + if err != nil { + return err + } + newmsg := b.rtm.NewOutgoingMessage(message, schannel.ID) b.rtm.SendMessage(newmsg) return nil } -func (b *Bslack) getChannelByName(name string) *slack.Channel { +func (b *Bslack) getChannelByName(name string) (*slack.Channel, error) { if b.channels == nil { - return nil + return nil, fmt.Errorf("%s: channel %s not found (no channels found)", b.FullOrigin(), name) } for _, channel := range b.channels { if channel.Name == name { - return &channel + return &channel, nil } } - return nil + return nil, fmt.Errorf("%s: channel %s not found", b.FullOrigin(), name) } func (b *Bslack) handleSlack() { |