K
K
KeterVik2018-08-22 20:45:05
Python
KeterVik, 2018-08-22 20:45:05

How to save text using regular expressions or commands?

We want the user to enter "first: message" in the chat and this is stored in a variable for later use with the command. In addition to text, pictures and files should also be saved, but I don’t think regular expressions will work here in this case. Is it possible to write /command and the next message after the command would be stored in a variable? Google did not help specifically for this task, so I am writing here again. Below is something that I tried to implement only in the case of text input, but due to ignorance of the regexps, I never wrote it, but the essence of what I need is here.

texts = ""
@bot.message_handler(regexp="first[a-zA-z]+")
def handle_text(message):
    texts = message.text
    
@bot.message_handler(commands=['one'])
def handle_text(message):
    bot.send_message(message.from_user.id, texts)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2018-08-22
@trofimovdev

Save the object itself message. It stores both the message, and pictures, and other information about the sender.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question