aiogram / aiogram
- вторник, 16 августа 2022 г. в 00:34:03
Is a pretty simple and fully asynchronous framework for Telegram Bot API written in Python 3.7 with asyncio and aiohttp.
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.
Few steps before getting started...
pip install aiogram
getMe
requestimport asyncio
from aiogram import Bot
BOT_TOKEN = ""
async def main():
bot = Bot(token=BOT_TOKEN)
try:
me = await bot.get_me()
print(f"🤖 Hello, I'm {me.first_name}.\nHave a nice Day!")
finally:
await bot.close()
asyncio.run(main())
import asyncio
from aiogram import Bot, Dispatcher, types
BOT_TOKEN = ""
async def start_handler(event: types.Message):
await event.answer(
f"Hello, {event.from_user.get_mention(as_html=True)} 👋!",
parse_mode=types.ParseMode.HTML,
)
async def main():
bot = Bot(token=BOT_TOKEN)
try:
disp = Dispatcher(bot=bot)
disp.register_message_handler(start_handler, commands={"start", "restart"})
await disp.start_polling()
finally:
await bot.close()
asyncio.run(main())
You can find more examples in examples/
directory
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]