summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-08-27 22:59:37 +0200
committerWim <wim@42.be>2017-08-27 22:59:37 +0200
commit5a8d7b5f6d30bf4d3ee93fe9593e0b3504ad684a (patch)
tree62f8534833b4184606980d1b61b44bbec8898fed /bridge
parentcfb810713872a5f95a5a54c449fef3bce5aa05b5 (diff)
downloadmatterbridge-msglm-5a8d7b5f6d30bf4d3ee93fe9593e0b3504ad684a.tar.gz
matterbridge-msglm-5a8d7b5f6d30bf4d3ee93fe9593e0b3504ad684a.tar.bz2
matterbridge-msglm-5a8d7b5f6d30bf4d3ee93fe9593e0b3504ad684a.zip
Modify Send() to return also a message id
Diffstat (limited to 'bridge')
-rw-r--r--bridge/api/api.go4
-rw-r--r--bridge/bridge.go2
-rw-r--r--bridge/discord/discord.go6
-rw-r--r--bridge/gitter/gitter.go6
-rw-r--r--bridge/irc/irc.go4
-rw-r--r--bridge/matrix/matrix.go6
-rw-r--r--bridge/mattermost/mattermost.go8
-rw-r--r--bridge/rocketchat/rocketchat.go6
-rw-r--r--bridge/slack/slack.go10
-rw-r--r--bridge/steam/steam.go6
-rw-r--r--bridge/telegram/telegram.go6
-rw-r--r--bridge/xmpp/xmpp.go4
12 files changed, 34 insertions, 34 deletions
diff --git a/bridge/api/api.go b/bridge/api/api.go
index 196be182..ca28d904 100644
--- a/bridge/api/api.go
+++ b/bridge/api/api.go
@@ -66,11 +66,11 @@ 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 2fe0f076..5df7c3da 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -19,7 +19,7 @@ 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 7debcda0..b44ad898 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -108,12 +108,12 @@ 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 + "_"
@@ -142,7 +142,7 @@ 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 f234b6bb..8f57ed94 100644
--- a/bridge/gitter/gitter.go
+++ b/bridge/gitter/gitter.go
@@ -97,15 +97,15 @@ 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 6e5839bd..36b01b6c 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -127,7 +127,7 @@ 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)
@@ -145,7 +145,7 @@ 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 b37738c6..1cad6221 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -74,17 +74,17 @@ 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 3de7e553..e7f125bd 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -136,7 +136,7 @@ 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 + "*"
@@ -158,12 +158,12 @@ 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 3223a781..1e534c20 100644
--- a/bridge/rocketchat/rocketchat.go
+++ b/bridge/rocketchat/rocketchat.go
@@ -57,7 +57,7 @@ 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
@@ -67,9 +67,9 @@ 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 f2663029..edbb668f 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -125,7 +125,7 @@ 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 + "_"
@@ -145,13 +145,13 @@ 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 {
@@ -170,7 +170,7 @@ 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 aa125e4a..25291ff4 100644
--- a/bridge/steam/steam.go
+++ b/bridge/steam/steam.go
@@ -69,13 +69,13 @@ 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 77704ab9..d0c471b2 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -57,11 +57,11 @@ 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" {
@@ -72,7 +72,7 @@ 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 56773ef5..d453706a 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -79,10 +79,10 @@ 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) {