Skip to main content

PyGrammY — GrammyJS inspired async Telegram Bot framework for Python

Project description

🐍 PyGrammY

PyGrammY — bu Python uchun to‘liq asinxron, grammy.js’dan ilhomlangan, zamonaviy Telegram Bot Framework.
U async/await, httpx, middleware, session, filters va modular arxitekturani qo‘llab-quvvatlaydi.


🚀 Xususiyatlar

  • ⚡ To‘liq asinxron (async/await)
  • 🌐 httpx asosida Telegram Bot API
  • 🧠 Context (ctx) — barcha ma’lumotlar bitta joyda
  • 🔌 Middleware chain (GrammyJS uslubida)
  • 💾 Session (memory & file storage)
  • 🧩 Composer — modular bot arxitekturasi
  • 🎯 Kuchli filters
  • ⌨️ Inline & Reply Keyboards
  • 🪝 Polling va Webhook qo‘llab-quvvatlanadi
  • 🛡 Global error handling

📦 O‘rnatish

PyPI orqali (kelajakda)

pip install pygrammy

Lokal o‘rnatish

pip install httpx aiohttp
project/
├── pygrammy/
│   ├── bot.py
│   ├── context.py
│   ├── keyboard.py
│   ├── session.py
│   ├── filters.py
│   ├── composer.py
│   ├── types.py
│   └── __init__.py
└── main.py

🧑‍💻 Minimal misol

import asyncio
from pygrammy import Bot

bot = Bot("YOUR_BOT_TOKEN")

@bot.command("start")
async def start(ctx):
    await ctx.reply("👋 Salom, PyGrammY ishlayapti!")

async def main():
    async with bot:
        await bot.start()

asyncio.run(main())

🧩 Middleware

@bot.use
async def logger(ctx, next):
    print(ctx.update.update_id)
    await next()

💾 Session

from pygrammy import session

bot.use(session(initial=lambda: {"count": 0}))

@bot.on("message:text")
async def counter(ctx):
    ctx.session["count"] += 1
    await ctx.reply(f"Count: {ctx.session['count']}")

⌨️ Inline Keyboard

from pygrammy import InlineKeyboard

kb = InlineKeyboard()
kb.text("👍 Like", "like").row().url("Google", "https://google.com")

await ctx.reply("Tanlang:", reply_markup=kb)

🎯 Filters

@bot.on("message:photo")
async def photo_handler(ctx):
    await ctx.reply("📸 Rasm qabul qilindi")

Custom filter:

@bot.filter(lambda ctx: ctx.chat.type == "private")
async def private_only(ctx):
    await ctx.reply("Private chat")

🪝 Callback Query

@bot.callback_query("like")
async def like(ctx):
    await ctx.answer_callback_query("👍")

🌐 Webhook

await bot.start(webhook={
    "domain": "https://example.com",
    "path": "/webhook",
    "port": 8443
})

🆚 GrammyJS bilan taqqoslash

Xususiyat GrammyJS PyGrammY
Til JS / TS Python
Async Promise async/await
HTTP fetch httpx
Typing TypeScript type hints

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygrammy-1.0.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygrammy-1.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file pygrammy-1.0.0.tar.gz.

File metadata

  • Download URL: pygrammy-1.0.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pygrammy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f000f1222724cf78011d20fe91e9252724ebda2be59a05e4070a695bd00464d2
MD5 e25b3358447eddb76d8a3a9f6c6fb3e6
BLAKE2b-256 c15d22497eaf87a12a1d16a7740607da203818d78c6dbf8f8c2e8a3328d961a7

See more details on using hashes here.

File details

Details for the file pygrammy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pygrammy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pygrammy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cced139830f7e72ddf930416600cde0dbdeaee4e46cc7c3fba3c7eb2bce2d0c
MD5 f2a68989ea46bbe95c460f3ea8bf6438
BLAKE2b-256 c5901dc7ab76df4dd98f9ef58695f696e7937198a647bfd3f7b644ac79483ca3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page