Merge 23f0434954 into 38fce68609
This commit is contained in:
@@ -13,7 +13,9 @@ type Config struct {
|
|||||||
Server string
|
Server string
|
||||||
Port int
|
Port int
|
||||||
Nick string
|
Nick string
|
||||||
|
Password string
|
||||||
Channel string
|
Channel string
|
||||||
|
SendMUserName bool
|
||||||
}
|
}
|
||||||
Mattermost struct {
|
Mattermost struct {
|
||||||
URL string
|
URL string
|
||||||
@@ -22,6 +24,7 @@ type Config struct {
|
|||||||
Token string
|
Token string
|
||||||
IconURL string
|
IconURL string
|
||||||
SkipTLSVerify bool
|
SkipTLSVerify bool
|
||||||
|
IrcNickPrefix string
|
||||||
}
|
}
|
||||||
General struct {
|
General struct {
|
||||||
GiphyAPIKey string
|
GiphyAPIKey string
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ UseTLS=false
|
|||||||
SkipTLSVerify=true
|
SkipTLSVerify=true
|
||||||
nick="matterbot"
|
nick="matterbot"
|
||||||
channel="#matterbridge"
|
channel="#matterbridge"
|
||||||
|
password=""
|
||||||
|
SendMUserName=true
|
||||||
|
|
||||||
[mattermost]
|
[mattermost]
|
||||||
url="http://yourdomain/hooks/yourhookkey"
|
url="http://yourdomain/hooks/yourhookkey"
|
||||||
@@ -13,6 +15,7 @@ showjoinpart=true
|
|||||||
#token=yourtokenfrommattermost
|
#token=yourtokenfrommattermost
|
||||||
IconURL="http://youricon.png"
|
IconURL="http://youricon.png"
|
||||||
#SkipTLSVerify=true
|
#SkipTLSVerify=true
|
||||||
|
IrcNickPrefix="irc-"
|
||||||
|
|
||||||
[general]
|
[general]
|
||||||
GiphyAPIKey=dc6zaTOxFJmzC
|
GiphyAPIKey=dc6zaTOxFJmzC
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ func NewBridge(name string, config *Config) *Bridge {
|
|||||||
func (b *Bridge) createIRC(name string) *irc.Connection {
|
func (b *Bridge) createIRC(name string) *irc.Connection {
|
||||||
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
||||||
i.UseTLS = b.Config.IRC.UseTLS
|
i.UseTLS = b.Config.IRC.UseTLS
|
||||||
|
if b.Config.IRC.Password != "" { i.Password = b.Config.IRC.Password }
|
||||||
i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.IRC.SkipTLSVerify}
|
i.TLSConfig = &tls.Config{InsecureSkipVerify: b.Config.IRC.SkipTLSVerify}
|
||||||
i.Connect(b.Config.IRC.Server + ":" + strconv.Itoa(b.Config.IRC.Port))
|
i.Connect(b.Config.IRC.Server + ":" + strconv.Itoa(b.Config.IRC.Port))
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
@@ -52,11 +53,11 @@ 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(b.Config.Mattermost.IrcNickPrefix+event.Nick, "PRIV: "+msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
func (b *Bridge) handleJoinPart(event *irc.Event) {
|
||||||
b.Send(b.Config.IRC.Nick, "irc-"+event.Nick+" "+strings.ToLower(event.Code)+"s "+event.Message())
|
b.Send(b.Config.IRC.Nick, b.Config.Mattermost.IrcNickPrefix+event.Nick+" "+strings.ToLower(event.Code)+"s "+event.Message())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bridge) handleOther(event *irc.Event) {
|
func (b *Bridge) handleOther(event *irc.Event) {
|
||||||
@@ -89,10 +90,19 @@ func (b *Bridge) handleMatter() {
|
|||||||
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)
|
||||||
|
case "!priv":
|
||||||
|
who := strings.Fields(message.Text)[1]
|
||||||
|
msg := strings.Fields(message.Text)[2:]
|
||||||
|
b.i.Privmsg(who, strings.Join(msg, " "))
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
texts := strings.Split(message.Text, "\n")
|
texts := strings.Split(message.Text, "\n")
|
||||||
for _, text := range texts {
|
for _, text := range texts {
|
||||||
b.i.Privmsg(b.Config.IRC.Channel, message.UserName+": "+text)
|
if (b.Config.IRC.SendMUserName) {
|
||||||
|
b.i.Privmsg(b.Config.IRC.Channel, message.UserName+": "+text)
|
||||||
|
} else {
|
||||||
|
b.i.Privmsg(b.Config.IRC.Channel, text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user