Naltox / telegram-node-bot

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

close runInlineMenu #167

Closed AndryFM closed 7 years ago

AndryFM commented 7 years ago

How close InlineMenu? I tried use "oneTimeKeyboard: true," but its dont do anything

$.runInlineMenu({
    layout: 2, //some layouting here
    method: 'sendMessage', //here you must pass the method name
    params: ['text'], //here you must pass the parameters for that method
    menu: [
        {
            text: 'First Button Text', //text of the button
            callback: (callbackQuery, message) => { //to your callback will be passed callbackQuery and response from method
                console.log(1)
            }
        },
        {
            text: 'Exit',
            message: 'Are you sure?',
            layout: 2,
            oneTimeKeyboard: true,
            menu: [ //Sub menu (current message will be edited)
                {
                    text: 'Yes!',
                    callback: () => {

                    }
                },
                {
                    text: 'No!',
                    callback: () => {

                    }
                }
            ]
        }
    ]
})

and how return back to previous menu lvl? (when im push "No" button - i want see "First Button Text" and "Exit")

AndryFM commented 7 years ago

return to prev lvl i did with wrapping menu in variable and calling it from No callback (if it right)

{
                            text: 'No!',
                            callback: () => {
                                $.runInlineMenu(menu)
                            }
                        }

but how close menu - question still actual ;)

AndryFM commented 7 years ago

I use this way:

{
    text: 'Yes!',
        callback: (callbackQuery, message) => {
            $.api.editMessageText('new text', { chat_id: $.chatId, message_id: message.messageId })
    }
},

if there exists a better way - tell me about it