Skip to content

Commit

Permalink
Add inline example.
Browse files Browse the repository at this point in the history
  • Loading branch information
JrooTJunior committed Jul 18, 2017
1 parent ce6b1ab commit 1e6aa38
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/inline_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import asyncio
import logging

from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher

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):
item = types.InlineQueryResultArticle('1', 'echo', types.InputTextMessageContent(inline_query.query))
await bot.answer_inline_query(inline_query.id, results=[item], cache_time=1)


if __name__ == '__main__':
try:
loop.run_until_complete(dp.start_pooling())
except KeyboardInterrupt:
loop.stop()

0 comments on commit 1e6aa38

Please sign in to comment.