Answer the question
In order to leave comments, you need to log in
How can the following system be automated?
Hi all. Got a question. I have a bot that is set for a specific task. Is it possible to make it so that I can do many others on this basis, as in special sites for creating bots. Example: the user sends a command, enters some data, his API key from the account, and a bot is attached to his account. And so with many other users. How to do this so as not to create a bunch of folders with the same files. It would also be interesting to know how to do updates in such a system. For example, I made an update in the main code, and it will be updated for all users.
Answer the question
In order to leave comments, you need to log in
It is possible, but, objectively, if you succeed, it will not be very soon
The code can be run from one place and files, the launch arguments on the command line can determine the identifier of the owner of the instance, all files with data or whatever you have there, let them be stored in subdirectories with a name equal to this identifier (but it’s better to store it in the database, of course, it will be stupidly more convenient) .
Be careful with updates, more precisely with restarting the bot during updates or maintenance. You either need to make the bot so that you can safely 'stop' it at any time (you need to understand that no operation with files on the disk is instantaneous), i.e. introduce mechanisms to temporarily stop them while waiting for the end of critical processes for this time (and appropriate monitoring for you so that you can evaluate what you are waiting for).
I did the same logic. One bot file for everyone (copy-pasting a bunch is not gentle), next to the bot file, I put the usual json where personal bot tokens arrive and save from the user's admin panel. Before starting, I read this json in the bot file and go through the cycle and create a bot for each token - and that's it) In order for the bot to reboot if a new token arrives from the user, I set up monitoring for changes in the file on the node through the pm2 manager.
well, make a database and store all the data there and start from the data as a bot
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question