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]+\|(.+?)>`)
|
||||
variableRE = regexp.MustCompile(`<!((?:subteam\^)?[a-zA-Z0-9]+)(?:\|@?(.+?))?>`)
|
||||
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) {
|
||||
r := topicOrPurposeRE.FindStringSubmatch(text)
|
||||
updateType, extracted, noSync := r[1], r[2], r[3]
|
||||
if noSync != "" {
|
||||
return "nosync", ""
|
||||
}
|
||||
updateType, extracted = r[1], r[2]
|
||||
return updateType, extracted
|
||||
}
|
||||
|
||||
|
@ -293,8 +293,6 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
|
||||
break
|
||||
}
|
||||
b.rtm.SetPurposeOfConversation(channelInfo.ID, text)
|
||||
case "nosync":
|
||||
break
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
@ -269,9 +269,17 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
|
||||
|
||||
// only relay topic change when configured
|
||||
if msg.Event == config.EventTopicChange && !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
|
||||
return brMsgIDs
|
||||
// don't relay topic/purpose change if disabled
|
||||
if !gw.Bridges[dest.Account].GetBool("ShowTopicChange") {
|
||||
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)
|
||||
if msg.Channel == "" && msg.Event != config.EventJoinLeave {
|
||||
flog.Debug("empty channel")
|
||||
|
Loading…
x
Reference in New Issue
Block a user