summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/config/config.go2
-rw-r--r--bridge/irc/irc.go10
-rw-r--r--bridge/slack/handlers.go7
-rw-r--r--bridge/slack/slack.go1
-rw-r--r--gateway/router.go33
-rw-r--r--matterbridge.toml.sample13
6 files changed, 63 insertions, 3 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 064f04a4..21010dbf 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -72,6 +72,7 @@ type Protocol struct {
EditSuffix string // mattermost, slack, discord, telegram, gitter
EditDisable bool // mattermost, slack, discord, telegram, gitter
IconURL string // mattermost, slack
+ IgnoreFailureOnStart bool // general
IgnoreNicks string // all protocols
IgnoreMessages string // all protocols
Jid string // xmpp
@@ -108,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/bridge/slack/handlers.go b/bridge/slack/handlers.go
index a3291c38..035c5af5 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -202,6 +202,13 @@ func (b *Bslack) handleStatusEvent(ev *slack.MessageEvent, rmsg *config.Message)
rmsg.Event = config.EventJoinLeave
case sChannelTopic, sChannelPurpose:
rmsg.Event = config.EventTopicChange
+ case sMessageChanged:
+ rmsg.Text = ev.SubMessage.Text
+ // handle deleted thread starting messages
+ if ev.SubMessage.Text == "This message was deleted." {
+ rmsg.Event = config.EventMsgDelete
+ return true
+ }
case sMessageDeleted:
rmsg.Text = config.EventMsgDelete
rmsg.Event = config.EventMsgDelete
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index ad48edf0..d054ae81 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -48,6 +48,7 @@ const (
sChannelLeave = "channel_leave"
sChannelJoined = "channel_joined"
sMemberJoined = "member_joined_channel"
+ sMessageChanged = "message_changed"
sMessageDeleted = "message_deleted"
sSlackAttachment = "slack_attachment"
sPinnedItem = "pinned_item"
diff --git a/gateway/router.go b/gateway/router.go
index 99b34378..13e8ddd8 100644
--- a/gateway/router.go
+++ b/gateway/router.go
@@ -54,17 +54,46 @@ func (r *Router) Start() error {
flog.Infof("Starting bridge: %s ", br.Account)
err := br.Connect()
if err != nil {
- return fmt.Errorf("Bridge %s failed to start: %v", br.Account, err)
+ e := fmt.Errorf("Bridge %s failed to start: %v", br.Account, err)
+ if r.disableBridge(br, e) {
+ continue
+ }
+ return e
}
err = br.JoinChannels()
if err != nil {
- return fmt.Errorf("Bridge %s failed to join channel: %v", br.Account, err)
+ e := fmt.Errorf("Bridge %s failed to join channel: %v", br.Account, err)
+ if r.disableBridge(br, e) {
+ continue
+ }
+ return e
+ }
+ }
+ // remove unused bridges
+ for _, gw := range r.Gateways {
+ for i, br := range gw.Bridges {
+ if br.Bridger == nil {
+ flog.Errorf("removing failed bridge %s", i)
+ delete(gw.Bridges, i)
+ }
}
}
go r.handleReceive()
return nil
}
+// disableBridge returns true and empties a bridge if we have IgnoreFailureOnStart configured
+// otherwise returns false
+func (r *Router) disableBridge(br *bridge.Bridge, err error) bool {
+ if r.BridgeValues().General.IgnoreFailureOnStart {
+ flog.Error(err)
+ // setting this bridge empty
+ *br = bridge.Bridge{}
+ return true
+ }
+ return false
+}
+
func (r *Router) getBridge(account string) *bridge.Bridge {
for _, gw := range r.Gateways {
if br, ok := gw.Bridges[account]; ok {
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index a4179b02..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
@@ -1303,6 +1308,12 @@ MediaDownloadSize=1000000
#OPTIONAL (default empty)
MediaDownloadBlacklist=[".html$",".htm$"]
+#IgnoreFailureOnStart allows you to ignore failing bridges on startup.
+#Matterbridge will disable the failed bridge and continue with the other ones.
+#Context: https://github.com/42wim/matterbridge/issues/455
+#OPTIONAL (default false)
+IgnoreFailureOnStart=false
+
###################################################################
#Gateway configuration
###################################################################
@@ -1389,7 +1400,7 @@ enable=true
#OPTIONAL - webhookurl only works for discord (it needs a different URL for each cahnnel)
[gateway.inout.options]
- webhookurl=""https://discordapp.com/api/webhooks/123456789123456789/C9WPqExYWONPDZabcdef-def1434FGFjstasJX9pYht73y"
+ webhookurl="https://discordapp.com/api/webhooks/123456789123456789/C9WPqExYWONPDZabcdef-def1434FGFjstasJX9pYht73y"
#API example
#[[gateway.inout]]