pythonpyrogram

Want to Take User Inputs in Pyrogram


I want to take user input in pyrogram. Like:

bot: What do u wanna say?

user: hola!

bot: u said, hola!

my code:

import csv

bot = Client("bot")


@bot.on_message(filters.command('start'))
def start(bot, msg):
    x=input
    bot.send_message(msg.chat.id,text=x)
    
bot.run()

like doing input() in Python. (I don't want to save them locally, just to cache them.)

How can I do that?


Solution

  • A conversation-like feature is not available yet in Pyrogram. One way to do that is saving states into a dictionary using user IDs as keys. Check the dictionary before taking actions so that you know in which step your users are and update it once they successfully go past one action.

    https://t.me/pyrogramchat/213488