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.
|
||||
|
||||
#### 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;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue