Skip to main content

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

Metadata

Release files for Pyrostates 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Pyrostates 1.0.1
File Size Uploaded
pyrostates-1.0.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Pyrostates 1.0.1
File Interpreter ABI Platform
Pyrostates-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / pyrostates-1.0.1.tar.gz

Download URL pyrostates-1.0.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
483c2521de70c5ee1ad5386af30dff1541c3b57aaef6c4a03312c01e88bda539
BLAKE2b-256 checksum
How to use checksums
d99ed8a58890336ac4a9a78a0e79c6b8b992a1e6033404fdb9f2b60ec13692b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.2

Release files / Pyrostates-1.0.1-py3-none-any.whl

Download URL Pyrostates-1.0.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17ec2b3988fe56e48f548469e08b5e4c3c44f90b39e5e8690dd2f546f8f431f1
BLAKE2b-256 checksum
How to use checksums
c2d50c379d48e19129e4fe534b4301e213e86bdb065800da1dfb72b54c10869f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page