summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2015-10-24 16:39:01 +0200
committerWim <wim@42.be>2015-10-24 16:39:01 +0200
commitb346ac868b052f07e88cf092d5ee1a04e9f14f81 (patch)
tree7da6120344a09fca68985c1757d0590ade31623c
parentd0cda034786f98f40c8900b7f219c54939dc3c0d (diff)
downloadmatterbridge-msglm-b346ac868b052f07e88cf092d5ee1a04e9f14f81.tar.gz
matterbridge-msglm-b346ac868b052f07e88cf092d5ee1a04e9f14f81.tar.bz2
matterbridge-msglm-b346ac868b052f07e88cf092d5ee1a04e9f14f81.zip
Add support for JOIN, PART and CTCP_ACTION
-rw-r--r--README.md1
-rw-r--r--config.go5
-rw-r--r--matterbridge.conf.sample1
-rw-r--r--matterbridge.go18
4 files changed, 22 insertions, 3 deletions
diff --git a/README.md b/README.md
index 4071dfe0..7f347995 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,7 @@ channel="#matterbridge"
url="http://mattermost.yourdomain.com/hooks/incomingwebhookkey"
#port the bridge webserver will listen on
port=9999
+showjoinpart=true #show irc users joining and parting
```
### mattermost
diff --git a/config.go b/config.go
index 17d4bbd8..07da3732 100644
--- a/config.go
+++ b/config.go
@@ -16,8 +16,9 @@ type Config struct {
Channel string
}
Mattermost struct {
- URL string
- Port int
+ URL string
+ Port int
+ ShowJoinPart bool
}
}
diff --git a/matterbridge.conf.sample b/matterbridge.conf.sample
index a7cb275f..bea46e91 100644
--- a/matterbridge.conf.sample
+++ b/matterbridge.conf.sample
@@ -9,3 +9,4 @@ channel="#matterbridge"
[mattermost]
url="http://yourdomain/hooks/yourhookkey"
port=9999
+showjoinpart=true
diff --git a/matterbridge.go b/matterbridge.go
index 4ba3c00a..d6ec67e1 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -6,6 +6,7 @@ import (
"github.com/thoj/go-ircevent"
"log"
"strconv"
+ "strings"
"time"
)
@@ -33,16 +34,31 @@ func (b *Bridge) createIRC(name string) *irc.Connection {
log.Println("Joining", b.Config.IRC.Channel, "as", b.Config.IRC.Nick)
i.Join(b.Config.IRC.Channel)
i.AddCallback("PRIVMSG", b.handlePrivMsg)
+ i.AddCallback("CTCP_ACTION", b.handlePrivMsg)
+ if b.Config.Mattermost.ShowJoinPart {
+ i.AddCallback("JOIN", b.handleJoinPart)
+ i.AddCallback("PART", b.handleJoinPart)
+ }
return i
}
func (b *Bridge) handlePrivMsg(event *irc.Event) {
matterMessage := matterhook.OMessage{}
- matterMessage.Text = event.Message()
+ if event.Code == "CTCP_ACTION" {
+ matterMessage.Text = event.Nick + " "
+ }
+ matterMessage.Text += event.Message()
matterMessage.UserName = "irc-" + event.Nick
b.m.Send(matterMessage)
}
+func (b *Bridge) handleJoinPart(event *irc.Event) {
+ matterMessage := matterhook.OMessage{}
+ matterMessage.Text = "irc-" + event.Nick + " " + strings.ToLower(event.Code) + "s " + event.Message()
+ matterMessage.UserName = b.Config.IRC.Nick
+ b.m.Send(matterMessage)
+}
+
func (b *Bridge) handleMatter() {
for {
message := b.m.Receive()