mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-18 17:12:37 +01:00
Add error message about non-existing channels (slack)
This commit is contained in:
parent
2d6ed51d94
commit
db0e4ba8c5
@ -1,6 +1,7 @@
|
|||||||
package bslack
|
package bslack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/42wim/matterbridge/bridge/config"
|
"github.com/42wim/matterbridge/bridge/config"
|
||||||
"github.com/42wim/matterbridge/matterhook"
|
"github.com/42wim/matterbridge/matterhook"
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
@ -115,21 +116,25 @@ func (b *Bslack) SendType(nick string, message string, channel string, mtype str
|
|||||||
}
|
}
|
||||||
return nil
|
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)
|
b.rtm.SendMessage(newmsg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bslack) getChannelByName(name string) *slack.Channel {
|
func (b *Bslack) getChannelByName(name string) (*slack.Channel, error) {
|
||||||
if b.channels == nil {
|
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 {
|
for _, channel := range b.channels {
|
||||||
if channel.Name == name {
|
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() {
|
func (b *Bslack) handleSlack() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package gateway
|
package gateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/42wim/matterbridge/bridge"
|
"github.com/42wim/matterbridge/bridge"
|
||||||
"github.com/42wim/matterbridge/bridge/config"
|
"github.com/42wim/matterbridge/bridge/config"
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
@ -109,7 +110,10 @@ func (gw *Gateway) handleMessage(msg config.Message, dest bridge.Bridge) {
|
|||||||
}
|
}
|
||||||
gw.modifyMessage(&msg, dest)
|
gw.modifyMessage(&msg, dest)
|
||||||
log.Debugf("Sending %#v from %s to %s", msg, msg.FullOrigin, dest.FullOrigin())
|
log.Debugf("Sending %#v from %s to %s", msg, msg.FullOrigin, dest.FullOrigin())
|
||||||
dest.Send(msg)
|
err := dest.Send(msg)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,10 @@ func (gw *SameChannelGateway) handleMessage(msg config.Message, dest bridge.Brid
|
|||||||
}
|
}
|
||||||
gw.modifyMessage(&msg, dest)
|
gw.modifyMessage(&msg, dest)
|
||||||
log.Debugf("Sending %#v from %s to %s", msg, msg.FullOrigin, dest.FullOrigin())
|
log.Debugf("Sending %#v from %s to %s", msg, msg.FullOrigin, dest.FullOrigin())
|
||||||
dest.Send(msg)
|
err := dest.Send(msg)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNickFormat(msg *config.Message, format string) {
|
func setNickFormat(msg *config.Message, format string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user