Answer the question
In order to leave comments, you need to log in
How to return the result of the decorator?
The situation is this, it was necessary to return the result of the work of the following decorator from the Pyrogram module:
@app.on_message(filters.text)
def message(client, message):
msg = message.text
return msg
However, it is not possible to do this according to the principle a = message() , since I do not need to pass any arguments to this function, because they already appear, as I understand it, as a result of the work of the on_message decorator. I would really appreciate if someone could suggest what I can do about this.
Answer the question
In order to leave comments, you need to log in
Well, for starters, what do you understand by "the result of the decorator's work"?
The result of the decorator is a function, if anything!
Those. the code
@app.on_message(filters.text)
def message(client, message):
msg = message.text
decorator = app.on_message(filters.text)
def message(client, message):
msg = message.text
# функция заменяется на результат работы декоратора - на ту же самую или другую функцию
message = decorator(message)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question