diff options
Diffstat (limited to 'bridge/xmpp/xmpp.go')
-rw-r--r-- | bridge/xmpp/xmpp.go | 15 |
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 +} |