From 33db22f4bad0174a9e17dea73e4d053edd11ec12 Mon Sep 17 00:00:00 2001 From: Owyn Date: Sat, 12 Feb 2022 21:36:14 +0300 Subject: [PATCH] Better scalability for filter examples (#632) --- resources/docs/Documentation.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/resources/docs/Documentation.md b/resources/docs/Documentation.md index 1db5761ee..21f1bccb0 100644 --- a/resources/docs/Documentation.md +++ b/resources/docs/Documentation.md @@ -172,10 +172,13 @@ Note that `MessageObject` attributes which can be synchronized with service are | Method | `runExecutableGetOutput(String, String[])` | `String` | `utils.runExecutableGetOutput('cmd.exe', ['/c', 'dir'])` | Launches external executable with optional parameters, reads its standard output and returns the output when executable finishes. #### Examples -Accept only messages/articles with title containing "Series Name" in it: +Accept only messages/articles with title containing "Series Name" or "Another series" in it (whitelist): ```js +var whitelist = [ + 'Series Name', 'Another series' +]; function filterMessage() { - if (msg.title.indexOf('Series Name') != -1) { + if (whitelist.some(i => msg.title.indexOf(i) != -1)) { return MessageObject.Accept; } else { return MessageObject.Ignore; @@ -183,13 +186,16 @@ function filterMessage() { } ``` -Accept only messages/articles with title NOT containing "Other Series Name" or "Some other title" in it: +Accept only messages/articles with title NOT containing "Other Series Name" or "Some other title" in it (blacklist): ```js +var blacklist = [ + 'Other Series Name', 'Some other title' +]; function filterMessage() { - if (msg.title.indexOf('Other Series Name') == -1 && msg.title.indexOf('Some other title') == -1) { - return MessageObject.Accept; - } else { + if (blacklist.some(i => msg.title.indexOf(i) != -1)) { return MessageObject.Ignore; + } else { + return MessageObject.Accept; } } ```