A Python library to handle steps in pyrogram framework.
Project description
Pyrostep
A Python library to handle steps in pyrogram framework.
Pyrostep helps you to use pyrogram:
- very easy step handling, waiting for answer, ...
- change connection timeout, retries, etc.
Updated to 2.10.8
- connection.session_max_retries completely changed.
Updated to 2.9.8
Now pyrostep is fully asyncronized ...
-
wait_for bug fixed on Python v3.10.x.
-
safe_idle changed, now you dont need this.
-
MetaStore.delete_item removed.
-
MetaStore.clear changed.
-
unregister_steps bug fixed, now cancel
asyncio.Futureobject. -
clear changed, now blocks listener until complete clearing.
Updated to 2.8.2
In this update, pyrostep completely changed ...
-
New Methods:
- safe_idle
- install
- MetaStore method's name changed.
- wait_for
-
Renamed Methods:
- change_store to change_root_store
-
Removed Methods:
- listen_on_the_side
- ask
- ask_wait
-
Removed Package:
- filters
install / update
python3 -m pip install -U pyrostep
Learn
to start with pyrostep, you have to do two steps:
- import pyrostep
- listen on which client you want
import pyrostep
# ...
cli = Client(...)
pyrostep.listen(cli)
step handling
step handling have two methods:
pyrostep.register_next_step(...)pyrostep.unregister_steps(...)
register_next_step register next step, and unregister_steps removes step for user.
see example: ( see examples )
# ...
async def step1(client, msg):
await msg.reply(
"Send your name?"
)
pyrostep.register_next_step(
msg.from_user.id,
step2
)
async def step2(client, msg):
await msg.reply(
f"Your name is {msg.text}"
)
# ...
wait_for method
if you dont like step handling, can use this method.
see example: ( see examples )
# ...
async def get_name(client, msg):
await msg.reply(
"Send your name?"
)
answer = await pyrostep.wait_for(
msg.from_user.id
)
await msg.reply(
f"Your name is {answer.text}"
)
# ...
Other packages and shortcuts
Connection
connection_max_retries method:
Change connection max retries. (default 3)
invoke_max_retries method:
Change invoke max retries. (default 5)
session_start_timeout method:
Change start timeout. (default 1)
session_max_retries method:
Change session max retries.
Shortcuts
import shortcuts:
from pyrostep import shortcuts
Now see methods:
split_list splites lst list:
>>> shortcuts.split_list([1, 2, 3, 4, 5, 6], 2)
# [[1, 2], [3, 4], [5, 6]]
>>> shortcuts.split_list([1, 2, 3], 2)
# [[1, 2], [3]]
keyboard creates ReplyKeyboardMarkup from your list:
buttons = [
[
["Top Left"], ["Top Right"]
],
[
["Bottom | Request Contact", True, "request_contact"]
]
]
kb = shortcuts.keyboard(buttons)
inlinekeyboard creates InlineKeyboardMarkup from your list:
buttons = [
[
["Top Left", "data_1"], ["Top Right", "data_2"]
],
[
["Bottom", "Your URL", "url"]
]
]
ikb = shortcuts.inlinekeyboard(buttons)
validation_channels checks user already in channels or not:
user_id = 56392019
channels = [-102792837, -10823823, 'channel_username']
is_joined = await validation_channels(
app, user_id, channels
)
# ...
async def invite(app, id, channels) -> None:
print(
f"User {id} is not member of channels ({channels})"
)
is_joined = await validation_channels(
app, user_id, channels,
invite_func=invite
)
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 pyrostep-2.10.8.tar.gz.
File metadata
- Download URL: pyrostep-2.10.8.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d52d01d0f112ce916a25b017567fa1b10cb93e85ed24cf66d646e75efbfc87a8
|
|
| MD5 |
89a8aa5945d65be79259d98e367f9066
|
|
| BLAKE2b-256 |
182133cc7a93a9e6eb5f5b69f590133a61388aea95bd6f4349712a5c89a0b93a
|
File details
Details for the file pyrostep-2.10.8-py3-none-any.whl.
File metadata
- Download URL: pyrostep-2.10.8-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7a3b94846f11e1e9fc1436822d68276e0e042617ab61c7e5f717ed05372219d
|
|
| MD5 |
17391e445e966b087f0b2fc2f3761386
|
|
| BLAKE2b-256 |
dc35259c8e9717022f62a6176b3b4127711e96d9e87d62516f42c12270730ebf
|