4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 16:39:24 +00:00

Add action support for slack,mattermost,irc,gitter,matrix,xmpp,discord. #199

This commit is contained in:
Wim
2017-07-30 17:48:23 +02:00
parent 54216cec4b
commit f8e6a69d6e
9 changed files with 95 additions and 15 deletions

View File

@ -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
}