Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
724 stars 143 forks source link

how to stop or remove Menu #202

Closed natget21 closed 6 years ago

natget21 commented 6 years ago

hello can anyone help me with removing keyboard / menu after the user has selected the option?

$.runMenu({ message: 'yes or no:', layout: [ 2,], 'yes': () => { }, 'no': () => { }, });

this will show the keyboard on telegram but after the user response i want to remove it not hide it but remove how can i do that?

Thanks,

rotimi-best commented 6 years ago

I also have this issue. Help would be highly appreciated.

natget21 commented 6 years ago

I also have this issue. Help would be highly appreciated.

@Rotimi-Best hello i shifted to https://telegraf.js.org/ which is really great and if you are about to start just like i was i would recommend you use that cause it is maintained regularly and has great community to help you out ;)

rotimi-best commented 6 years ago

@natget21 I actually found the solution. I checked telegraf, I sincerely didn't like it, the documentation wasn't clear to me (many things were not explained well with examples), and many of the other tutorials were confusing, there were just different approach to doing the same thing, this got me confused and other things. I personally love this module, it has all I would need and doesn't give me any errors at the moment.

This was how I solved it.

$.runMenu({
    message: 'Select:',
    options: {
        parse_mode: 'Markdown' // in options field you can pass some additional data, like parse_mode
    },
    'Exit': {
        message: 'Do you realy want to exit?',
        resizeKeyboard: true,
        'Yes': () =>  { // remove keyboard when you send message
               $.sendMessage('Alright', { reply_markup: JSON.stringify({ remove_keyboard: true }) }) },
        'No': () => { $.sendMessage('Exiting', { reply_markup: JSON.stringify({ remove_keyboard: true }) }) }
    }
})