diff options
author | Wim <wim@42.be> | 2018-11-25 19:32:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-25 19:32:16 +0100 |
commit | 9f66f93641612028455c43478da2b19e8ee42b8a (patch) | |
tree | 2d604d3b8f4bfba0e5f87c73e55b7474a2d88fb5 | |
parent | 8869e253cad84f504c5b90bfe9256ca8fb4e815c (diff) | |
download | matterbridge-msglm-9f66f93641612028455c43478da2b19e8ee42b8a.tar.gz matterbridge-msglm-9f66f93641612028455c43478da2b19e8ee42b8a.tar.bz2 matterbridge-msglm-9f66f93641612028455c43478da2b19e8ee42b8a.zip |
Add option to send RAW commands after connection (irc). Fixes #490 (#604)
-rw-r--r-- | bridge/config/config.go | 1 | ||||
-rw-r--r-- | bridge/irc/irc.go | 10 | ||||
-rw-r--r-- | matterbridge.toml.sample | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go index 48c36d9d..21010dbf 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -109,6 +109,7 @@ type Protocol struct { ReplaceMessages [][]string // all protocols ReplaceNicks [][]string // all protocols RemoteNickFormat string // all protocols + RunCommands []string // irc Server string // IRC,mattermost,XMPP,discord ShowJoinPart bool // all protocols ShowTopicChange bool // slack diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index eee432b2..1e813246 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -365,6 +365,7 @@ func (b *Birc) handleOther(client *girc.Client, event girc.Event) { func (b *Birc) handleOtherAuth(client *girc.Client, event girc.Event) { b.handleNickServ() + b.handleRunCommands() // we are now fully connected b.connected <- nil } @@ -471,6 +472,15 @@ func (b *Birc) formatnicks(nicks []string) string { return strings.Join(nicks, ", ") + " currently on IRC" } +func (b *Birc) handleRunCommands() { + for _, cmd := range b.GetStringSlice("RunCommands") { + if err := b.i.Cmd.SendRaw(cmd); err != nil { + b.Log.Errorf("RunCommands %s failed: %s", cmd, err) + } + time.Sleep(time.Second) + } +} + func (b *Birc) handleNickServ() { if !b.GetBool("UseSASL") && b.GetString("NickServNick") != "" && b.GetString("NickServPassword") != "" { b.Log.Debugf("Sending identify to nickserv %s", b.GetString("NickServNick")) diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 5e7be29e..b51f351b 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -96,6 +96,11 @@ RejoinDelay=0 #Only works in IRC right now. ColorNicks=false +#RunCommands allows you to send RAW irc commands after connection +#Array of strings +#OPTIONAL (default empty) +RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something"] + #Nicks you want to ignore. #Messages from those users will not be sent to other bridges. #OPTIONAL |