Answer the question
In order to leave comments, you need to log in
How to write a constructor for telegram bots?
Hello. Such a task: you need to write a telegram bot to create other telegram bots. All bots must run on webhooks. Each bot will have the same functionality: the user sends a command, and the bot responds with something. The creator of the bot, respectively, indicates which commands the bot should respond to.
I don't quite understand how I should implement this. When I wrote bots before, I had a bot.js file. I performed node bot.js
. The bot started working. I also had nginx, which handled webhooks.
It turns out that I need to create files bot1.js, bot2.js, etc. for each user? And this is provided that each bot will have a different code. Or is there a better solution?
Answer the question
In order to leave comments, you need to log in
In the webhook, add the botid parameter. Each bot has its own parameter.
On the server side, when webhooking, see which bot the request came for.
Next, read (from somewhere) the parameters / settings of this bot and execute its logic.
In the bot settings, you describe the rules or sets of commands that the bot must execute.
It's hard to say in more detail without seeing the whole problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question