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.10
- connection.connection_max_retries AttributeError fixed.
- different loop error fixed.
Updated to 2.10.8
-
connection.session_max_retries completely changed.
install / update
python3 -m pip install -U pyrostep
Learn
to start with pyrostep, you have to do two steps:
- import pyrostep
- listen on client which 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 registers 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.10.tar.gz.
File metadata
- Download URL: pyrostep-2.10.10.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
413ac57035533fc2870ef3bfb5db2da9ce482dbdb4f63f367ad5ae944cff5701
|
|
| MD5 |
210fa4acbe63029fd7a8081d6bfddfea
|
|
| BLAKE2b-256 |
701f17eb707a12b7aed6270ab8915c8e81cbec92233739b50accff1c43e876dd
|
File details
Details for the file pyrostep-2.10.10-py3-none-any.whl.
File metadata
- Download URL: pyrostep-2.10.10-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d97e0a55b308d637617cd49f85fc07fc79ddd3f26f7424d9c181ecb87214ab22
|
|
| MD5 |
2e6ffadbfd76de5cdb52db1f2b88e2db
|
|
| BLAKE2b-256 |
551c439a139a672aa7422d52ea251389cbe453631f0c20956e7cf9696cbe7775
|