Wednesday, 19 April 2017

JS Slack Notification Filter

Utilizing Slack webhooks and webtask.io I've created a notification filter (based off of a generic script I found online) for Slack that, at this time, filters out messages that contain the string NON-SLA. I'm totally new to JS so getting to this point has all been trial and error. I would like to adjust the script to filter out messages that contain one of any number of strings, but I'm at a roadblock mostly because I'm not familiar with the language and have had 0 luck trying out the various solutions that I've found online.

Here's the current filter for just a single string:

function shouldNotify(data) {
  return !data.text.includes('NON-SLA');
}

This returns TRUE for shouldNotify and the rest of the script pushes the message to the specified channel.

I couldn't find a way to do something similar to this:

return !data.text.includes('one','two','three');

Looked into using an array, but nothing of what I found seemed like it would work with the existing script as a whole and I just simply do not have the time to attempt to rewrite it. Seems that this would be the most efficient and proper way to do it though.

Full script can be seen here.

Any help at all would be greatly appreciated as, again, I'm out of ideas with my limited knowledge of this.

TIA



via Tronyx

No comments:

Post a Comment