-5

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?

Aditya
  • 3
  • 3
  • 3
    Welcome to Stack Overflow. Please read [ask] and https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users. In particular: for a question like this, you are expected to check the documentation first. If you still have a question after reading the documentation, you should ask in a way that a) proves to others that you read the documentation; b) explains exactly why reading the documentation did not solve the problem. – Karl Knechtel Sep 30 '21 at 07:34
  • 1
    Does this answer your question? [How to read keyboard-input?](https://stackoverflow.com/questions/5404068/how-to-read-keyboard-input) – Taylor Cochran Sep 30 '21 at 07:35
  • 1
    Please show what you have tried. – PCM Sep 30 '21 at 07:36
  • 1
    @taylorcochran no bro this is totally different – Aditya Sep 30 '21 at 07:38
  • If you have searched the python docs, you would get your solution. – PCM Sep 30 '21 at 07:39
  • @PCM i have searched python docs and pyrogram docs both – Aditya Sep 30 '21 at 07:41

3 Answers3

0

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

ColinShark
  • 1,047
  • 2
  • 10
  • 18
-2

something like :

print("bot:What do u wanna say?\nUser:")
message = input()
print("bot: u said",message)
-2

Firstly we print out a message asking what the user wants to say like this:

print("What do u wanna say?")

Then we would like to get the users input with the input() command and get the users input and then print out a message saying "u said, (input)" and here is how you can do that:

print("u said, "+input(": "))

And finally the full code:

print("What do u wanna say?")
print("u said, "+input(": "))
  • 2
    No, this is different. – PCM Sep 30 '21 at 07:33
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 30 '21 at 09:54