NSplusthon
An asynchronous Python MTProto client library for Soroush Plus.
Maintained fork of SPlusthon, itself derived from Telethon. See NOTICE and THIRD_PARTY.md.
Features
- User Accounts & Bots: Support for user login and official bot tokens.
- FSM State Storage: Finite State Machine with
MemoryStorageand persistentSQLiteStorage. - Composable Filters: Combine event filters using Python logic (
&,|,~). - Group Moderation: Built-in flood protection, link checking, profanity filtering, and optional night-lock.
- Interactive Conversations: Linear multi-step conversation handler (
async with client.conversation(chat)). - Client Pool: Manage multiple accounts with client pooling and message broadcasting.
- Inline Keyboards & Paginator: Clean keyboard builder and paginated inline menu layout.
- Soroush Plus Detection: Link parser and entity classifier for Soroush Plus URLs, URIs, and user IDs.
Installation
pip install -U nsplusthon
Optional dependencies for fast crypto (cryptg) and proxy support:
pip install -U "nsplusthon[fast]"
PyPI may lag the git tag (Trusted Publishing — see PUBLISHING.md). Latest:
pip install -U "nsplusthon[fast] @ git+https://github.com/Amogrotex/NSplusthon.git"
Quick Start
Basic Bot Example
from nsplusthon import SoroushClient, events
from nsplusthon.sessions import StringSession
client = SoroushClient(StringSession())
@client.on(events.NewMessage(pattern=r"(?i)hello"))
async def hello_handler(event):
await event.reply("Hello!")
client.start()
client.run_until_disconnected()
Bot Token Login
client.start(bot_token="12345:abcdef")
No API ID or API hash is required.
Usage Examples
Finite State Machine (FSM)
from nsplusthon.fsm import StatesGroup, State, MemoryStorage
class Registration(StatesGroup):
name = State()
city = State()
storage = MemoryStorage()
ctx = storage.get_context(user_id=event.sender_id, chat_id=event.chat_id)
await ctx.set_state(Registration.name)
await ctx.update_data(name="Ali")
Group Guard Moderation
from nsplusthon.moderation import GroupGuard
guard = GroupGuard(
max_flood_messages=5,
max_mentions=3,
allowed_domains=["splus.ir"],
exempt_user_ids={bot_id},
)
result = guard.inspect_message(chat_id=event.chat_id, user_id=event.sender_id, text=event.text)
if result["is_violation"]:
await event.delete()
Keyboard & Pagination
from nsplusthon import Button
from nsplusthon.paginator import Paginator
paginator = Paginator(items=["Item 1", "Item 2", "Item 3"], page_size=2)
keyboard = paginator.build_keyboard(current_page=1, callback_prefix="page")
License
GPL-3.0. Copyright (C) 2026 AmoGrotex. Upstream Telethon is MIT — see NOTICE.
Metadata
Release files for NSplusthon 1.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nsplusthon-1.8.1.tar.gz | 610.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nsplusthon-1.8.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.3 MB
Release files / nsplusthon-1.8.1.tar.gz
| Download URL | nsplusthon-1.8.1.tar.gz |
|---|---|
| Size | 610.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bda3273037c799d6d40ddb2e7c7ec52bf086294c77e29e588d2bbfe2f03f96e4
|
|
BLAKE2b-256 checksum How to use checksums |
4cad23ae42199118879401b041e3c5ed98ce8cbf0e6156fadc186b3ddaed938e
|
| 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.8.1-py3-none-any.whl
| Download URL | nsplusthon-1.8.1-py3-none-any.whl |
|---|---|
| Size | 690.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c216e27c185e46e323339a9e8c3c7a114b16645216083f29eb29913cc53ecc89
|
|
BLAKE2b-256 checksum How to use checksums |
518ed5c407f5d18b0d8ffe183cd0a5848220ded163d4d231063e3da0fdfe5d61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|