python library Client for iranian messager sroosh
Project description
pysroosh
Python client for Sroosh, built on Telethon (MTProto).
Install
pip install pysroosh
Optional extras:
pip install pysroosh[redis]
pip install pysroosh[postgres]
Quick start
from pysroosh import Client
bot = Client("my_session")
@bot.on_message()
async def handler(client, message):
await message.reply("Hello!")
bot.run()
Sync usage
from pysroosh.sync import Client
bot = Client("my_session")
@bot.on_message()
def handler(client, message):
message.reply("Hello!")
bot.run()
Events
on_messageon_editedon_callback_queryon_inline_queryon_chat_actionon_user_updateon_message_deletedon_message_readon_error
Filters
from pysroosh import filters
@bot.on_message(filters.text & filters.private)
@bot.on_message(filters.command("start"))
@bot.on_message(filters.photo | filters.video)
Buttons
from pysroosh import Button
keyboard = Button.build_inline([
Button.inline("Option 1", b"opt1"),
Button.inline("Option 2", b"opt2"),
])
await bot.send_message(chat_id, "Choose:", buttons=keyboard)
FSM
from pysroosh.fsm import State, StateMachine
from pysroosh.storage import MemoryStorage
storage = MemoryStorage()
fsm = StateMachine(storage)
class Form:
name = State()
age = State()
Scheduler
from pysroosh.scheduler import MessageScheduler
scheduler = MessageScheduler(bot)
scheduler.schedule_interval("hourly", chat_id, "Hello!", interval=3600)
Admin
await bot.admin.ban_user(chat_id, user_id)
await bot.admin.mute_user(chat_id, user_id)
await bot.admin.purge_messages(chat_id, limit=100)
AFK
bot.afk.set_afk(True, reason="lunch")
@bot.on_message(filters.private & filters.incoming)
async def auto_reply(client, message):
await bot.afk.handle(message)
Mirror
from pysroosh.mirror import MessageMirror
mirror = MessageMirror(bot)
mirror.add_route(source=-100123, targets=[-100456], add_prefix="[Mirror]")
await mirror.start()
CLI
pysroosh run bot.py
pysroosh validate bot.py
pysroosh version
pysroosh session-info my_session.session
Notes
This library uses Telethon as its transport, connecting with the public
Sroosh api_id/api_hash by default (documented by the SrooshJS project).
You may pass your own credentials to Client(session, api_id=..., api_hash=...).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysroosh-2.0.0.tar.gz.
File metadata
- Download URL: pysroosh-2.0.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb71fa0e025fa62f273f820f25b38e0924f2c44c1978dbb2b2dca7ddf40862fe
|
|
| MD5 |
3a85f0094da4339002d9f1a72e8604fc
|
|
| BLAKE2b-256 |
723f4f0760663d422c8528f984b9cb1f13076623eeabd43157d4c94bc7725d9e
|
File details
Details for the file pysroosh-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pysroosh-2.0.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31b3b287880a8fb40e35e0bc9d68797e4e75483dd4676f5d976798b40b0832be
|
|
| MD5 |
4757bbdc1d5adb2918903f0279d26997
|
|
| BLAKE2b-256 |
e5ef3ad2cfc04cd8c1271e0ace841094aaf83c378a123bd16d32d175baba7a67
|