forked from jshiffer/matterbridge
Refactor and IconURL support
This commit is contained in:
parent
6feccd4c6c
commit
43738dbc89
@ -20,6 +20,7 @@ type Config struct {
|
|||||||
Port int
|
Port int
|
||||||
ShowJoinPart bool
|
ShowJoinPart bool
|
||||||
Token string
|
Token string
|
||||||
|
IconURL string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,3 +11,4 @@ url="http://yourdomain/hooks/yourhookkey"
|
|||||||
port=9999
|
port=9999
|
||||||
showjoinpart=true
|
showjoinpart=true
|
||||||
#token=yourtokenfrommattermost
|
#token=yourtokenfrommattermost
|
||||||
|
IconURL="http://youricon.png"
|
||||||
|
@ -45,30 +45,31 @@ func (b *Bridge) createIRC(name string) *irc.Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
||||||
matterMessage := matterhook.OMessage{}
|
msg := ""
|
||||||
if event.Code == "CTCP_ACTION" {
|
if event.Code == "CTCP_ACTION" {
|
||||||
matterMessage.Text = event.Nick + " "
|
msg = event.Nick + " "
|
||||||
}
|
}
|
||||||
matterMessage.Text += event.Message()
|
msg += event.Message()
|
||||||
matterMessage.UserName = "irc-" + event.Nick
|
b.Send("irc-"+event.Nick, msg)
|
||||||
b.m.Send(matterMessage)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
||||||
matterMessage := matterhook.OMessage{}
|
b.Send(b.Config.IRC.Nick, "irc-"+event.Nick+" "+strings.ToLower(event.Code)+"s "+event.Message())
|
||||||
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) handleOther(event *irc.Event) {
|
func (b *Bridge) handleOther(event *irc.Event) {
|
||||||
matterMessage := matterhook.OMessage{}
|
|
||||||
switch event.Code {
|
switch event.Code {
|
||||||
case "353":
|
case "353":
|
||||||
matterMessage.UserName = b.Config.IRC.Nick
|
b.Send(b.Config.IRC.Nick, event.Message()+" currently on IRC")
|
||||||
matterMessage.Text = 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)
|
b.m.Send(matterMessage)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleMatter() {
|
func (b *Bridge) handleMatter() {
|
||||||
|
Loading…
Reference in New Issue
Block a user