Skip to main content

NSplusthon

NSplusthon

An asynchronous Python MTProto client library for Soroush Plus.

PyPI Python License

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 MemoryStorage and persistent SQLiteStorage.
  • 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.2

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.8.2
File Size Uploaded
nsplusthon-1.8.2.tar.gz 611.5 kB Details

Built distribution (wheel)

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

Total release size: 1.3 MB

Release files / nsplusthon-1.8.2.tar.gz

Download URL nsplusthon-1.8.2.tar.gz
Size 611.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c4c6cff7ce41a31efa2dd3b87de4391d3119f0f77fc4b203c0a1aa87e61c07d0
BLAKE2b-256 checksum
How to use checksums
0ea11c88a9a4753ba2d31132b422727cd6295f0c1325df9e22b28f5ffa0750a9
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.2-py3-none-any.whl

Download URL nsplusthon-1.8.2-py3-none-any.whl
Size 691.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0accee5115619e4f15202e373b89113314708ab8b24dbb93bbd9a784c4501280
BLAKE2b-256 checksum
How to use checksums
0bcb6d9ed393bf941463f146326829ad2079424c9065ae64aa75509afcf4f07d
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

This release

1.8.2 This release

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

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