mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-21 10:12:00 -08:00
Fix receiving messages from private channels (slack). See #118
This commit is contained in:
parent
79e6c9fa6c
commit
2b0f178ba3
@ -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)
|
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() {
|
func (b *Bslack) handleSlack() {
|
||||||
flog.Debugf("Choosing API based slack connection: %t", b.Config.UseAPI)
|
flog.Debugf("Choosing API based slack connection: %t", b.Config.UseAPI)
|
||||||
mchan := make(chan *MMMessage)
|
mchan := make(chan *MMMessage)
|
||||||
@ -178,8 +190,8 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
|
|||||||
// ignore first message
|
// ignore first message
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
flog.Debugf("Receiving from slackclient %#v", ev)
|
flog.Debugf("Receiving from slackclient %#v", ev)
|
||||||
//ev.ReplyTo
|
// use our own func because rtm.GetChannelInfo doesn't work for private channels
|
||||||
channel, err := b.rtm.GetChannelInfo(ev.Channel)
|
channel, err := b.getChannelByID(ev.Channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user