D
D
Duzive2019-09-18 22:25:03
Python
Duzive, 2019-09-18 22:25:03

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})

I don't know much about this topic, I hope for your help;)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
i1yas, 2019-09-18
@duzive

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 question

Ask a Question

731 491 924 answers to any question