question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filters cannot filter out replies as expect

See original GitHub issue

Using filter to filter out replies as wiki filter example to filter out replies but failed.

Expected Behavior

using the following script:

+ * 
- {^test(true)} how are you
- hello

test() as follows:

exports.test = async function test(cb) {
    const content = this.message.original
    console.log(content)
    if (content === 'test') {
        cb(null, true)
    } else {
        cb(null, false)
    }
}

when I type test I wish it will return how are you

Current Behavior

When I type test it occurs the following error

/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.0.2@ss-parser/lib/wordnet.js:28
  throw err;
  ^

TypeError: cb is not a function
    at Object.test (/Users/lijiarui/Dropbox/git/superscript/myBotName/plugins/index.plugins.js:46:9)
    at /Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/utils.js:114:29
    at new Promise (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.0.22.2@es6-shim/es6-shim.js:1452:9)
    at Object.<anonymous> (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/utils.js:109:12)
    at Generator.next (<anonymous>)
    at step (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/utils.js:25:191)
    at /Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/utils.js:25:437
    at new Promise (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.0.22.2@es6-shim/es6-shim.js:1452:9)
    at Object.<anonymous> (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/utils.js:25:99)
    at Object.runPluginFunc (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/utils.js:119:17)
    at /Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/getReply/filterFunction.js:52:47
    at Generator.next (<anonymous>)
    at step (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/getReply/filterFunction.js:27:191)
    at /Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.1.1.0@superscript/lib/bot/getReply/filterFunction.js:27:361
    at /Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.0.22.2@es6-shim/es6-shim.js:1409:18
    at Immediate.<anonymous> (/Users/lijiarui/Dropbox/git/superscript/myBotName/node_modules/.0.22.2@es6-shim/es6-shim.js:1382:26)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

Possible Solution

When I try the following script: (change - {^test(true)} how are you to - {^test()} how are you)

+ * 
- {^test()} how are you
- hello

It works well.

So I feel confused about this, because wiki shows as follows, it use {^functionX(true)} instead of {^functionX()}

+ i am *1
- {^functionX(true)}  Yes, you are <cap>.
- {^functionX(false)} You’re lying, you’re not <cap>!

Need some help, Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
duffrindcommented, Jun 5, 2017

Changing the plugin to:

exports.test = function(bool, cb) {
    const content = this.message.original
    if (content === 'test') {
        cb(null, bool === 'true')
    } else {
        cb(null, bool === 'false')
    }
}

and the main.ss file to:

+ *
- {^test("true")} yes it is test.
- {^test("false")} no, you are wrong.

Makes filtering work again.

0reactions
lijiaruicommented, Jun 7, 2017

@duffrind Oh! Thanks, it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Analytics Filter Not Working? (Here's How To Fix It)
Incorrect RegEx. Another reason your Filter may not be working is that you haven't formatted it correctly. For example, when you're filtering ...
Read more >
Filters not working as expected - WordPress.org
Hi There, The plugin is not working as expected. On a category page, the tag filter does not filter by the tags available...
Read more >
Filtering Responses - Qualtrics
Your filter field would be your satisfaction question, your operator would be “Not equal to,” and your operand would be “extremely satisfied.” a...
Read more >
Solved: Measure not filtering as expected - Microsoft Power BI ...
I altered your measure a little bit, and it works! This is the measure I ended up using: KPI = CALCULATE(( COUNT(Table[Brief Description...
Read more >
About view filters - Analytics Help - Google Support
Use filter verification to make sure your filters are performing as expected before applying them to your incoming data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found