Relatively recently I am writing notation in OOP, studying Laravel, trying to deal with DI. There is also a need to write a bot who can answer questions and perform certain actions within the entire application. I can do this, but I would like to do it correctly, and it would be ideal to issue it as a separate package.

But when I look at the task, I see that the implementation requires both data storage and working with the models that are in the application. Is it possible at all to issue a separate package .. or is it necessarily to be part of my application?

update: what is it for

The task is simply to replace the DH manager with a bot). And here it’s not just the answer to the FAQ, but also requests like: “How are my devices?” Or in the case of a finished repair, this is already setting a reference for payment, with the calculation of the cost of the parcel. Here it turns out that at some stage of communication the bot needs to pull the class method from the main application. And it would be cool to reuse it, setting up the stages of the conversation and the methods that the bot would pull. Because the main algorithm of conducting conversations, obviously should not change, only the rules and the scheme.

While the setup of the bot is not very intuitive ... and while it can be called a sketch on the knees. Well, it is tied to the application, because the constructor serves all those objects that it pulls and even the sender, who sends the user something, if the bot knows what to send, or if you do not quite understand, specify the subject of the request and ask to rephrase if He does not know that he will not send anything, and the message will not be answered ... and the person will already be engaged in it.

PS>

I have nothing against service center managers, but they often answer the same questions and do the same operations. I think it is extremely correct to leave them only "interesting" questions.

  • Em. No need to enter the correspondence in the answer, just edit your question. - AK ♦
  • Yes, yes. Thank you. - Mars

1 answer 1

I can do this, but I would like to do it correctly, and it would be ideal to issue it as a separate package.

Let's start in order. Select in some package it makes sense the code that will be reused.

Do you work in a web-studio that bakes five projects a month like pies and you need bots functionality in every second?

If yes, then there is a need to allocate a bot in a separate package, but if you don’t have a one-time project, you can not allocate it.

Somewhere I even met an approximate approach to reusing the code: the first time just write the code, the second time we take from the previous project, and the third time we draw up a separate package. That is, only for the third time we are starting to understand which functions will be included in the package, and which ones will be left out as specific for a specific project.

If you have a one-time project, then generally you can start by searching for ready-made bots. Found five projects, chose one for yourself - and use it for health. Or not found - write your own.

If you want to do something for learning (educational purposes), then you can either take the “make a one-off project” or try to make a package.

You choose, you know it better. The only thing that will be commendable is to make the project open to the githaba (especially if there haven't been such yet) so that others can (fork and) later use some parts in their projects.

Is it possible to separate the bot from the application - I think it is quite possible. In this case, it will be possible to make abstractions that do not depend on transport (and make a bot for telegrams, for facebook and other things), you can separate the specifics of the application (set up questions through the database).

If you do not understand what and how to arrange in the module - first, just write a working application. Your question now, not only to you yourself seems too general, but to the rest of stackoverflow participants. When the code is ready, you will either understand it yourself, or you can already ask a more detailed question.

  • Yes, apparently until it is part of the application, and then a separate package. It seemed to me not the best option, to write and rewrite. - Mars
  • But apparently at my level of development .. this is the surest way: to write and rewrite. - Mars