Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 5ec94fdb4356df1be68a107f0ac142d44530b334 Author: Fredrik de Vibe <fdv@ifi.uio.no> Date: Fri Mar 18 06:09:29 2016 +0000 Add config option to prefix messages (IRC->MM) with nick If username overriding isn't enabled on the Mattermost server, this is required for Mattermost users to see who sent a message from IRC. diff --git a/README.md b/README.md index f10f917..a17f1b5 100644 --- a/README.md +++ b/README.md @@ -566 +568 @@ SkipTLSVerify=true  nick="matterbot"  channel="#matterbridge"  UseSlackCircumfix=false +#whether to prefix messages from IRC to mattermost with the sender's nick. Useful if username overrides for incoming webhooks isn't enabled on the mattermost server +PrefixMessagesWithNick=false    [mattermost]  #url is your incoming webhook url (account settings - integrations - incoming webhooks) diff --git a/config.go b/config.go index d103888..d0bf804 100644 --- a/config.go +++ b/config.go @@ -814 +815 @@ import (    type Config struct {   IRC struct { - UseTLS bool - SkipTLSVerify bool - Server string - Port int - Nick string - Password string - Channel string - UseSlackCircumfix bool + UseTLS bool + SkipTLSVerify bool + Server string + Port int + Nick string + Password string + Channel string + UseSlackCircumfix bool + PrefixMessagesWithNick bool   }   Mattermost struct {   URL string diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample index cf17e8a..843402e 100644 --- a/matterbridge.conf.sample +++ b/matterbridge.conf.sample @@ -66 +67 @@ SkipTLSVerify=true  nick="matterbot"  channel="#matterbridge"  UseSlackCircumfix=false +PrefixMessagesWithNick=false    [mattermost]  url="http://yourdomain/hooks/yourhookkey" diff --git a/matterbridge.go b/matterbridge.go index 6cf4ea2..4302cf1 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -928 +9212 @@ func (b *Bridge) SendType(nick string, message string, channel string, mtype str   matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}   matterMessage.Channel = channel   matterMessage.UserName = nick - matterMessage.Text = message   matterMessage.Type = mtype + if (b.Config.IRC.PrefixMessagesWithNick) { + matterMessage.Text = nick + ": " + message + } else { + matterMessage.Text = message + }   err := b.m.Send(matterMessage)   if err != nil {   log.Println(err)