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

Comments

Projects
None yet
2 participants
@okyrylchuk
Copy link

okyrylchuk commented Mar 16, 2016

Could you please make a bot as inline?

@EXL

This comment has been minimized.

Copy link
Owner

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

@EXL EXL closed this Mar 17, 2016

@EXL EXL referenced this issue Mar 17, 2016

Closed

inlinePhoto example? #84

EXL added a commit that referenced this issue Jul 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment