Skip to main content

BaleNova

کار با حساب بله در Python، با یک API ساده و قابل‌فهم.

نصب

pip install balenova

Python 3.10 یا جدیدتر لازم است.

شروع در کمتر از یک دقیقه

یک فایل به نام main.py بسازید:

from balenova import Client, events, filters

app = Client("my_account")


@app.on(events.NewMessage, filters.command("start"))
async def start(event):
    await event.reply("سلام! من آماده‌ام 🌱")


app.run_forever()

سپس اجرا کنید:

python main.py

بار اول شماره، کد ورود و در صورت نیاز رمز دومرحله‌ای پرسیده می‌شود. دفعات بعد ورود ذخیره‌شده استفاده خواهد شد.

پیام‌ها

@app.on(events.NewMessage, filters.private & filters.text)
async def new_message(event):
    print(event.text)
    print(event.sender_id)
    print(event.chat.id)

    await event.answer("پیامت رسید")
    await event.reply("این پیام به‌صورت پاسخ ارسال شد")

فیلترها را می‌توان با &، | و ~ ترکیب کرد:

only_commands = filters.incoming & filters.private & filters.command("help")

همهٔ به‌روزرسانی‌ها به‌صورت کلاس

هر به‌روزرسانی یک شیء مشخص است:

  • events.NewMessage برای پیام تازه
  • events.MessageSent برای تأیید ارسال
  • events.RawUpdate برای موارد دیگری که دادهٔ آن‌ها دریافت شده است
  • events.Update پایهٔ مشترک همهٔ موارد
@app.on_update
async def every_update(update):
    print(update.name)
    print(update.to_json())

برای گرفتن فقط یک نوع:

@app.on(events.MessageSent)
async def sent(update):
    print(update.to_dict())

تبدیل نتیجه‌ها به JSON

مدل‌هایی مانند پیام، کاربر، گفت‌وگو و به‌روزرسانی مستقیماً قابل تبدیل‌اند:

print(event.to_dict())
print(event.to_json())

me = await client.get_me()
print(me.to_json())

میان‌برهای کاربردی

await client.send("12345|1", "سلام")
chat = await client.get_entity("username")

async for message in client.iter_messages("12345|1", limit=100):
    print(message.text)

limits = await client.get_upload_limits()

روی خود پیام نیز میان‌برهای آماده وجود دارد:

await event.message.respond("سلام")
await event.message.edit_text("متن جدید")
await event.message.delete()
await event.message.react("❤")

نمونه‌های بیشتر در پوشهٔ examples و راهنمای ساده در docs/USAGE.md قرار دارند.

نکتهٔ مهم

این پروژه رسمیِ بله نیست. از حساب آزمایشی شروع کنید، اطلاعات ورود و فایل‌های session را منتشر نکنید و مسئولیت استفاده از حساب بر عهدهٔ خود شماست.

مجوز

MIT — جزئیات حقوقی لازم در فایل NOTICE نگه‌داری می‌شود.

Metadata

Release files for balenova 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for balenova 0.3.0
File Size Uploaded Provenance
balenova-0.3.0.tar.gz 81.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for balenova 0.3.0
File Interpreter ABI Platform
balenova-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 159.5 kB

Release files / balenova-0.3.0.tar.gz

Download URL balenova-0.3.0.tar.gz
Size 81.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b337adbb6a6f48408c1b2e83b571c779ac8179ccc571ce507e07cf5d55f9ec58
BLAKE2b-256 checksum
How to use checksums
6a1f88af40f28b408d03122144e31de9a4176f6273696fdbe315e96e2ab441b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / balenova-0.3.0-py3-none-any.whl

Download URL balenova-0.3.0-py3-none-any.whl
Size 77.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
369c08e326dc25787d7bedf3aa90fa00ea01bcf63b8afea4842511413c52b612
BLAKE2b-256 checksum
How to use checksums
dd00693e2002b86161a85679a63a43aded32e564c680d42913b58355050eaf70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for balenova 0.3.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page