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/irc/irc.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bridge/irc') diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index 86ed6974..aa46a6f1 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -135,7 +135,7 @@ func (b *Birc) Send(msg config.Message) error { if len(b.Local) == b.Config.MessageQueue-1 { text = text + " " } - b.Local <- config.Message{Text: text, Username: msg.Username, Channel: msg.Channel} + b.Local <- config.Message{Text: text, Username: msg.Username, Channel: msg.Channel, Event: msg.Event} } else { flog.Debugf("flooding, dropping message (queue at %d)", len(b.Local)) } @@ -148,7 +148,11 @@ func (b *Birc) doSend() { throttle := time.NewTicker(rate) for msg := range b.Local { <-throttle.C - b.i.Privmsg(msg.Channel, msg.Username+msg.Text) + if msg.Event == config.EVENT_USER_ACTION { + b.i.Action(msg.Channel, msg.Username+msg.Text) + } else { + b.i.Privmsg(msg.Channel, msg.Username+msg.Text) + } } } @@ -244,10 +248,12 @@ func (b *Birc) handlePrivMsg(event *irc.Event) { if event.Nick == b.Nick { return } + rmsg := config.Message{Username: event.Nick, Channel: event.Arguments[0], Account: b.Account, UserID: event.User + "@" + event.Host} flog.Debugf("handlePrivMsg() %s %s %#v", event.Nick, event.Message(), event) msg := "" if event.Code == "CTCP_ACTION" { - msg = event.Nick + " " + // msg = event.Nick + " " + rmsg.Event = config.EVENT_USER_ACTION } msg += event.Message() // strip IRC colors @@ -276,7 +282,8 @@ func (b *Birc) handlePrivMsg(event *irc.Event) { msg = string(output) flog.Debugf("Sending message from %s on %s to gateway", event.Arguments[0], b.Account) - b.Remote <- config.Message{Username: event.Nick, Text: msg, Channel: event.Arguments[0], Account: b.Account, UserID: event.User + "@" + event.Host} + rmsg.Text = msg + b.Remote <- rmsg } func (b *Birc) handleTopicWhoTime(event *irc.Event) { -- cgit v1.2.3