forked from mullwar/telebot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinline-query.js
49 lines (38 loc) · 1.09 KB
/
inline-query.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
To enable this option, send the /setinline command to @BotFather and provide
the placeholder text that the user will see in the input field after typing
your bot’s name.
*/
'use strict';
const TeleBot = require('../');
const bot = new TeleBot('-PASTEYOURTELEGRAMBOTAPITOKENHERE-');
// On inline query
bot.on('inlineQuery', msg => {
let query = msg.query;
console.log(`inline query: ${ query }`);
// Create a new answer list object
const answers = bot.answerList(msg.id, { cacheTime: 60 });
// Article
answers.addArticle({
id: 'query',
title: 'Inline Title',
description: `Your query: ${ query }`,
message_text: 'Click!'
});
// Photo
answers.addPhoto({
id: 'photo',
caption: 'Telegram logo.',
photo_url: 'https://telegram.org/img/t_logo.png',
thumb_url: 'https://telegram.org/img/t_logo.png'
});
// Gif
answers.addGif({
id: 'gif',
gif_url: 'https://telegram.org/img/tl_card_wecandoit.gif',
thumb_url: 'https://telegram.org/img/tl_card_wecandoit.gif'
});
// Send answers
return bot.answerQuery(answers);
});
bot.connect();