Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline bot #11

Closed
okyrylchuk opened this issue Mar 16, 2016 · 1 comment
Closed

Inline bot #11

okyrylchuk opened this issue Mar 16, 2016 · 1 comment

Comments

@okyrylchuk
Copy link

@okyrylchuk okyrylchuk commented Mar 16, 2016

Could you please make a bot as inline?

@EXL
Copy link
Owner

@EXL EXL commented Mar 17, 2016

@okyrylchuk, try this simple example:

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.