summaryrefslogtreecommitdiffstats
path: root/bridge/xmpp
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-30 17:48:23 +0200
committerWim <wim@42.be>2017-07-30 17:48:23 +0200
commitf8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5 (patch)
tree7ac1bc3a4c0d0429cf01adcedd2ae0422d6963cd /bridge/xmpp
parent54216cec4b4f2023306e378587b1ac55dc720968 (diff)
downloadmatterbridge-msglm-f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5.tar.gz
matterbridge-msglm-f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5.tar.bz2
matterbridge-msglm-f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5.zip
Add action support for slack,mattermost,irc,gitter,matrix,xmpp,discord. #199
Diffstat (limited to 'bridge/xmpp')
-rw-r--r--bridge/xmpp/xmpp.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 504b9747..dfc2967e 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -133,6 +133,7 @@ func (b *Bxmpp) xmppKeepAlive() chan bool {
}
func (b *Bxmpp) handleXmpp() error {
+ var ok bool
done := b.xmppKeepAlive()
defer close(done)
nodelay := time.Time{}
@@ -154,8 +155,13 @@ func (b *Bxmpp) handleXmpp() error {
nick = s[1]
}
if nick != b.Config.Nick && v.Stamp == nodelay && v.Text != "" {
+ rmsg := config.Message{Username: nick, Text: v.Text, Channel: channel, Account: b.Account, UserID: v.Remote}
+ rmsg.Text, ok = b.replaceAction(rmsg.Text)
+ if ok {
+ rmsg.Event = config.EVENT_USER_ACTION
+ }
flog.Debugf("Sending message from %s on %s to gateway", nick, b.Account)
- b.Remote <- config.Message{Username: nick, Text: v.Text, Channel: channel, Account: b.Account, UserID: v.Remote}
+ b.Remote <- rmsg
}
}
case xmpp.Presence:
@@ -163,3 +169,10 @@ func (b *Bxmpp) handleXmpp() error {
}
}
}
+
+func (b *Bxmpp) replaceAction(text string) (string, bool) {
+ if strings.HasPrefix(text, "/me ") {
+ return strings.Replace(text, "/me ", "", -1), true
+ }
+ return text, false
+}