summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-02-18 21:45:29 +0100
committerWim <wim@42.be>2016-02-18 21:45:29 +0100
commitf914695801618d76b8982c0c6b53b0470c04e89f (patch)
treec391d10fe8155d45d2033c4faf47b7c2a3b19fab
parent304dc2e25fcfe8f69662956d966c0a2db0610e2b (diff)
downloadmatterbridge-msglm-f914695801618d76b8982c0c6b53b0470c04e89f.tar.gz
matterbridge-msglm-f914695801618d76b8982c0c6b53b0470c04e89f.tar.bz2
matterbridge-msglm-f914695801618d76b8982c0c6b53b0470c04e89f.zip
Add support for slack username circumfix. Closes #10
-rw-r--r--README.md1
-rw-r--r--config.go15
-rw-r--r--matterbridge.conf.sample1
-rw-r--r--matterbridge.go7
4 files changed, 16 insertions, 8 deletions
diff --git a/README.md b/README.md
index a6946f57..9bc7357c 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ UseTLS=false
SkipTLSVerify=true
nick="matterbot"
channel="#matterbridge"
+UseSlackCircumfix=false
[mattermost]
#url is your incoming webhook url (account settings - integrations - incoming webhooks)
diff --git a/config.go b/config.go
index 32187d2b..d1038880 100644
--- a/config.go
+++ b/config.go
@@ -8,13 +8,14 @@ import (
type Config struct {
IRC struct {
- UseTLS bool
- SkipTLSVerify bool
- Server string
- Port int
- Nick string
- Password string
- Channel string
+ UseTLS bool
+ SkipTLSVerify bool
+ Server string
+ Port int
+ Nick string
+ Password string
+ Channel string
+ UseSlackCircumfix bool
}
Mattermost struct {
URL string
diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample
index b44ff8ac..cf17e8a5 100644
--- a/matterbridge.conf.sample
+++ b/matterbridge.conf.sample
@@ -5,6 +5,7 @@ UseTLS=false
SkipTLSVerify=true
nick="matterbot"
channel="#matterbridge"
+UseSlackCircumfix=false
[mattermost]
url="http://yourdomain/hooks/yourhookkey"
diff --git a/matterbridge.go b/matterbridge.go
index a07ab303..6cf4ea2d 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -103,8 +103,13 @@ func (b *Bridge) SendType(nick string, message string, channel string, mtype str
}
func (b *Bridge) handleMatter() {
+ var username string
for {
message := b.m.Receive()
+ username = message.UserName + ": "
+ if b.Config.IRC.UseSlackCircumfix {
+ username = "<" + message.UserName + "> "
+ }
cmd := strings.Fields(message.Text)[0]
switch cmd {
case "!users":
@@ -116,7 +121,7 @@ func (b *Bridge) handleMatter() {
}
texts := strings.Split(message.Text, "\n")
for _, text := range texts {
- b.i.Privmsg(b.getIRCChannel(message.Token), message.UserName+": "+text)
+ b.i.Privmsg(b.getIRCChannel(message.Token), username+text)
}
}
}