aiogram is a pretty simple and fully asynchronous framework for Telegram Bot API written in Python 3.7 with asyncio and aiohttp. It helps you to make your bots faster and simpler.
📚 Click to see some basic examples
Few steps before getting started...
- First, you should obtain token for your bot from BotFather.
- Install the latest stable version of aiogram, simply running
pip install aiogram
Simple getMe request
importasynciofromaiogramimportBotBOT_TOKEN=""asyncdefmain():
bot=Bot(token=BOT_TOKEN)
try:
me=awaitbot.get_me()
print(f"🤖 Hello, I'm {me.first_name}.\nHave a nice Day!")
finally:
awaitbot.close()
asyncio.run(main())importasynciofromaiogramimportBot, Dispatcher, typesBOT_TOKEN=""asyncdefstart_handler(event: types.Message):
awaitevent.answer(
f"Hello, {event.from_user.get_mention(as_html=True)} 👋!",
parse_mode=types.ParseMode.HTML,
)
asyncdefmain():
bot=Bot(token=BOT_TOKEN)
try:
disp=Dispatcher(bot=bot)
disp.register_message_handler(start_handler, commands={"start", "restart"})
awaitdisp.start_polling()
finally:
awaitbot.close()
asyncio.run(main())You can find more examples in examples/ directory
- News: @aiogram_live
- Communities:
- 🇺🇸 @aiogram
- 🇺🇦 @aiogramua
- 🇺🇿 @aiogram_uz
- 🇰🇿 @aiogram_kz
- 🇷🇺 @aiogram_ru
- 🇮🇷 @aiogram_fa
- 🇮🇹 @aiogram_it
- 🇧🇷 @aiogram_br
- PyPI: aiogram
- Documentation: aiogram site
- Source: Github repo
- Issues/Bug tracker: Github issues tracker
- Test bot: @aiogram_bot
This project exists thanks to all the people who contribute. [Code of conduct].
Become a financial contributor and help us sustain our community. [Contribute]
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]