|
2 | 2 | import telebot |
3 | 3 | import time |
4 | 4 | import sys |
| 5 | +import logging |
5 | 6 | from telebot import types |
6 | 7 |
|
7 | 8 | API_TOKEN = '<api_token>' |
8 | 9 |
|
9 | 10 | bot = telebot.TeleBot(API_TOKEN) |
| 11 | +telebot.logger.setLevel(logging.DEBUG) |
10 | 12 |
|
11 | 13 |
|
12 | 14 | @bot.inline_handler(lambda query: query.query == 'text') |
13 | | -def query(inline_query): |
| 15 | +def query_text(inline_query): |
14 | 16 | try: |
15 | 17 | r = types.InlineQueryResultArticle('1', 'Result', inline_query.query) |
16 | | - bot.answer_inline_query(inline_query.id, [r]) |
| 18 | + r2 = types.InlineQueryResultArticle('2', 'Result2', inline_query.query) |
| 19 | + bot.answer_inline_query(inline_query.id, [r, r2]) |
| 20 | + except Exception as e: |
| 21 | + print(e) |
| 22 | + |
| 23 | + |
| 24 | +@bot.inline_handler(lambda query: query.query == 'photo') |
| 25 | +def query_photo(inline_query): |
| 26 | + try: |
| 27 | + r = types.InlineQueryResultPhoto('1', |
| 28 | + 'https://raw.githubusercontent.com/eternnoir/pyTelegramBotAPI/master/examples/detailed_example/kitten.jpg', |
| 29 | + thumb_url='https://raw.githubusercontent.com/eternnoir/pyTelegramBotAPI/master/examples/detailed_example/kitten.jpg') |
| 30 | + r2 = types.InlineQueryResultPhoto('2', |
| 31 | + 'https://raw.githubusercontent.com/eternnoir/pyTelegramBotAPI/master/examples/detailed_example/rooster.jpg', |
| 32 | + thumb_url='https://raw.githubusercontent.com/eternnoir/pyTelegramBotAPI/master/examples/detailed_example/rooster.jpg') |
| 33 | + bot.answer_inline_query(inline_query.id, [r, r2]) |
17 | 34 | except Exception as e: |
18 | 35 | print(e) |
19 | 36 |
|
|
0 commit comments