Skip to main content
NSplusthon — Python client for Soroush Plus

NSplusthon

Async Python library for the Soroush Plus (سروش پلاس / SPlus) API
Telethon-style client for user accounts and bots. Fork of SPlusthon.

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

PyPI Python versions License Downloads Stars Issues

Documentation · English docs · PyPI · GitHub · Soroush Plus


What is NSplusthon?

NSplusthon is an asyncio Python 3.9+ library that talks to Soroush Plus (سروش پلاس, also called SPlus) over MTProto — the same idea as Telethon for Telegram.

Use it to write userbots and bots: send messages and files, download media, handle events, and route commands. No API ID or API hash is required.

It is a maintained fork of SPlusthon with a faster AES-IGE path, a command router, rate limiting, and encrypted sessions. The import is nsplusthon; the client class is still SoroushClient.

pip install nsplusthon
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()

Do not name your script nsplusthon.py — it will shadow the package.


Why NSplusthon instead of SPlusthon / spluspy?

NSplusthon SPlusthon spluspy
Telethon-style SoroushClient yes yes no
AES-IGE (libssl, 256 KiB) ~100 MiB/s ~5.6 MiB/s ~5.9 MiB/s
import time (lazy) ~15 ms ~340 ms —
Command router + rate limit yes no no
Encrypted StringSession yes no no
Typed (py.typed) yes — —

Full write-up: Compare · Migrate from SPlusthon


Features

  • User accounts and bots
  • High-performance asyncio client
  • Command router: /help, middleware, per-user state, rate limits
  • Sliding-window RateLimiter (avoid FloodWait / bans)
  • Passphrase-encrypted sessions (AES-IGE + PBKDF2)
  • Lazy import (PEP 562): import nsplusthon in ~15 ms
  • Sync and async APIs
  • Soroush TL schema (layer 182)
  • StringSession / MemorySession / SQLiteSession
  • WebSocket transport and DC routing
  • RSA + AES
  • No API ID / API hash
  • Telethon-like API so Telegram bots are easy to port
  • Typed package for Pyright / Pylance / mypy

  • پشتیبانی کامل از حساب کاربری و ربات
  • 🎛️ Command Router با /help خودکار، middleware و rate-limit
  • 🔐 Session رمزنگاری‌شده با passphrase
  • 🪜 API مشابه Telethon برای مهاجرت آسان
  • 🗝️ بدون نیاز به API ID و API Hash


Install

Requires Python 3.9+.

pip install nsplusthon

Faster crypto, SOCKS proxies, and media helpers:

pip install "nsplusthon[fast]"

Latest git snapshot:

pip install "git+https://github.com/Amogrotex/NSplusthon.git"
Extra What you get
cryptg Faster C crypto (recommended)
socks SOCKS proxies
fast cryptg + socks + Pillow + hachoir + isal
dev pytest stack

Core dependencies: aiohttp, pyaes, rsa.


Quick start

from nsplusthon import SoroushClient
from nsplusthon.sessions import StringSession

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

Send a message, a file, or download media:

client.send_message("username", "سلام از NSplusthon")
client.send_file("username", "/path/image.jpg")

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

Sync API

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

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

Saved / encrypted session

from nsplusthon import SoroushClient
from nsplusthon.sessions import StringSession

session = "1AwA..."  # string from the first login

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

enc = StringSession.encrypt_session(session, "passphrase")
later = StringSession.from_encrypted(enc, "passphrase")

Command router

from nsplusthon import SoroushClient
from nsplusthon.sessions import StringSession
from nsplusthon.router import Router

router = Router().use_rate_limit(max_calls=40, period=60)

@router.command("start", description="Says hello")
async def cmd_start(event, args, kwargs):
    name = kwargs.get("name", "دوست")
    await event.reply(f"سلام {name}!")

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

Documentation

Persian (default): amogrotex.github.io/NSplusthon


Performance

AES-IGE via libssl (no cryptg), 256 KiB, Intel Xeon @ 2.60 GHz, Python 3.13.14, best of 9. Bit-identical to the C reference.

Library Encrypt time Throughput
NSplusthon 2.50 ms 100.1 MiB/s
SPlusthon 44.86 ms 5.6 MiB/s
spluspy 42.47 ms 5.9 MiB/s

Micro-benchmarks (benchmarks/microbench.py) on Python 3.13:

Operation Time
import nsplusthon (lazy) ~15 ms (was ~340 ms)
TL pack (SendMessageRequest) 2.4 µs
StringSession restore 5.6 µs
Router parse + resolve 2.3 µs

Scripts: benchmarks/aes_ige_bench.py · benchmarks/microbench.py


Contributing

See CONTRIBUTING.md. Please open an issue first, work on a branch, and run python -m compileall nsplusthon before the PR.

License

GNU GPL v3.

This is a third-party library and is not affiliated with Soroush Plus. Follow the Soroush Plus terms. You are responsible for how you use it.


NSplusthon is maintained by AmoGrotex.

Forked from SPlusthon by Shayan Heidari, which is based on Telethon by Lonami.

Metadata

Release files for NSplusthon 1.3.5

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.3.5
File Size Uploaded
nsplusthon-1.3.5.tar.gz 599.1 kB Details

Built distribution (wheel)

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

Total release size: 1.3 MB

Release files / nsplusthon-1.3.5.tar.gz

Download URL nsplusthon-1.3.5.tar.gz
Size 599.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8ba3961029110852a73e64f061b245981339f94ba28e633e9b6de45d69a2be34
BLAKE2b-256 checksum
How to use checksums
322a7b8b12b48016b7cbf0d50ade661f164ef30fe22547e7be4ac21ed7bf14bc
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.3.5-py3-none-any.whl

Download URL nsplusthon-1.3.5-py3-none-any.whl
Size 675.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbcfaff0aaa41ec42d2f113edbe2e685485029d201a138e5dd1a772afbe736a4
BLAKE2b-256 checksum
How to use checksums
43c721e706ece196532b57fa50c364c58679efe5d73875cbff7c97820d51b103
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

This release

1.3.5 This release

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

1.2.1

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