IITC.comm.declarativeMessageFilter

Declarative message filter for COMM API

Methods

static addRule(id, rule)

Adds a new filtering rule with a given ID.

Parameters:
Name Type Description
id string

The ID of the rule to add.

rule Object

The rule to add.

Examples
// Hide all messages from Resistance team
IITC.comm.declarativeMessageFilter.addRule({
  id: "hideResistanceTeam1",
  conditions: [
    { field: "player.team", value: "Resistance" },
  ]
});
// Hide all messages except those from the Resistance team using the inverted rule
IITC.comm.declarativeMessageFilter.addRule({
  id: "hideExceptResistanceTeam",
  conditions: [
    { field: "player.team", value: "Resistance", invert: true },
  ]
});
// Hide messages that look like spam
IITC.comm.declarativeMessageFilter.addRule({
  id: "hideSpam",
  conditions: [
    { field: "markup[4][1].plain", condition: /ingress-(shop|store)|(store|shop)-ingress/i },
  ]
});

static filterMessage(message) → {boolean}

Checks if a message matches any of the current filtering rules.

Parameters:
Name Type Description
message Object

The message to check.

Returns:
boolean -

True if the message matches any rule, false otherwise.

static getAllRules() → {Object}

Gets all current filtering rules.

Returns:
Object -

The current set of filtering rules.

static getMessageValueByPath(object, path) → {*}

Extracts the value from the message object by a given path.

Parameters:
Name Type Description
object Object

The message object.

path String

Path to the property in dot notation.

Returns:
* -

The value of the property at the specified path or undefined if the path is not valid.

static getRuleById(id) → {Object|null}

Gets a rule by its ID.

Parameters:
Name Type Description
id string

The ID of the rule to get.

Returns:
Object | null -

The rule object, or null if not found.

static matchesRule(message, rule) → {boolean}

Checks if the message matches a single rule.

Parameters:
Name Type Description
message Object

The message to check.

rule Object

The rule to match against.

Returns:
boolean -

True if the message matches the rule, false otherwise.

static removeRule(id)

Removes a filtering rule by its ID.

Parameters:
Name Type Description
id string

The ID of the rule to remove.