aiogram/examples/inline_bot.py

26 lines
737 B
Python
Raw Normal View History

2017-07-19 02:56:28 +03:00
import asyncio
import logging
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
2017-11-19 01:05:50 +02:00
from aiogram.utils.executor import start_pooling
2017-07-19 02:56:28 +03:00
API_TOKEN = 'BOT TOKEN HERE'
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
bot = Bot(token=API_TOKEN, loop=loop)
dp = Dispatcher(bot)
@dp.inline_handler()
async def inline_echo(inline_query: types.InlineQuery):
2017-11-19 01:05:50 +02:00
item = types.InlineQueryResultArticle(id='1', title='echo',
input_message_content=types.InputTextMessageContent(inline_query.query))
2017-07-19 02:56:28 +03:00
await bot.answer_inline_query(inline_query.id, results=[item], cache_time=1)
if __name__ == '__main__':
2017-11-19 01:05:50 +02:00
start_pooling(dp, loop=loop, skip_updates=True)