Inline bot

#11 · closed · 1 comments

View on GitHub ↗

okyrylchuk

Could you please make a bot as [inline](https://core.telegram.org/bots/inline)?

Comments

EXL

@okyrylchuk, try this simple example: ``` javascript var TelegramBot = require('node-telegram-bot-api'); var token = 'WRITE_YOUR_TOKEN_HERE'; var botOptions = { polling: true }; var bot = new TelegramBot(token, botOptions); bot.getMe().then(function(me) { console.log('Hello! My name is %s!', me.first_name); console.log('My id is %s.', me.id); console.log('And my username is @%s.', me.username); }); bot.on('inline_query', function(msg) { var q_id = msg.id; var q_query = msg.query; // var q_from = msg.from; // var q_offset = msg.offset; var results = []; for (var i = 0; i < 10; ++i) { var InlineQueryResultPhoto = { 'type': 'photo', 'photo_url': 'http://exlmoto.ru/wp-content/Images/E770vE1000/large/' + q_query + '.jpg', 'thumb_url': 'http://exlmoto.ru/wp-content/Images/E770vE1000/' + q_query + '.jpg', 'id': '287878416582808857/' + i, 'photo_width': 48, 'photo_height': 48 }; results.push(InlineQueryResultPhoto); } bot.answerInlineQuery(q_id, results); }); bot.on('chosen_inline_result', function(msg) { console.log('Chosen:' + msg); }); ``` Demonstration: ![Inline Bot Screen](http://i.imgur.com/VZDne7l.png) And read this: http://github.com/yagop/node-telegram-bot-api#events http://github.com/yagop/node-telegram-bot-api#telegrambotanswerinlinequeryinlinequeryid-results-options--promise http://core.telegram.org/bots/inline http://core.telegram.org/bots/api#inline-mode http://core.telegram.org/bots/api#inlinequeryresultphoto