Metadata-Version: 2.4
Name: pysroosh
Version: 2.0.0
Summary: python library Client for iranian messager sroosh
Home-page: https://github.com/blaygamesoffcial-hash/pysroosh
Author: its_blay
Author-email: its_blay <blaygamesoffcial@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/blaygamesoffcial-hash/pysroosh
Project-URL: Repository, https://github.com/blaygamesoffcial-hash/pysroosh
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: AsyncIO
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: telethon>=1.34.0
Provides-Extra: redis
Requires-Dist: redis; extra == "redis"
Provides-Extra: postgres
Requires-Dist: asyncpg; extra == "postgres"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# 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

```python
from pysroosh import Client

bot = Client("my_session")

@bot.on_message()
async def handler(client, message):
    await message.reply("Hello!")

bot.run()
```

### Sync usage

```python
from pysroosh.sync import Client

bot = Client("my_session")

@bot.on_message()
def handler(client, message):
    message.reply("Hello!")

bot.run()
```

## Events

- `on_message`
- `on_edited`
- `on_callback_query`
- `on_inline_query`
- `on_chat_action`
- `on_user_update`
- `on_message_deleted`
- `on_message_read`
- `on_error`

## Filters

```python
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

```python
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

```python
from pysroosh.fsm import State, StateMachine
from pysroosh.storage import MemoryStorage

storage = MemoryStorage()
fsm = StateMachine(storage)

class Form:
    name = State()
    age = State()
```

## Scheduler

```python
from pysroosh.scheduler import MessageScheduler

scheduler = MessageScheduler(bot)
scheduler.schedule_interval("hourly", chat_id, "Hello!", interval=3600)
```

## Admin

```python
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

```python
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

```python
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=...)`.
