Better scalability for filter examples (#632)
This commit is contained in:
parent
4ec98eb322
commit
33db22f4ba
1 changed files with 12 additions and 6 deletions
|
@ -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.
|
| 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
|
#### 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
|
```js
|
||||||
|
var whitelist = [
|
||||||
|
'Series Name', 'Another series'
|
||||||
|
];
|
||||||
function filterMessage() {
|
function filterMessage() {
|
||||||
if (msg.title.indexOf('Series Name') != -1) {
|
if (whitelist.some(i => msg.title.indexOf(i) != -1)) {
|
||||||
return MessageObject.Accept;
|
return MessageObject.Accept;
|
||||||
} else {
|
} else {
|
||||||
return MessageObject.Ignore;
|
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
|
```js
|
||||||
|
var blacklist = [
|
||||||
|
'Other Series Name', 'Some other title'
|
||||||
|
];
|
||||||
function filterMessage() {
|
function filterMessage() {
|
||||||
if (msg.title.indexOf('Other Series Name') == -1 && msg.title.indexOf('Some other title') == -1) {
|
if (blacklist.some(i => msg.title.indexOf(i) != -1)) {
|
||||||
return MessageObject.Accept;
|
|
||||||
} else {
|
|
||||||
return MessageObject.Ignore;
|
return MessageObject.Ignore;
|
||||||
|
} else {
|
||||||
|
return MessageObject.Accept;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue