summaryrefslogtreecommitdiffstats
path: root/matterbridge.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2015-10-24 18:44:45 +0200
committerWim <wim@42.be>2015-10-24 18:44:45 +0200
commit43738dbc89c888967181309002dc46b2c64990a0 (patch)
treeabbb4ae072d5d50e8559c5d09afe056ac60b4ffe /matterbridge.go
parent6feccd4c6cae08c7c6a4f283822565785428b2e0 (diff)
downloadmatterbridge-msglm-43738dbc89c888967181309002dc46b2c64990a0.tar.gz
matterbridge-msglm-43738dbc89c888967181309002dc46b2c64990a0.tar.bz2
matterbridge-msglm-43738dbc89c888967181309002dc46b2c64990a0.zip
Refactor and IconURL support
Diffstat (limited to 'matterbridge.go')
-rw-r--r--matterbridge.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/matterbridge.go b/matterbridge.go
index 219f062e..94d38954 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -45,30 +45,31 @@ func (b *Bridge) createIRC(name string) *irc.Connection {
}
func (b *Bridge) handlePrivMsg(event *irc.Event) {
- matterMessage := matterhook.OMessage{}
+ msg := ""
if event.Code == "CTCP_ACTION" {
- matterMessage.Text = event.Nick + " "
+ msg = event.Nick + " "
}
- matterMessage.Text += event.Message()
- matterMessage.UserName = "irc-" + event.Nick
- b.m.Send(matterMessage)
+ msg += event.Message()
+ b.Send("irc-"+event.Nick, msg)
}
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)
+ b.Send(b.Config.IRC.Nick, "irc-"+event.Nick+" "+strings.ToLower(event.Code)+"s "+event.Message())
}
func (b *Bridge) handleOther(event *irc.Event) {
- matterMessage := matterhook.OMessage{}
switch event.Code {
case "353":
- matterMessage.UserName = b.Config.IRC.Nick
- matterMessage.Text = event.Message() + " currently on IRC"
+ b.Send(b.Config.IRC.Nick, event.Message()+" currently on IRC")
}
+}
+
+func (b *Bridge) Send(nick string, message string) error {
+ matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
+ matterMessage.UserName = nick
+ matterMessage.Text = message
b.m.Send(matterMessage)
+ return nil
}
func (b *Bridge) handleMatter() {