2016-06-30 13 views
1

私は電報のボットにnode_telegram_bot_apiを使用します。私は、インラインキーボードボタンを作成します。テレグラムのinlineKeyboardは機能しません

var bot = new loader.Bot(config.botToken,{polling:true}); 
var options = { 
     reply_markup: JSON.stringify({ 
      inline_keyboard: [ 
       [{text: 'Some button text 1', callback_data: '1'}], // Clicking will send "1" 
       [{text: 'Some button text 2', callback_data: '2'}], // Clicking will send "2" 
       [{text: 'Some button text 3', callback_data: '3'}] // Clicking will send "3" 
      ] 
     }) 
    }; 

    bot.sendMessage(msg.from.id, "Click a button to display data", options); 

とボタンをクリックして聞くために私はcallback_query機能に次のように語った。

bot.on('callback_query', function(msg) { 
    var user = msg.from.id; 
    var data = msg.data; 
    bot.sendMessage(msg.from.id, "You clicked button with data '"+ data +"'"); 
}); 

ボタンをクリックした後、この機能が実装されていません。 私を助けることができますか?

+0

JSON.stringifyは必要ありません。とにかく、これは必要ない場合でも動作するように見えるため、問題は解決しません。 – jlvaquero

答えて

1

私にとってこのテスト中華鍋:

https://ide.c9.io/jlvaquero/test

は、プロジェクトとそれを比較してみてください。私の2セントはあなたのnode_telegram_bot_apiバージョンです。

+0

私は 'c9'にアクセスできません。あなたのコードを' jsbin.com'に入れられますか? –

+0

ここにあります:http://jsbin.com/noqepukizo/edit?js,console – jlvaquero

+0

あなたの問題を発見しましたか?同様の問題を抱えている他の人々への将来の参照のために、投稿して修正を行ってください。 – jlvaquero

関連する問題