mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-24 17:51:36 +00:00
Add option to change receiving mattermost channel
This commit is contained in:
parent
f0a5d2396f
commit
0dc5e042d2
@ -23,6 +23,7 @@ type Config struct {
|
|||||||
IconURL string
|
IconURL string
|
||||||
SkipTLSVerify bool
|
SkipTLSVerify bool
|
||||||
BindAddress string
|
BindAddress string
|
||||||
|
Channel string
|
||||||
}
|
}
|
||||||
General struct {
|
General struct {
|
||||||
GiphyAPIKey string
|
GiphyAPIKey string
|
||||||
|
@ -54,26 +54,28 @@ func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
|||||||
msg = event.Nick + " "
|
msg = event.Nick + " "
|
||||||
}
|
}
|
||||||
msg += event.Message()
|
msg += event.Message()
|
||||||
b.Send("irc-"+event.Nick, msg)
|
b.Send("irc-"+event.Nick, msg, b.Config.Mattermost.Channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
||||||
b.SendType(b.Config.IRC.Nick, "irc-"+event.Nick+" "+strings.ToLower(event.Code)+"s "+event.Message(), "join_leave")
|
b.SendType(b.Config.IRC.Nick, "irc-"+event.Nick+" "+strings.ToLower(event.Code)+"s "+event.Message(),
|
||||||
|
b.Config.Mattermost.Channel, "join_leave")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleOther(event *irc.Event) {
|
func (b *Bridge) handleOther(event *irc.Event) {
|
||||||
switch event.Code {
|
switch event.Code {
|
||||||
case "353":
|
case "353":
|
||||||
b.Send(b.Config.IRC.Nick, event.Message()+" currently on IRC")
|
b.Send(b.Config.IRC.Nick, event.Message()+" currently on IRC", b.Config.Mattermost.Channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) Send(nick string, message string) error {
|
func (b *Bridge) Send(nick string, message string, channel string) error {
|
||||||
return b.SendType(nick, message, "")
|
return b.SendType(nick, message, channel, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) SendType(nick string, message string, mtype string) error {
|
func (b *Bridge) SendType(nick string, message string, channel string, mtype string) error {
|
||||||
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
matterMessage := matterhook.OMessage{IconURL: b.Config.Mattermost.IconURL}
|
||||||
|
matterMessage.Channel = channel
|
||||||
matterMessage.UserName = nick
|
matterMessage.UserName = nick
|
||||||
matterMessage.Text = message
|
matterMessage.Text = message
|
||||||
matterMessage.Type = mtype
|
matterMessage.Type = mtype
|
||||||
@ -95,7 +97,7 @@ func (b *Bridge) handleMatter() {
|
|||||||
b.i.SendRaw("NAMES " + b.Config.IRC.Channel)
|
b.i.SendRaw("NAMES " + b.Config.IRC.Channel)
|
||||||
case "!gif":
|
case "!gif":
|
||||||
message.Text = b.giphyRandom(strings.Fields(strings.Replace(message.Text, "!gif ", "", 1)))
|
message.Text = b.giphyRandom(strings.Fields(strings.Replace(message.Text, "!gif ", "", 1)))
|
||||||
b.Send(b.Config.IRC.Nick, message.Text)
|
b.Send(b.Config.IRC.Nick, message.Text, b.Config.Mattermost.Channel)
|
||||||
}
|
}
|
||||||
texts := strings.Split(message.Text, "\n")
|
texts := strings.Split(message.Text, "\n")
|
||||||
for _, text := range texts {
|
for _, text := range texts {
|
||||||
|
Loading…
Reference in New Issue
Block a user