Vitor Oliveira
Vitor Oliveira

Reputation: 327

Making 1 message handler return the same function to every input

I'm trying to make 1 message handler return one same function to every input it gets.

For example, instead of making these 2 message handler return the same function 'editing' when the input is equal to 'Edit' or 'ADD':

messageHandler(
                    Filters.regex('^(Edit)$'), editing),
messageHandler(
                    Filters.regex('^(ADD)$'), editing)

I wanted to add something like :

 messageHandler(
                        Filters.regex('^(%s)$' %(user_input)), editing)

So everything its typed returns the same function 'editing'

For a more specific case, if necessary, consider this code . If, for some reason, I wanted to add only 1 message handler which returns the function 'start' to everything the user types. How could it be done?

Upvotes: 1

Views: 116

Answers (1)

CallMeStag
CallMeStag

Reputation: 7060

This question has already been answered at the Github discussions of python-telegram-bot where it was pointed out that one can use Filters.text to filter for all incoming text messages. Alternatively, Filters.all would even accept all non-text messages.

Upvotes: 1

Related Questions