Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to use the decorator @TelegramActionHandler without message #3

Closed
evilsprut opened this issue Jan 12, 2020 · 3 comments · Fixed by #32
Closed

Make it possible to use the decorator @TelegramActionHandler without message #3

evilsprut opened this issue Jan 12, 2020 · 3 comments · Fixed by #32
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@evilsprut
Copy link
Owner

This code doesn't work:

@TelegramActionHandler({ message: '' })
@evilsprut evilsprut added bug Something isn't working enhancement New feature or request labels Jan 12, 2020
@evilsprut evilsprut self-assigned this Jan 12, 2020
@edgesite
Copy link

edgesite commented Feb 2, 2020

The empty string is false value so handlers.filter(({ config }) => config.message) filtered out {message: ''}. Use following code instead of
https://github.com/bukhalo/nestjs-telegraf/blob/cef3796f01c5086f6e8438876de5e828056c8056/lib/telegraf.service.ts#L99 may solve that:

private setupOnMessage(handlers: Handler[]): void {
    const onMessageHandlers = handlers.filter(({ config }) => config.message !== undefined)

    onMessageHandlers.forEach(handler => {
      if (handler.config.message) {
        this.bot.hears(handler.config.message, this.adoptHandle(handler))
      } else {
        this.bot.on('message', this.adoptHandle(handler);
      }
    });
  }

@evilsprut
Copy link
Owner Author

@all-contributors please add @edgesite for code, bug

@allcontributors
Copy link
Contributor

@bukhalo

I've put up a pull request to add @edgesite! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants