5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 03:30:26 +00:00

Merge pull request #12 from fdevibe/msgprefix

Add config option to prefix messages (IRC->MM) with nick
This commit is contained in:
@42wim 2016-03-18 12:50:52 +01:00
commit 4759ee6132
4 changed files with 17 additions and 9 deletions

View File

@ -56,6 +56,8 @@ 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)

View File

@ -8,14 +8,15 @@ 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

View File

@ -6,6 +6,7 @@ SkipTLSVerify=true
nick="matterbot"
channel="#matterbridge"
UseSlackCircumfix=false
PrefixMessagesWithNick=false
[mattermost]
url="http://yourdomain/hooks/yourhookkey"

View File

@ -92,8 +92,12 @@ 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)