Aiogram 3 uchun o'zbekcha va juda oson kutubxona
Project description
๐ค AioTeleBot
Telegram bot yaratish uchun eng oson va o'zbekcha kutubxona! Aiogram 3 asosida qurilgan.
โจ Xususiyatlari
- ๐บ๐ฟ To'liq o'zbekcha dokumentatsiya va metodlar
- ๐ Juda oson - kamroq kod, ko'proq natija
- ๐ฏ Sodda sintaksis - 5 daqiqada bot yasang
- ๐ฆ Barcha imkoniyatlar - state, tugmalar, media va h.k.
- ๐ง Aiogram 3 asosida ishlab chiqilgan
๐ฅ O'rnatish
pip install aiotelebot
๐ Tezkor Boshlash
Oddiy bot
from aiotelebot import OsonBot
# Bot yaratish
bot = OsonBot("SIZNING_TOKEN")
# /start komandasi
@bot.xabar("/start")
async def start(xabar):
await bot.yuborish(xabar, "๐ Salom! Men oddiy botman.")
# /help komandasi
@bot.xabar("/help")
async def yordam(xabar):
await bot.yuborish(xabar, "๐ Yordam bo'limi")
# Botni ishga tushirish
bot.ishga_tushirish()
Tugmalar bilan
from aiotelebot import OsonBot, Tugma
bot = OsonBot("TOKEN")
@bot.xabar("/menu")
async def menu(xabar):
# Oddiy tugmalar
tugma = Tugma()
tugma.qator(["๐ Statistika", "โ๏ธ Sozlamalar"])
tugma.qator(["โ Yordam"])
await bot.yuborish(xabar, "Menyuni tanlang:", tugma)
bot.ishga_tushirish()
Inline tugmalar
from aiotelebot import OsonBot, InlineTugma
bot = OsonBot("TOKEN")
@bot.xabar("/taklif")
async def taklif(xabar):
# Inline tugmalar
tugma = InlineTugma()
tugma.qator([
("โ
Tasdiq", "tasdiq"),
("โ Rad etish", "rad")
])
tugma.url("๐ Sayt", "https://example.com")
await bot.yuborish(xabar, "Taklifni qabul qilasizmi?", tugma)
# Inline tugma bosilganda
@bot.callback("tasdiq")
async def tasdiq_handler(callback):
await bot.javob_berish(callback, "โ
Tasdiqlanddi!")
await bot.tahrirlash(callback, "Taklif qabul qilindi โ
")
bot.ishga_tushirish()
Holatlar bilan ishlash (State)
from aiotelebot import OsonBot, HolatGuruhi, Holat
bot = OsonBot("TOKEN")
# Holatlarni yaratish
class Royxat(HolatGuruhi):
ism = Holat()
yosh = Holat()
telefon = Holat()
@bot.xabar("/royxat")
async def royxat_boshlash(xabar):
await bot.holat_ozgartirish(xabar, Royxat.ism)
await bot.yuborish(xabar, "Ismingizni kiriting:")
@bot.xabar(holat=Royxat.ism)
async def ism_qabul(xabar):
await bot.malumot_saqlash(xabar, "ism", xabar.text)
await bot.holat_ozgartirish(xabar, Royxat.yosh)
await bot.yuborish(xabar, "Yoshingizni kiriting:")
@bot.xabar(holat=Royxat.yosh)
async def yosh_qabul(xabar):
await bot.malumot_saqlash(xabar, "yosh", xabar.text)
await bot.holat_ozgartirish(xabar, Royxat.telefon)
tugma = Tugma()
tugma.kontakt("๐ฑ Telefon raqamni yuborish")
await bot.yuborish(xabar, "Telefon raqamingizni yuboring:", tugma)
@bot.xabar(holat=Royxat.telefon)
async def telefon_qabul(xabar):
# Barcha ma'lumotlarni olish
malumot = await bot.malumot_olish(xabar)
await bot.holat_tozalash(xabar)
await bot.yuborish(
xabar,
f"โ
Ro'yxatdan o'tdingiz!\n\n"
f"๐ค Ism: {malumot['ism']}\n"
f"๐ Yosh: {malumot['yosh']}\n"
f"๐ฑ Telefon: {xabar.contact.phone_number}"
)
bot.ishga_tushirish()
Media yuborish
from aiotelebot import OsonBot, Media
bot = OsonBot("TOKEN")
@bot.xabar("/rasm")
async def rasm_yuborish(xabar):
# Fayldan
await bot.rasm_yuborish(
xabar,
Media.fayldan("rasm.jpg"),
izoh="Bu rasm"
)
# URL dan
await bot.rasm_yuborish(
xabar,
Media.urldan("https://example.com/rasm.jpg"),
izoh="URL dan rasm"
)
@bot.xabar("/video")
async def video_yuborish(xabar):
await bot.video_yuborish(
xabar,
Media.fayldan("video.mp4"),
izoh="Video fayl"
)
@bot.xabar("/fayl")
async def fayl_yuborish(xabar):
await bot.fayl_yuborish(
xabar,
Media.fayldan("dokument.pdf"),
izoh="PDF fayl"
)
bot.ishga_tushirish()
๐ To'liq Misol
from aiotelebot import OsonBot, Tugma, InlineTugma, HolatGuruhi, Holat, Media
# Bot yaratish
bot = OsonBot("SIZNING_TOKEN", log_darajasi="INFO")
# Holatlar
class Savol(HolatGuruhi):
javob_kutish = Holat()
# Start komandasi
@bot.xabar("/start")
async def start(xabar):
tugma = Tugma()
tugma.qator(["๐ Statistika", "โ Savol"])
tugma.qator(["โ๏ธ Sozlamalar"])
await bot.yuborish(
xabar,
f"Salom, {xabar.from_user.first_name}! ๐\n"
f"Men yordamchi botman.",
tugma
)
# Statistika
@bot.xabar(matn="๐ Statistika")
async def statistika(xabar):
inline = InlineTugma()
inline.qator([
("๐ Bugun", "stat_bugun"),
("๐
Hafta", "stat_hafta")
])
inline.qator([("๐ Orqaga", "orqaga")])
await bot.yuborish(xabar, "๐ Statistika bo'limi:", inline)
# Savol boshlash
@bot.xabar(matn="โ Savol")
async def savol_boshlash(xabar):
await bot.holat_ozgartirish(xabar, Savol.javob_kutish)
await bot.yuborish(xabar, "Savolingizni yozing:")
# Savolga javob
@bot.xabar(holat=Savol.javob_kutish)
async def savol_javob(xabar):
await bot.holat_tozalash(xabar)
await bot.yuborish(xabar, f"Sizning savolingiz: {xabar.text}\n\nTez orada javob beramiz!")
# Callback handlerlar
@bot.callback("stat_bugun")
async def stat_bugun(callback):
await bot.javob_berish(callback, "Bugungi statistika")
@bot.callback("orqaga")
async def orqaga(callback):
tugma = Tugma()
tugma.qator(["๐ Statistika", "โ Savol"])
await bot.tahrirlash(callback, "Bosh menyu", tugma)
# Har qanday xabar
@bot.har_qanday_xabar()
async def boshqa(xabar):
print(f"Noma'lum xabar: {xabar.text}")
# Botni ishga tushirish
if __name__ == "__main__":
bot.ishga_tushirish()
๐ฏ Asosiy Metodlar
Bot Metodlari
| Metod | Tavsif |
|---|---|
yuborish() |
Xabar yuborish |
tahrirlash() |
Xabarni tahrirlash |
javob_berish() |
Callback ga javob |
rasm_yuborish() |
Rasm yuborish |
video_yuborish() |
Video yuborish |
fayl_yuborish() |
Fayl yuborish |
holat_ozgartirish() |
Holatni o'zgartirish |
malumot_saqlash() |
Ma'lumot saqlash |
malumot_olish() |
Ma'lumot olish |
Dekoratorlar
| Dekorator | Tavsif |
|---|---|
@bot.xabar() |
Xabar handler |
@bot.callback() |
Inline tugma handler |
@bot.har_qanday_xabar() |
Barcha xabarlar |
๐ Litsenziya
MIT License
๐ค Hissa qo'shish
Pull requestlar xush kelibsiz!
๐ Aloqa
Savollar bo'lsa, issue oching!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiotelebotuz-1.0.0.tar.gz
(10.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiotelebotuz-1.0.0.tar.gz.
File metadata
- Download URL: aiotelebotuz-1.0.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa11451838fa342ae2d3938cde0eee675129bdc31474e63e8e23d295eba7b3f4
|
|
| MD5 |
a2a5e95c2018935a6e014bb63d8f7abc
|
|
| BLAKE2b-256 |
b0dabc77cfe44c8812d5562cf803e7cbb9929c53b324c2a3ef38deb59503a484
|
File details
Details for the file aiotelebotuz-1.0.0-py3-none-any.whl.
File metadata
- Download URL: aiotelebotuz-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86236ada1335693faaf1c7dc3039c09a85be7511888b746ad3e22a26f10e6e9a
|
|
| MD5 |
603cb67b431f28aa2d73fe9d020491e2
|
|
| BLAKE2b-256 |
c36f19719d6e5950428609e4b5e8b77e34a030f7cc448cd87deb605502be8a4a
|