Skip to main content

Easy conversation handler for pyrogram mtproto library...

Project description

#Conversation in pyrogram

from pyrocon import patch

patch(client, clear, timeout, stop_cmd, placeholder)

client : 'Client' required parameter ( Pyrogram Client )

clear : 'bool' required parameter set true if you want delete msg after get answer(Default to False)

timeout : 'int' optional parameter (Default to 30 sec)

stop_cmd : 'str' optional parameter (Default to /cancel)

placeholder : 'str' optional parameter (Custom placeholder for Forcereply)

============================================================

patch.ask(update, text, cquery, filter)

update : 'Message/CallbacQuery' required parameter (Where to start conv..)

text : 'str' Required parameter (Question to ask)

cquery : 'bool' Parameter set True when asking with inline buttons (Default to False)

filter : Pyrogram filters optional parameter (Default to filters.text)

============================================================

#using example:

#Create quiz instance

  from pyrocon import patch
  from pyrogram import Client,filters
  
  app = Client(...)
  quiz = patch(app)

  @app.on_message(..)  
  async def _(client,message):
    answer = await quiz.ask(message,text)
    if answer.text:
     print(answer.text)
    await answer.reply("I got answer..")

  app.run()

#handle text messages

  answer = await quiz.ask(message,text)
  if answer.text:
    print(answer.text)
  await answer.reply("I got answer..")

#handle CallbackQuery / inline buttons

  answer = await quiz.ask(CallbacQuery,text,cquery=True)
  if answer.text:
    print(answer.text)
  await answer.reply("I got answer..")

#Using pyrogram filters

single filter

  from pyrogram import filters

  answer = await quiz.ask(update,text,filter=filters.photo)
  print(answer.photo)

multiple filters (same as pyrogram)

  from pyrogram import filters

  answer = await quiz.ask(update,text,filter=(filters.photo & filters.group))
  print(answer.photo)

#Handle any kind of errors

  answer = await quiz.ask(update,text)
  if answer.error:
    print(answer.error)

#Handle timeout Errors

  answer = await quiz.ask(update,text)
  if answer.timeout:
    print(answer.timeout)

#Handle cancellation Errors

  answer = await quiz.ask(update,text)
  if answer.cancel:
    print(answer.cancel)

Facts:

#if successful answer is Message object otherwise an error

#answer must be in reply to orginal message and should be a text message otherwise message will be ignored

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

pyrocon-2.0.6.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

pyrocon-2.0.6-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pyrocon-2.0.6.tar.gz.

File metadata

  • Download URL: pyrocon-2.0.6.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pyrocon-2.0.6.tar.gz
Algorithm Hash digest
SHA256 a8f4c091437a202aa134c7c7a39cbfd825c44b8f6640857ba302197c61aff02b
MD5 9dcc6cda11e4ad15b5dc22d0500d5e1a
BLAKE2b-256 cefce5384487ab39577b72abbc718a4999005c35514ff4248dd1e9066caea4f3

See more details on using hashes here.

File details

Details for the file pyrocon-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyrocon-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pyrocon-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4f365a249121aeb245263e4e5a67e3985e24942800fa00c1c929987f529477b3
MD5 0d3756e693888cb2a5204ff38df3eac3
BLAKE2b-256 4f46244ce555547e2c32c197ce9b5588caaa3a5b0fe7c8f7936593c39c0b0f07

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