5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-25 07:15:43 +00:00

Refactor and IconURL support

This commit is contained in:
Wim 2015-10-24 18:44:45 +02:00
parent 6feccd4c6c
commit 43738dbc89
3 changed files with 15 additions and 12 deletions

View File

@ -20,6 +20,7 @@ type Config struct {
Port int
ShowJoinPart bool
Token string
IconURL string
}
}

View File

@ -11,3 +11,4 @@ url="http://yourdomain/hooks/yourhookkey"
port=9999
showjoinpart=true
#token=yourtokenfrommattermost
IconURL="http://youricon.png"

View File

@ -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() {