Naltox / telegram-node-bot

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

runInlineMenu issue #85

Closed edakhmetgareev closed 8 years ago

edakhmetgareev commented 8 years ago

Hello,

Maybe I use this method do not correctly, but I think it should be refactored. If I use readme example for send inline keyboard, then it work ok only for sendMessage $.runInlineMenu({ layout: 2 method: 'sendMessage' params: ['text'] menu: [...] }); If I want to edit inline menu message, then I should send a prevMessage as second parameter. In this case I have an error in Scope.js on 408 line: params[0].chat_id = prevMessage.chat.id params[0].message_id = prevMessage.messageId because params[0] is not an object, it is a string (params: ['text']). Therefore I have to do next trick: $.runInlineMenu({layout: 1, method: 'sendMessage', menu: menu, message: 'Text', // Pass additional param instead of `params: [text] params: prevMessage == undefined ? ['Text'] : [], // Skip this line for bypass Scope.js error on 408 line }, prevMessage)

If I am wrong, could you explain me how use correctly this method for sending and editing inline keyboard message?

Thank you.

VitaliyR commented 8 years ago

@aed86 just save somewhere 2nd parameter of callback query response

callback: (cb, msg) => {
  $.api.answerCallbackQuery(cb.id);
  $.userSesion.msg = msg; // or kind of it
  const otherMenu = {
    method: 'sendMessage',
    params: [msg], // hello there
    message: 'My new message',
    menu: [ /* ... */ ]
  };
  $.runInlineMenu(menu, msg);
}
Naltox commented 8 years ago

@aed86

Hi! @VitaliyR right, but you can also use submenus from docs: https://github.com/Naltox/telegram-node-bot#inline-menu

Qurbonov commented 6 years ago

Hello, I am using 'extension-telegram-node-bot', now problem is { text: 'telegram', url: 'telegram.org', callback: (callbackQuery, message) => { console.log('Buy') } }

url doesn't work

rotimi-best commented 5 years ago

My use case is I don't want to create a new menu, I want to update the old one, just like is used in this bot