My buttons dont work on first tap after first command is executed. I have to tap twice to get Controllers working. E.g. after /start is executed I have to tap twice on button 'Русский язык', to get .when(new TextCommand('Русский язык', 'mainPageRuCommand'), new MainRuController()) working. What is wrong with my code?
My buttons dont work on first tap after first command is executed. I have to tap twice to get Controllers working. E.g. after /start is executed I have to tap twice on button 'Русский язык', to get .when(new TextCommand('Русский язык', 'mainPageRuCommand'), new MainRuController()) working. What is wrong with my code?
`class LanguageController extends TelegramBaseController { languageHandler($) { $.runMenu({ options: {parse_mode: 'Markdown'}, message: 'Выберите:', layout: 1, 'Русский язык 🇷🇺': () => {}, 'Английский язык': () => {}, }); } get routes() { return { 'languageCommand': 'languageHandler' }; } };
class MainRuController extends TelegramBaseController { mainPageRuHandler($) { $.runMenu({ message: 'Выберите раздел', layout: 2, 'Фотогалерея': () => {}, 'Меню': () => {}, 'О нас': () => {}, 'Видео': () => {}, 'Контакты': () => {}, 'Доставка': () => {}, 'Заказать столик': () => {}, 'Конкурсы': () => {}, }); } get routes() { console.log('s'); return { 'mainPageRuCommand': 'mainPageRuHandler' }; } };
class OtherwiseController extends TelegramBaseController { handle($) { $.sendMessage('Я вас не понимаю'); } };
tg.router.when(new TextCommand('start', 'languageCommand'), new LanguageController()) .when(new TextCommand('Русский язык', 'mainPageRuCommand'), new MainRuController()) .when(new TextCommand('О нас', 'aboutCommand'), new AboutController()) .when(new TextCommand('Контакты', 'contactCommand'), new ContactsController()) .otherwise(new OtherwiseController());`