aiosplus 🚀
aiosplus is a modern, high-performance, asynchronous, type-safe, and modular Python framework for the Soroush Plus Bot API (مستندات پلتفرم بات سروشپلاس).
✨ Features | ویژگیهای کلیدی
- ⚡ Asynchronous First: Built from the ground up on Python's
asyncioandhttpxfor maximum concurrency and throughput. - 🛡️ Pydantic V2 Powered: Complete, strictly-typed data models with automatic JSON validation and serialization for all API entities.
- 🎯 Aiogram 3 Style Architecture: Modular
Dispatcher,Routerblueprints,EventObserver, and hierarchical middleware pipelines. - 🪄 Expressive Magic Filters (
F): Clean and readable query filtering likeF.text == "hello",F.from_user.id == 123,F.data.startswith("action_"). - 🧠 Finite State Machine (FSM): Built-in state management with
StatesGroup,State,FSMContext, andMemoryStorage. - ⌨️ Fluent Keyboard Builders: Chainable
InlineKeyboardBuilderandReplyKeyboardBuilderfor dynamic button layouts. - 📦 100% Soroush Plus Bot API Coverage: Full support for messages, photos, audio, documents, videos, voice notes, video notes, media albums, contacts, locations, stickers, bot commands, webhooks, and long polling.
- 🔤 Rich Formatting Utilities: Helpers for HTML and MarkdownV2 text formatting and character escaping.
📦 Installation | نصب
Install using pip:
pip install aiosplus
Or install with FastAPI webhook support:
pip install "aiosplus[fastapi]"
🚀 Quickstart | شروع سریع
Create your first bot in fewer than 20 lines of code:
import asyncio
from aiosplus import Bot, Dispatcher
from aiosplus.filters import Command
from aiosplus.types import Message
# Initialize Bot and Dispatcher
bot = Bot(token="YOUR_BOT_TOKEN_HERE")
dp = Dispatcher()
# Handle /start command
@dp.message(Command("start"))
async def start_handler(message: Message) -> None:
user_name = message.from_user.first_name if message.from_user else "کاربر"
await message.answer(f"سلام {user_name}! خوش آمدید به ربات سروشپلاس.")
# Echo text messages
@dp.message()
async def echo_handler(message: Message) -> None:
if message.text:
await message.answer(f"شما گفتید: {message.text}")
async def main() -> None:
print("Bot is running...")
await dp.start_polling(bot, drop_pending_updates=True)
if __name__ == "__main__":
asyncio.run(main())
🧩 Architecture Overview | ساختار معماری
aiosplus/
├── bot/ # Core Bot client handling API requests & file transfers
├── client/ # Async HTTP session & URL construction (HTTPX)
├── dispatcher/ # Dispatcher, Routers, Event Observers, & Pipelines
├── enums.py # ParseMode, ChatType, MessageEntityType, ChatAction, etc.
├── exceptions.py # Comprehensive API & network exception hierarchy
├── filters/ # Command, Text, MagicFilter (F), ChatType, State filters
├── fsm/ # Finite State Machine (StatesGroup, FSMContext, MemoryStorage)
├── middlewares/ # Outer & Inner middleware abstract bases
├── types/ # Pydantic v2 data models for all Soroush Plus objects
└── utils/ # Keyboard builders, text formatters, & webhook helpers
📚 Guides & Examples | راهنما و مثالها
Explore ready-to-run examples in the examples/ directory:
- Echo Bot: Basic message handling and command dispatching.
- Keyboards Bot: Multi-row inline keyboards, callback query alerts, and reply menus.
- FSM Survey Bot: Multi-step form data collection using
StatesGroupandFSMContext. - Media & Files Bot: Uploading photos, sending albums (
send_media_group), and downloading user files. - FastAPI Webhook: High-throughput production webhook server with FastAPI.
⌨️ Dynamic Keyboards Example
from aiosplus.utils import InlineKeyboardBuilder
builder = InlineKeyboardBuilder()
builder.button(text="وبسایت", url="https://splus.ir")
builder.button(text="تایید", callback_data="confirm")
builder.button(text="انصراف", callback_data="cancel")
builder.adjust(1, 2) # Row 1: 1 button, Row 2: 2 buttons
await message.answer("گزینه مورد نظر را انتخاب کنید:", reply_markup=builder.as_markup())
🧠 Finite State Machine (FSM) Example
from aiosplus import State, StatesGroup
from aiosplus.fsm.context import FSMContext
from aiosplus.filters import StateFilter
class Form(StatesGroup):
name = State()
age = State()
@dp.message(Command("register"))
async def start_register(message: Message, state: FSMContext) -> None:
await state.set_state(Form.name)
await message.answer("لطفاً نام خود را وارد کنید:")
@dp.message(StateFilter(Form.name))
async def process_name(message: Message, state: FSMContext) -> None:
await state.update_data(name=message.text)
await state.set_state(Form.age)
await message.answer("سن خود را وارد کنید:")
📡 API Methods Supported | متدهای پشتیبانیشده
| Method | Soroush Plus Endpoint | Return Type |
|---|---|---|
get_me |
/getMe |
User |
send_message |
/sendMessage |
Message |
forward_message |
/forwardMessage |
Message |
copy_message |
/copyMessage |
MessageId |
send_photo |
/sendPhoto |
Message |
send_audio |
/sendAudio |
Message |
send_document |
/sendDocument |
Message |
send_video |
/sendVideo |
Message |
send_animation |
/sendAnimation |
Message |
send_voice |
/sendVoice |
Message |
send_video_note |
/sendVideoNote |
Message |
send_media_group |
/sendMediaGroup |
list[Message] |
send_location |
/sendLocation |
Message |
send_contact |
/sendContact |
Message |
send_sticker |
/sendSticker |
Message |
send_chat_action |
/sendChatAction |
bool |
get_file |
/getFile |
File |
download_file |
/file/bot<token>/<path> |
Path / BinaryIO |
answer_callback_query |
/answerCallbackQuery |
bool |
set_my_commands |
/setMyCommands |
bool |
get_my_commands |
/getMyCommands |
list[BotCommand] |
delete_my_commands |
/deleteMyCommands |
bool |
edit_message_text |
/editMessageText |
Message / bool |
edit_message_caption |
/editMessageCaption |
Message / bool |
edit_message_media |
/editMessageMedia |
Message / bool |
edit_message_reply_markup |
/editMessageReplyMarkup |
Message / bool |
delete_message |
/deleteMessage |
bool |
get_updates |
/getUpdates |
list[Update] |
set_webhook |
/setWebhook |
bool |
delete_webhook |
/deleteWebhook |
bool |
get_webhook_info |
/getWebhookInfo |
WebhookInfo |
🧪 Testing & Quality Assurance
Run the test suite with coverage:
pytest
Run type checking and code formatting:
mypy aiosplus tests
ruff check .
ruff format .
📄 License
This project is licensed under the terms of the MIT License.
Metadata
Release files for aiosplus 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiosplus-0.1.0.tar.gz | 47.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiosplus-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 94.0 kB
Release files / aiosplus-0.1.0.tar.gz
| Download URL | aiosplus-0.1.0.tar.gz |
|---|---|
| Size | 47.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf65bbc0473bffa8525c5aa61855162e5d1815c32c98fc271a030bd466c40a48
|
|
BLAKE2b-256 checksum How to use checksums |
9085410d19cdf0e60d029a6ca0ba4b71f49de5934e178dce5b646f948d023922
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency logRelease files / aiosplus-0.1.0-py3-none-any.whl
| Download URL | aiosplus-0.1.0-py3-none-any.whl |
|---|---|
| Size | 46.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a1e589f6b05fdfa4dd2714f9f345da2b23a8bb2a23014fa81c42ee7d9ac8277
|
|
BLAKE2b-256 checksum How to use checksums |
554836a07c7dfcfd268fa3b73ece6cb489a084aaee1c22cbe9adf23c919c2f78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 1, 2026.
Transparency log