Answer the question
In order to leave comments, you need to log in
How to make a function generator in python?
I want to make a function that can generate other functions for the VKontakte bot.
The bottom line is that a person writes to the bot: create command, after which the bot will ask him what phrase to answer, and what to answer. How can this be implemented? Are there any libraries to implement this functionality?
Here is the code that should be generated:
vk.method("messages.send", {"peer_id": event.object.peer_id, "message": message,"random_id": 0})
Answer the question
In order to leave comments, you need to log in
Of course, this can be implemented on lambdas, but do you need to store these commands, and not just produce functions in memory?
I don't know how serious you are about this, but it clearly requires a database. The table should store the question and the answer. Then there will be a general function, at the input the question for which it is looking for an answer in the database, that's it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question