Merge 23f0434954 into 38fce68609
This commit is contained in:
@@ -13,7 +13,9 @@ type Config struct {
|
||||
Server string
|
||||
Port int
|
||||
Nick string
|
||||
Password string
|
||||
Channel string
|
||||
SendMUserName bool
|
||||
}
|
||||
Mattermost struct {
|
||||
URL string
|
||||
@@ -22,6 +24,7 @@ type Config struct {
|
||||
Token string
|
||||
IconURL string
|
||||
SkipTLSVerify bool
|
||||
IrcNickPrefix string
|
||||
}
|
||||
General struct {
|
||||
GiphyAPIKey string
|
||||
|
||||
@@ -5,6 +5,8 @@ UseTLS=false
|
||||
SkipTLSVerify=true
|
||||
nick="matterbot"
|
||||
channel="#matterbridge"
|
||||
password=""
|
||||
SendMUserName=true
|
||||
|
||||
[mattermost]
|
||||
url="http://yourdomain/hooks/yourhookkey"
|
||||
@@ -13,6 +15,7 @@ showjoinpart=true
|
||||
#token=yourtokenfrommattermost
|
||||
IconURL="http://youricon.png"
|
||||
#SkipTLSVerify=true
|
||||
IrcNickPrefix="irc-"
|
||||
|
||||
[general]
|
||||
GiphyAPIKey=dc6zaTOxFJmzC
|
||||
|
||||
@@ -31,6 +31,7 @@ func NewBridge(name string, config *Config) *Bridge {
|
||||
func (b *Bridge) createIRC(name string) *irc.Connection {
|
||||
i := irc.IRC(b.Config.IRC.Nick, b.Config.IRC.Nick)
|
||||
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.Connect(b.Config.IRC.Server + ":" + strconv.Itoa(b.Config.IRC.Port))
|
||||
time.Sleep(time.Second)
|
||||
@@ -52,11 +53,11 @@ func (b *Bridge) handlePrivMsg(event *irc.Event) {
|
||||
msg = event.Nick + " "
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
@@ -89,10 +90,19 @@ func (b *Bridge) handleMatter() {
|
||||
case "!gif":
|
||||
message.Text = b.giphyRandom(strings.Fields(strings.Replace(message.Text, "!gif ", "", 1)))
|
||||
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")
|
||||
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