Moved nosync message drop into gateway logic.
This commit is contained in:
parent
fa2e31ce51
commit
2e3d90ef64
@ -266,15 +266,12 @@ var (
|
|||||||
channelRE = regexp.MustCompile(`<#[a-zA-Z0-9]+\|(.+?)>`)
|
channelRE = regexp.MustCompile(`<#[a-zA-Z0-9]+\|(.+?)>`)
|
||||||
variableRE = regexp.MustCompile(`<!((?:subteam\^)?[a-zA-Z0-9]+)(?:\|@?(.+?))?>`)
|
variableRE = regexp.MustCompile(`<!((?:subteam\^)?[a-zA-Z0-9]+)(?:\|@?(.+?))?>`)
|
||||||
urlRE = regexp.MustCompile(`<(.*?)(\|.*?)?>`)
|
urlRE = regexp.MustCompile(`<(.*?)(\|.*?)?>`)
|
||||||
topicOrPurposeRE = regexp.MustCompile(`(?s)^@.+ set the channel (topic|purpose): (.+?)(\[nosync\])?$`)
|
topicOrPurposeRE = regexp.MustCompile(`(?s)^@.+ set the channel (topic|purpose): (.+?)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *Bslack) extractTopicOrPurpose(text string) (updateType string, extracted string) {
|
func (b *Bslack) extractTopicOrPurpose(text string) (updateType string, extracted string) {
|
||||||
r := topicOrPurposeRE.FindStringSubmatch(text)
|
r := topicOrPurposeRE.FindStringSubmatch(text)
|
||||||
updateType, extracted, noSync := r[1], r[2], r[3]
|
updateType, extracted = r[1], r[2]
|
||||||
if noSync != "" {
|
|
||||||
return "nosync", ""
|
|
||||||
}
|
|
||||||
return updateType, extracted
|
return updateType, extracted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,8 +293,6 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
b.rtm.SetPurposeOfConversation(channelInfo.ID, text)
|
b.rtm.SetPurposeOfConversation(channelInfo.ID, text)
|
||||||
case "nosync":
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
@ -269,8 +269,16 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
|
|||||||
|
|
||||||
// only relay topic change when configured
|
// only relay topic change when configured
|
||||||
if msg.Event == config.EventTopicChange && !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
|
if msg.Event == config.EventTopicChange && !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
|
||||||
|
// don't relay topic/purpose change if disabled
|
||||||
|
if !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
|
||||||
return brMsgIDs
|
return brMsgIDs
|
||||||
}
|
}
|
||||||
|
// don't relay topic/purpose update if sync is enabled, but msg marked as nosync
|
||||||
|
if gw.Bridges[dest.Account].GetBool("SyncTopicChange") && strings.HasSuffix(msg.Text, "[nosync]") {
|
||||||
|
return brMsgIDs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// broadcast to every out channel (irc QUIT)
|
// broadcast to every out channel (irc QUIT)
|
||||||
if msg.Channel == "" && msg.Event != config.EventJoinLeave {
|
if msg.Channel == "" && msg.Event != config.EventJoinLeave {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user