nicebot
Telegram botlar uchun Python kutubxonasi: kam kod, hamma narsa ichida.
🇺🇿 O'zbekcha · 🇷🇺 Документация на русском · 🇬🇧 English docs
from nicebot import Nicebot
bot = Nicebot(token="123456:ABC...")
@bot.command("start")
async def start(ctx):
name = await ctx.ask("Ismingiz?")
age = await ctx.ask("Yoshingiz?", int)
await ctx.reply(f"Salom, {name}! Siz {age} yoshdasiz.")
bot.start()
Bu kodda Dispatcher, StatesGroup va FSM yo'q. ctx.ask() savol berib, javobni o'sha joyda kutadi. Son kiritilmasa, o'zi qayta so'raydi. Foydalanuvchi esa bazaga avtomatik saqlanadi.
O'rnatish
pip install nicebot # SQLite bilan
pip install "nicebot[postgres]" # + PostgreSQL
pip install "nicebot[mysql]" # + MySQL / MariaDB
pip install "nicebot[mongo]" # + MongoDB
pip install "nicebot[all]" # hammasi + Redis
Tayyor loyiha yaratish:
nicebot new mybot && cd mybot && python bot.py
Ichida nimalar bor
| Bot API 10.3 to'liq | 403 ta tur va 185 ta metod rasmiy spetsifikatsiyadan generatsiya qilingan, msgspec asosida |
| Ichki ORM | SQLite, PostgreSQL, MySQL va MongoDB uchun bitta API, avto-migratsiya bilan |
| Suhbatlar | ask, confirm, choose(multiple=True), form va validatorlar (telefon +998, email, sana…) |
| Tugmalar | Button(on_click=func), "buy:{id:int}" shablonlari, Toggle, ttl, once, only, avto-joylashuv |
| UI | Ko'p darajali Menu, ctx.paginate(), reply klaviatura qisqartmalari |
| Biznes | Referal, broadcast (davom ettirish bilan), statistika, admin panel, majburiy obuna, support, Telegram Stars |
| Guruhlar | ban, mute, warn, captcha |
| Mini App | @bot.api endpointlari, initData HMAC tekshiruvi, nicebot.js |
| Arxitektura | DI (type hint orqali), middleware, Router, from_env(), scheduler, fon vazifalari, kesh |
| Ishonchlilik | Flood-wait, retry, file_id keshi, to'g'ri to'xtash, xatolar haqida adminlarga hisobot |
| Ishlab chiqish | reload=True, bot.test() (Telegram'siz testlar), CLI |
To'liq ro'yxat va qo'llanma: hujjatlar sayti (uz / ru / en).
Yana misollar
from nicebot import Nicebot, Button, Model, fields, Phone
bot = Nicebot(token="...", db="sqlite:///shop.db", admins=[123456789])
class Order(Model):
user_id = fields.BigInt(index=True)
product = fields.Str(100)
phone = fields.Str(20)
async def buy(ctx, product: str):
phone = await ctx.ask("Telefon raqamingiz?", Phone)
if await ctx.confirm(f"{product} buyurtma qilinsinmi?"):
await Order.create(user_id=ctx.user_id, product=product, phone=phone)
await ctx.reply("✅ Qabul qilindi!")
await ctx.notify_admins(f"🛒 Yangi buyurtma: {product}, {phone}")
@bot.command("shop", description="Do'kon")
async def shop(ctx):
await ctx.reply("Mahsulotni tanlang:", buttons=[
Button("📚 Kitob", on_click=buy, product="Kitob"),
Button("🎧 Quloqchin", on_click=buy, product="Quloqchin"),
])
bot.start(reload=True)
Adminlar uchun /stats, /broadcast, /maintenance va /backup buyruqlari avtomatik ishlaydi.
Testlash
async def test_shop():
async with bot.test() as t:
user = t.user(first_name="Ali")
await user.send("/shop")
await user.click("Kitob")
await user.send("90 123 45 67")
await user.click("Ha")
assert t.last_in(user.chat_id).text == "✅ Qabul qilindi!"
Litsenziya
MIT © Ozodbek Sobirjonovich
Metadata
Release files for nicebot 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nicebot-0.1.0.tar.gz | 136.0 kB | With provenance | Details for nicebot-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nicebot-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nicebot-0.1.0-py3-none-any.whl |
Total release size: 276.9 kB
Release files / nicebot-0.1.0.tar.gz
| Download URL | nicebot-0.1.0.tar.gz |
|---|---|
| Size | 136.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa2c73c3ab0af8aaa02c169c4a9118d6fdad9dfe165cd31cf7275ae51acfa84a
|
|
BLAKE2b-256 checksum How to use checksums |
a8484e596555d5f8e90c3722c5706adf727d8f51698cfc74c645a2e20da261ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / nicebot-0.1.0-py3-none-any.whl
| Download URL | nicebot-0.1.0-py3-none-any.whl |
|---|---|
| Size | 140.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0df02b66624a9233fc4f70706e6733b628b76681356b143549c216f3df4a9cf
|
|
BLAKE2b-256 checksum How to use checksums |
35341c2872f8211c8358aea71c0465db556b7ca5102ce9f3ee07d329d114a0a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for nicebot 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for nicebot-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.