mullwar / telebot

The easy way to write Telegram bots in Node.js
https://www.npmjs.com/package/telebot
MIT License
1.48k stars 270 forks source link

TeleBot event catch any command does't works #176

Open rgonzlz opened 4 years ago

rgonzlz commented 4 years ago

Hi!

I have this code:

export const id = 'Test';
export const defaultConfig = { };
export const plugin = (bot: TeleBot, pluginConfig: any) => {

    bot.on('/*', (msg, props) => {

        msg.reply.text(`Hi! Command: ${msg.text}`);

    });

}

Output: image

I checked the code and the problem is in the updates.js file, line 88:

                const eventList = ['/' + match[1]];
                if (!anyEventFlags[1]) {
                    eventList.push(['/*']); // <--- this
                    anyEventFlags[1] = true;
                }

Is an array, I edit to remove it and replace for a string:

                const eventList = ['/' + match[1]];
                if (!anyEventFlags[1]) {
                    eventList.push('/*'); 
                    anyEventFlags[1] = true;
                }

Output: image

Is correct this fix?

Thanks.