Skip to main content
NSplusthon Logo

NSplusthon

Asynchronous Python library for the Soroush Plus API

کتابخانه‌ای مدرن و سریع بر پایه asyncio برای تعامل مستقیم با API پیام‌رسان سروش پلاس — به‌عنوان کاربر یا ربات.

PyPI Python License Stars Issues

📖 Documentation • 📦 PyPI • 🐙 GitHub • 💬 Soroush Plus


✨ ویژگی‌ها

  • ✅ پشتیبانی کامل از حساب کاربری و ربات
  • ⚡ مبتنی بر asyncio با کارایی بالا
  • 🔄 استفاده همزمان به‌صورت Sync و Async
  • 🧩 پشتیبانی کامل از TL Schema اختصاصی سروش (Layer 182)
  • 💾 مدیریت انعطاف‌پذیر Session: StringSession / MemorySession / SQLiteSession
  • 🌐 ترنسپورت WebSocket و DC Routing
  • 🔒 رمزنگاری RSA و AES
  • 🗝️ بدون نیاز به API ID و API Hash
  • 🪜 API مشابه Telethon برای مهاجرت آسان
  • 📝 پکیج Typed (py.typed) — تایپ‌چک کامل با Pyright / Pylance / mypy
  • 🚀 مسیر OpenSSL بهینه برای AES-IGE (چند برابر سریع‌تر از کتابخانه‌های مشابه)

📊 عملکرد

بنچمارک AES-IGE روی مسیر libssl (بدون cryptg) — ۲۵۶ کیلوبایت، Intel Xeon @ 2.60GHz، Python 3.13.14، بهترینِ ۹ اجرا. خروجی با مرجع C بیت‌به‌بیت یکسان بود.

کتابخانه زمان رمزگذاری سرعت
NSplusthon 2.50 ms 100.1 MiB/s
SPlusthon 44.86 ms 5.6 MiB/s
spluspy 42.47 ms 5.9 MiB/s

NSplusthon روی این مسیر حدود ۱۸ برابر سریع‌تر است (from_buffer_copy به‌جای کپی بایت‌به‌بایت در سطح Python).

اسکریپت بنچمارک: benchmarks/aes_ige_bench.py

🚀 نصب

نیاز به Python 3.9 یا بالاتر.

از PyPI:

pip install nsplusthon

نصب کامل با بهینه‌سازی‌های سرعت (cryptg + پروکسی + پردازش رسانه):

pip install "nsplusthon[fast]"

آخرین نسخه توسعه از Git:

pip install git+https://github.com/Amogrotex/NSplusthon.git

وابستگی‌های اختیاری (Extras)

Extra محتوا
cryptg رمزنگاری C سریع‌تر (توصیه‌شده)
socks پشتیبانی از پروکسی SOCKS
fast همه‌چیز: cryptg + socks + Pillow + hachoir + isal
dev ابزارهای توسعه: pytest + pytest-asyncio + pytest-cov

وابستگی‌های اصلی: aiohttp، pyaes، rsa

⚡ شروع سریع

from nsplusthon import SoroushClient
from nsplusthon.sessions import StringSession

client = SoroushClient(StringSession())
client.start()

⚠️ نکته: فایل اسکریپت خود را nsplusthon.py نامگذاری نکنید — پایتون هنگام import با خود کتابخانه تداخل پیدا می‌کند.

💬 یک ربات ساده

from nsplusthon import SoroushClient, events
from nsplusthon.sessions import StringSession

client = SoroushClient(StringSession())

@client.on(events.NewMessage)
async def handler(event):
    await event.reply("سلام 👋")

client.start()
client.run_until_disconnected()

ارسال پیام

client.send_message("username", "سلام از NSplusthon ❤️")

ارسال فایل

client.send_file("username", "/path/image.jpg")

دانلود رسانه

message = client.get_messages("username", limit=1)[0]
message.download_media()

🔄 حالت همگام (Sync)

اگر با async/await راحت نیستید، از API همگام استفاده کنید:

from nsplusthon.sync import SoroushClient
from nsplusthon.sessions import StringSession

with SoroushClient(StringSession()) as client:
    print(client.get_me())
    client.send_message("username", "درود!")

🔐 Session ذخیره‌شده

Session را یک‌بار ذخیره کنید و در اجراهای بعدی از همان استفاده کنید:

from nsplusthon import SoroushClient
from nsplusthon.sessions import StringSession

session = "1AwA..."  # رشته‌ای که پس از ورود اولیه ذخیره می‌کنید

with SoroushClient(StringSession(session)) as client:
    print(client.get_me())

📚 مستندات

مستندات کامل پروژه (فارسی):

👉 https://Amogrotex.github.io/NSplusthon/

🤝 مشارکت

Pull requestها خوشحال‌کننده‌اند! لطفاً:

  1. یک Issue برای مشکل یا ویژگی جدید باز کنید
  2. روی شاخه‌ای جدا کار کنید
  3. قبل از ارسال، مطمئن شوید کد byte-compile می‌شود: python -m compileall nsplusthon
  4. توضیح تغییرات را در PR بنویسید

⚖️ مجوز

این پروژه تحت مجوز GNU GPL v3 منتشر شده است.

⚠️ توجه: این کتابخانه شخص ثالث است و وابستگی به سروش پلاس ندارد. هنگام استفاده، قوانین و شرایط استفاده سروش پلاس را رعایت کنید. مسئولیت نحوه استفاده از این پروژه بر عهده کاربر است.


NSplusthon is maintained by AmoGrotex

Metadata

Release files for NSplusthon 1.2.1

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

Source distribution (sdist)

Source distribution for NSplusthon 1.2.1
File Size Uploaded
nsplusthon-1.2.1.tar.gz 590.4 kB Details

Built distribution (wheel)

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

Total release size: 1.3 MB

Release files / nsplusthon-1.2.1.tar.gz

Download URL nsplusthon-1.2.1.tar.gz
Size 590.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e801f7eb85323a1d660a37a8997271ff5a36a0902201429df81de498e8c67696
BLAKE2b-256 checksum
How to use checksums
adde365606b924b1db7e1cc4baa0fed6fc9593ec9f4feeb1b94eed008e7452f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / nsplusthon-1.2.1-py3-none-any.whl

Download URL nsplusthon-1.2.1-py3-none-any.whl
Size 666.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9540a597920c93b1946dd172e2867bdfe3d5cbab2ce79423fe6fd6cf3b461404
BLAKE2b-256 checksum
How to use checksums
8e7c953447d2bccb95e3f7bffc3980aa2aad5cf84e577df3d3c0d2a877581780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

1.8.2

2 release files

1.8.1

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.4

2 release files

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