Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrostates-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Pyrostates-1.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pyrostates-1.0.1.tar.gz.

File metadata

  • Download URL: pyrostates-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for pyrostates-1.0.1.tar.gz
Algorithm Hash digest
SHA256 483c2521de70c5ee1ad5386af30dff1541c3b57aaef6c4a03312c01e88bda539
MD5 205685b5e747ee2147c92d328b8e212a
BLAKE2b-256 d99ed8a58890336ac4a9a78a0e79c6b8b992a1e6033404fdb9f2b60ec13692b2

See more details on using hashes here.

File details

Details for the file Pyrostates-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: Pyrostates-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for Pyrostates-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17ec2b3988fe56e48f548469e08b5e4c3c44f90b39e5e8690dd2f546f8f431f1
MD5 c3d1dcd73f1aa234798253a73014ca6c
BLAKE2b-256 c2d50c379d48e19129e4fe534b4301e213e86bdb065800da1dfb72b54c10869f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page