SerjoPepper / bot-brother

Node.js framework for telegram bots
214 stars 27 forks source link

Inline keyboard doesn't work #11

Open lsndr opened 7 years ago

lsndr commented 7 years ago

Использование context.inlineKeyboard не дает никаких результатов, кроме ошибки в консоле сразу же после отправки сообщения UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: message can't be edited"} (node:16320) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code

Если попытаться отправить клавиатура через параметр reply_markup, то она появляется в сообщении, но после нажатия появляется ошибка Unhandled rejection SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at CommandHandler.handle (D:\nodejs\vkm2\node_modules\bot-brother\lib\command-handler.js:211:30) at D:\nodejs\vkm2\node_modules\bot-brother\lib\bot.js:349:42 at tryCatcher (D:\nodejs\vkm2\node_modules\bluebird\js\main\util.js:26:23) at Promise._settlePromiseFromHandler (D:\nodejs\vkm2\node_modules\bluebird\js\main\promise.js:510:31) at Promise._settlePromiseAt (D:\nodejs\vkm2\node_modules\bluebird\js\main\promise.js:584:18) at Promise._settlePromises (D:\nodejs\vkm2\node_modules\bluebird\js\main\promise.js:700:14) at Async._drainQueue (D:\nodejs\vkm2\node_modules\bluebird\js\main\async.js:123:16) at Async._drainQueues (D:\nodejs\vkm2\node_modules\bluebird\js\main\async.js:133:10) at Immediate.Async.drainQueues (D:\nodejs\vkm2\node_modules\bluebird\js\main\async.js:15:14) at runCallback (timers.js:800:20) at tryOnImmediate (timers.js:762:5) at processImmediate [as _immediateCallback] (timers.js:733:5)

Пример из readme также нерабочий. Тут даже нет метода отправки сообщения с inlineKeyboard `bot.bommand('inline_example') .use('before', function (ctx) { // set any your data to callbackData. // IMPORTANT! Try to fit your data in 60 chars, because Telegram has limit for inline buttons ctx.inlineKeyboard([[ {'Option 1': {callbackData: {myVar: 1}, isShown: function (ctx) { return ctx.callbackData.myVar != 1 }}}, {'Option 2': {callbackData: {myVar: 2}, isShown: function (ctx) { return ctx.callbackData.myVar != 2 }}}, // use syntax: // 'callback${{CALLBACK_COMMAND}}' (or 'cb${{CALLBACK_COMMAND}}') // 'invoke${{INVOKE_COMMAND}}' // to go to another command {'Option 3': {go: 'cb$go_inline_example'}}, {'Option 4': {go: 'invoke$go_inline_example'}} ]]) }) .answer(function (ctx) { ctx.sendMessage('Inline data example') }) .callback(function (ctx) { ctx.updateText('Callback data: ' + ctx.callbackData.myVar) })

bot.command('go_inline_example') .invoke(function (ctx) { ctx.sendMessage('This command invoked directly') }) .callback(function (ctx) { ctx.updateText('Command invoked via callback! type /inline_example to start again') })`

mhs-mlkn commented 7 years ago

i have the same problem did you managed to solve this problem?

lsndr commented 7 years ago

Yes. I switched to https://github.com/telegraf/telegraf

R.I.P. bot-brother