3 horizontal lines, burger
3 horizontal lines, burger

3 horizontal lines, burger
Remove all
LOADING ...

Telegram bot in inline mode, an example

Clock
10.01.2025
/
Clock
13.04.2026
/
Icon of app type
Telegram bot
An eye
1216
Hearts
0
Connected dots
0
Connected dots
0
Connected dots
0


[Inline bot]
@joker_gut_bot

Description

An example of telegram bot in inline mode, how it works, code example and ready to talk an online bot
You can try out my telegram bot by this link: @joker_gut_bot

Functionality

Supported commands:
  1. /help - it displays info about each command
  2. /startapp - it displays a single message
  3. @joker_gut_bot greeting (inline) - give you a choice between 3 greetings
  4. @joker_gut_bot memes (inline) - give you a choice between 3 memes

Source code

Here you can find a source code of an inline telegram bot.

main.py file

#!/usr/bin/env python import asyncio import logging import sys import uuid from aiogram import F from aiogram.types import Message, InlineQuery, InlineQueryResultArticle, InputTextMessageContent, InlineQueryResultPhoto from aiogram.filters import Command from aiogram.utils.i18n import gettext as _ from config import bot_dispatcher, bot @bot_dispatcher.inline_query(F.query == "greeting") async def send_greetings(inline_query: InlineQuery): results = [] results.append(InlineQueryResultArticle( id=str(uuid.uuid4()), title=_("Обычное приветствие"), input_message_content=InputTextMessageContent( disable_web_page_preview=True, message_text=_("Приветствую я вас сегодня.") ) )) results.append(InlineQueryResultArticle( id=str(uuid.uuid4()), title=_("Жёсткое приветствие"), input_message_content=InputTextMessageContent( disable_web_page_preview=True, message_text=_("Ну чё, как дела") ) )) results.append(InlineQueryResultArticle( id=str(uuid.uuid4()), title=_("Спокойное приветствие"), input_message_content=InputTextMessageContent( disable_web_page_preview=True, message_text=_("Привет") ) )) await inline_query.answer(results) @bot_dispatcher.inline_query(F.query == "memes") async def send_user_images(inline_query: InlineQuery): results = [] results.append(InlineQueryResultPhoto( id=str(uuid.uuid4()), photo_url="https://wisconsinskydivingcenter.com/wp-content/uploads/2024/05/you-dont-need-a-parachute-to-go-skydiving-meme.jpeg", thumbnail_url="https://wisconsinskydivingcenter.com/wp-content/uploads/2024/05/you-dont-need-a-parachute-to-go-skydiving-meme.jpeg" )) results.append(InlineQueryResultPhoto( id=str(uuid.uuid4()), photo_url="https://jungleroots.com/wp-content/uploads/2022/11/1_OkVxoXBTygSKB8K-zbB7uQ-300x176.jpeg", thumbnail_url="https://jungleroots.com/wp-content/uploads/2022/11/1_OkVxoXBTygSKB8K-zbB7uQ-300x176.jpeg" )) results.append(InlineQueryResultPhoto( id=str(uuid.uuid4()), photo_url="https://livestorm.imgix.net/1127/1651607695-obi-wan-alarm-work-meme.jpeg?h=auto&w=730&fm=jpeg&auto=format&q=90&dpr=1", thumbnail_url="https://livestorm.imgix.net/1127/1651607695-obi-wan-alarm-work-meme.jpeg?h=auto&w=730&fm=jpeg&auto=format&q=90&dpr=1" )) await inline_query.answer(results) @bot_dispatcher.message(Command('help')) async def help(message: Message): await message.answer(_("Этот бот является примером того, как можно реализовать inline функционал для него.")) await message.answer(_("/startapp - запустить приложение")) await message.answer(_("@joker_gut_bot memes - запросить мемы для показа")) await message.answer(_("@joker_gut_bot greeting - запросить ответы по умолчанию")) @bot_dispatcher.message(Command("startapp")) async def start_app(message: Message): await message.answer(_("Этот бот является примером того, как можно реализовать inline функционал для него.")) async def main() -> None: await bot_dispatcher.start_polling(bot) if __name__ == "__main__": logging.basicConfig(level=logging.INFO, stream=sys.stdout) asyncio.run(main())

config.py file

from aiogram import Bot, Dispatcher from aiogram.utils.i18n import I18n, SimpleI18nMiddleware with open(".env", "r") as file: buffer = file.read() line_pos = buffer.find("BOT_TOKEN") TOKEN = buffer[buffer.find("=", line_pos) + 1:] bot = Bot(TOKEN) bot_dispatcher = Dispatcher(bot=bot) # Set up translation i18n = I18n(path="locales", domain="messages") i18n_handler = SimpleI18nMiddleware(i18n) i18n_handler.setup(bot_dispatcher)

Similar tools

Simple quizer bot

Creation date
11.12.2023
/
Update date
12.02.2026
/
Icon of app type
Telegram bot
An eye
493
Hearts
0
Connected dots
0
Connected dots
0
Connected dots
0
This is a simple telegram bot questionnaire, which is written in python/aiogram and uses a clever system of its own templates to render (send) survey results to users.
Online tool to scrape text, headers and source code (just use CSS selector) from websites, web pages and lists of pages. With subsequent basic processing, which includes the number of words, the number of unique words and collecting a list of the frequency of occurrence of these words in the text.

Do not forget to share, like and leave a comment :)

Reviews

(0)

captcha
Send
LOADING ...
It's empty now. Be the first (o゚v゚)ノ