A state handling extension for Pyrogram
Project description
Pyrostates
A state handling extension for Pyrogram
from pyrogram import Client, filters
from pyrostates import at_state, set_state, del_state
app = Client("my_account")
@app.on_message(at_state(None) & filters.private & filters.text)
async def home_state(_, message):
await message.reply("Hello, I'm the conversation bot. What is your name?")
set_state(message, "NAME")
@app.on_message(at_state("NAME") & filters.private & filters.text)
async def name_state(_, message):
name = message.text
await message.reply(f"Nice to meet you, {name}! How old are you?")
set_state(message, "AGE")
@app.on_message(at_state("AGE") & filters.private & filters.text)
async def age_state(_, message):
age = message.text
await message.reply(f"You are {age} years old, good for you! Have a nice day!")
del_state(message)
app.run()
Pyrostates is a ready, easy and elegant extension for the Pyrogram framework. It enables you to handle the states of your users in the most simple, efficient and reliable way.
Installing
pip3 install pyrostates
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
pyrostates-0.1.0.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for Pyrostates-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85f70a866b69b2f4ebed27e7290dc416bbbf317e34f2def080bf39416b7bf3d6 |
|
MD5 | c5db09cc84217beae85a8a818af14e02 |
|
BLAKE2b-256 | e205670853e69d29dfc7ef3869652c8713c74d34f6d32021e6b3e5f53086a9fc |