commit 66f3022fc3fc783ab91eec179feab64ad4cb75e6
Author: Wim <wim@42.be>
Date: Sun Aug 27 22:59:37 2017 +0000
diff --git a/bridge/api/api.go b/bridge/api/api.go
index 196be18..ca28d90 100644
--- a/bridge/api/api.go
+++ b/bridge/api/api.go
@@ -6611 +6611 @@ func (b *Api) JoinChannel(channel config.ChannelInfo) error {
}
-func (b *Api) Send(msg config.Message) error {
+func (b *Api) Send(msg config.Message) (string, error) {
b.Lock()
defer b.Unlock()
b.Messages.Enqueue(&msg)
- return nil
+ return "", nil
}
func (b *Api) handlePostMessage(c echo.Context) error {
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 2fe0f07..5df7c3d 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -197 +197 @@ import (
)
type Bridger interface {
- Send(msg config.Message) error
+ Send(msg config.Message) (string, error)
Connect() error
JoinChannel(channel config.ChannelInfo) error
Disconnect() error
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index 7debcda..b44ad89 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -10812 +10812 @@ func (b *bdiscord) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *bdiscord) Send(msg config.Message) error {
+func (b *bdiscord) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
channelID := b.getChannelID(msg.Channel)
if channelID == "" {
flog.Errorf("Could not find channelID for %v", msg.Channel)
- return nil
+ return "", nil
}
if msg.Event == config.EVENT_USER_ACTION {
msg.Text = "_" + msg.Text + "_"
@@ -1427 +1427 @@ func (b *bdiscord) Send(msg config.Message) error {
AvatarURL: msg.Avatar,
})
}
- return nil
+ return "", nil
}
func (b *bdiscord) messageUpdate(s *discordgo.Session, m *discordgo.MessageUpdate) {
diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go
index f234b6b..8f57ed9 100644
--- a/bridge/gitter/gitter.go
+++ b/bridge/gitter/gitter.go
@@ -9715 +9715 @@ func (b *Bgitter) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Bgitter) Send(msg config.Message) error {
+func (b *Bgitter) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
roomID := b.getRoomID(msg.Channel)
if roomID == "" {
flog.Errorf("Could not find roomID for %v", msg.Channel)
- return nil
+ return "", nil
}
// add ZWSP because gitter echoes our own messages
- return b.c.SendMessage(roomID, msg.Username+msg.Text+" ")
+ return "", b.c.SendMessage(roomID, msg.Username+msg.Text+" ")
}
func (b *Bgitter) getRoomID(channel string) string {
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 6e5839b..36b01b6 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -1277 +1277 @@ func (b *Birc) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Birc) Send(msg config.Message) error {
+func (b *Birc) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
if strings.HasPrefix(msg.Text, "!") {
b.Command(&msg)
@@ -1457 +1457 @@ func (b *Birc) Send(msg config.Message) error {
flog.Debugf("flooding, dropping message (queue at %d)", len(b.Local))
}
}
- return nil
+ return "", nil
}
func (b *Birc) doSend() {
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go
index b37738c..1cad622 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -7417 +7417 @@ func (b *Bmatrix) JoinChannel(channel config.ChannelInfo) error {
return err
}
-func (b *Bmatrix) Send(msg config.Message) error {
+func (b *Bmatrix) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
channel := b.getRoomID(msg.Channel)
flog.Debugf("Sending to channel %s", channel)
if msg.Event == config.EVENT_USER_ACTION {
b.mc.SendMessageEvent(channel, "m.room.message",
matrix.TextMessage{"m.emote", msg.Username + msg.Text})
- return nil
+ return "", nil
}
b.mc.SendText(channel, msg.Username+msg.Text)
- return nil
+ return "", nil
}
func (b *Bmatrix) getRoomID(channel string) string {
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index 3de7e55..e7f125b 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -1367 +1367 @@ func (b *Bmattermost) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Bmattermost) Send(msg config.Message) error {
+func (b *Bmattermost) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
if msg.Event == config.EVENT_USER_ACTION {
msg.Text = "*" + msg.Text + "*"
@@ -15812 +15812 @@ func (b *Bmattermost) Send(msg config.Message) error {
err := b.mh.Send(matterMessage)
if err != nil {
flog.Info(err)
- return err
+ return "", err
}
- return nil
+ return "", nil
}
b.mc.PostMessage(b.mc.GetChannelId(channel, ""), message)
- return nil
+ return "", nil
}
func (b *Bmattermost) handleMatter() {
diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go
index 3223a78..1e534c2 100644
--- a/bridge/rocketchat/rocketchat.go
+++ b/bridge/rocketchat/rocketchat.go
@@ -577 +577 @@ func (b *Brocketchat) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Brocketchat) Send(msg config.Message) error {
+func (b *Brocketchat) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
matterMessage.Channel = msg.Channel
@@ -679 +679 @@ func (b *Brocketchat) Send(msg config.Message) error {
err := b.mh.Send(matterMessage)
if err != nil {
flog.Info(err)
- return err
+ return "", err
}
- return nil
+ return "", nil
}
func (b *Brocketchat) handleRocketHook() {
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index f266302..edbb668 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -1257 +1257 @@ func (b *Bslack) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Bslack) Send(msg config.Message) error {
+func (b *Bslack) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
if msg.Event == config.EVENT_USER_ACTION {
msg.Text = "_" + msg.Text + "_"
@@ -14513 +14513 @@ func (b *Bslack) Send(msg config.Message) error {
err := b.mh.Send(matterMessage)
if err != nil {
flog.Info(err)
- return err
+ return "", err
}
- return nil
+ return "", nil
}
schannel, err := b.getChannelByName(channel)
if err != nil {
- return err
+ return "", err
}
np := slack.NewPostMessageParameters()
if b.Config.PrefixMessagesWithNick {
@@ -1707 +1707 @@ func (b *Bslack) Send(msg config.Message) error {
b.rtm.SendMessage(newmsg)
*/
- return nil
+ return "", nil
}
func (b *Bslack) getAvatar(user string) string {
diff --git a/bridge/steam/steam.go b/bridge/steam/steam.go
index aa125e4..25291ff 100644
--- a/bridge/steam/steam.go
+++ b/bridge/steam/steam.go
@@ -6913 +6913 @@ func (b *Bsteam) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Bsteam) Send(msg config.Message) error {
+func (b *Bsteam) Send(msg config.Message) (string, error) {
id, err := steamid.NewId(msg.Channel)
if err != nil {
- return err
+ return "", err
}
b.c.Social.SendMessage(id, steamlang.EChatEntryType_ChatMsg, msg.Username+msg.Text)
- return nil
+ return "", nil
}
func (b *Bsteam) getNick(id steamid.SteamId) string {
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go
index 77704ab..d0c471b 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -5711 +5711 @@ func (b *Btelegram) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Btelegram) Send(msg config.Message) error {
+func (b *Btelegram) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
chatid, err := strconv.ParseInt(msg.Channel, 10, 64)
if err != nil {
- return err
+ return "", err
}
if b.Config.MessageFormat == "HTML" {
@@ -727 +727 @@ func (b *Btelegram) Send(msg config.Message) error {
m.ParseMode = tgbotapi.ModeHTML
}
_, err = b.c.Send(m)
- return err
+ return "", err
}
func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 56773ef..d453706 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -7910 +7910 @@ func (b *Bxmpp) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Bxmpp) Send(msg config.Message) error {
+func (b *Bxmpp) Send(msg config.Message) (string, error) {
flog.Debugf("Receiving %#v", msg)
b.xc.Send(xmpp.Chat{Type: "groupchat", Remote: msg.Channel + "@" + b.Config.Muc, Text: msg.Username + msg.Text})
- return nil
+ return "", nil
}
func (b *Bxmpp) createXMPP() (*xmpp.Client, error) {
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 86fa572..a7fc411 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -216 +2112 @@ type Gateway struct {
ChannelOptions map[string]config.ChannelOptions
Message chan config.Message
Name string
+ Messages map[string][]*BridgeMsg
+}
+
+type BridgeMsg struct {
+ br *bridge.Bridge
+ ID string
}
func New(cfg config.Gateway, r *Router) *Gateway {
@@ -1627 +1687 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
if dest.Protocol == "api" {
msg.Channel = originchannel
}
- err := dest.Send(msg)
+ _, err := dest.Send(msg)
if err != nil {
fmt.Println(err)
}