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.

'Unbind' earlier set triggers (telegraf.hears)

See original GitHub issue

As far as I can see it is not possible to override or unbind earlier set telegraf.hears triggers.

For instance if the following code is executed:

        app.hears('test', ({reply}) => {
            return reply("FIRST!");
        });

        app.hears('test', ({reply}) => {
            return reply("SECOND!");
        });

        app.hears('test', ({reply}) => {
            return reply("THIRD!");
        });

If the bot hears test it will always reply with “FIRST!”.

Is there any way to unbind old triggers or to override them?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dotcypresscommented, Oct 31, 2017

@NoahKr as I understood, you want some sort of dynamic text routing. Actually, you can use .hears like that:


function checkAnswer(text) {
   // Naive implementation, replace with any predicate
   return text === '420'
}

bot.hears(checkAnswer, ctx => ctx.reply('Blaze it'))

1reaction
weijinnxcommented, Nov 2, 2017

@NoahKr yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node Telegraf callback button - Stack Overflow
For what we need to pass data to callback button in in simple keyboard (not inline), if thats doesn't matter? Example: const mainMenuKeyboard...
Read more >
Expand Kubernetes Monitoring with Telegraf Operator
Telegraf Operator then sets the configuration for the entire cluster so your users don't need to worry about configuring a metrics destination ...
Read more >
Build a Telegram Bot using TypeScript, Node.js, and Telegraf ...
I am using a computer with Linux Mint 20.2 and Visual Studio Code 1.61.2 to write the bot. The project will use the...
Read more >
Practical Advice for Auto Setup - GroundWork Support
Reconfiguration as desired (updating the instructions file as needed; dropping a new trigger file) when the set of services to be monitored on...
Read more >
How to Add a Telegram Bot to Telegram Group (2022 Tutorial)
So the first step we need to do, is create our own Telegram group. ... in “Disable” or click on the button, you...
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