From f8e6a69d6e8453de0b700b6e9a3eedeec0b1f0a5 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 30 Jul 2017 17:48:23 +0200 Subject: Add action support for slack,mattermost,irc,gitter,matrix,xmpp,discord. #199 --- bridge/xmpp/xmpp.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'bridge/xmpp/xmpp.go') 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 +} -- cgit v1.2.3