diff options
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/discord/discord.go | 4 | ||||
-rw-r--r-- | bridge/gitter/gitter.go | 4 | ||||
-rw-r--r-- | bridge/slack/slack.go | 13 | ||||
-rw-r--r-- | bridge/xmpp/xmpp.go | 4 |
4 files changed, 16 insertions, 9 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go index f1331dd4..446977ad 100644 --- a/bridge/discord/discord.go +++ b/bridge/discord/discord.go @@ -25,9 +25,9 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(config config.Protocol, origin string, c chan config.Message) *bdiscord { +func New(cfg config.Protocol, origin string, c chan config.Message) *bdiscord { b := &bdiscord{} - b.Config = &config + b.Config = &cfg b.Remote = c b.protocol = protocol b.origin = origin diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go index 8d3a0459..95c41af4 100644 --- a/bridge/gitter/gitter.go +++ b/bridge/gitter/gitter.go @@ -23,9 +23,9 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(config config.Protocol, origin string, c chan config.Message) *Bgitter { +func New(cfg config.Protocol, origin string, c chan config.Message) *Bgitter { b := &Bgitter{} - b.Config = &config + b.Config = &cfg b.Remote = c b.protocol = protocol b.origin = origin diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index f9432863..3b0a6c85 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -14,6 +14,7 @@ type MMMessage struct { Text string Channel string Username string + Raw *slack.MessageEvent } type Bslack struct { @@ -25,6 +26,7 @@ type Bslack struct { Remote chan config.Message protocol string origin string + si *slack.Info channels []slack.Channel } @@ -35,13 +37,12 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(config config.Protocol, origin string, c chan config.Message) *Bslack { +func New(cfg config.Protocol, origin string, c chan config.Message) *Bslack { b := &Bslack{} - b.Config = &config + b.Config = &cfg b.Remote = c b.protocol = protocol b.origin = origin - b.Config.UseAPI = config.UseAPI return b } @@ -148,6 +149,10 @@ func (b *Bslack) handleSlack() { time.Sleep(time.Second) flog.Debug("Start listening for Slack messages") for message := range mchan { + // do not send messages from ourself + if message.Username == b.si.User.Name { + continue + } texts := strings.Split(message.Text, "\n") for _, text := range texts { flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.FullOrigin()) @@ -177,6 +182,7 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) { m.Username = user.Name m.Channel = channel.Name m.Text = ev.Text + m.Raw = ev mchan <- m } count++ @@ -184,6 +190,7 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) { flog.Debugf("%#v", ev.Error()) case *slack.ConnectedEvent: b.channels = ev.Info.Channels + b.si = ev.Info case *slack.InvalidAuthEvent: flog.Fatalf("Invalid Token %#v", ev) default: diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index a7c326be..164284e5 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -25,10 +25,10 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(config config.Protocol, origin string, c chan config.Message) *Bxmpp { +func New(cfg config.Protocol, origin string, c chan config.Message) *Bxmpp { b := &Bxmpp{} b.xmppMap = make(map[string]string) - b.Config = &config + b.Config = &cfg b.protocol = protocol b.origin = origin b.Remote = c |