Add passive only matches

This commit is contained in:
Federico Terzi 2020-01-20 00:03:23 +01:00
parent e2c98284b6
commit 6e03e7e8e4
2 changed files with 12 additions and 1 deletions

View File

@ -32,6 +32,7 @@ pub struct Match {
pub trigger: String,
pub content: MatchContentType,
pub word: bool,
pub passive_only: bool,
// Automatically calculated from the trigger, used by the matcher to check for correspondences.
#[serde(skip_serializing)]
@ -133,7 +134,8 @@ impl<'a> From<&'a AutoMatch> for Match{
Self {
trigger: other.trigger.clone(),
content,
word: other.word.clone(),
word: other.word,
passive_only: other.passive_only,
_trigger_sequence: trigger_sequence,
}
}
@ -155,10 +157,14 @@ struct AutoMatch {
#[serde(default = "default_word")]
pub word: bool,
#[serde(default = "default_passive_only")]
pub passive_only: bool,
}
fn default_vars() -> Vec<MatchVariable> {Vec::new()}
fn default_word() -> bool {false}
fn default_passive_only() -> bool {false}
fn default_replace() -> Option<String> {None}
fn default_image_path() -> Option<String> {None}

View File

@ -114,6 +114,11 @@ impl <'a, R: MatchReceiver, M: ConfigManager<'a>> super::Matcher for ScrollingMa
let new_matches: Vec<MatchEntry> = active_config.matches.iter()
.filter(|&x| {
// only active-enabled matches are considered
if x.passive_only {
return false;
}
let mut result = Self::is_matching(x, c, 0, is_current_word_separator);
if x.word {