I'm trying to build a Telegram bot, I'm using the following npm package: https://www.npmjs.com/package/node-telegram-bot-api
I have the following project structure:
In my app.js
file I do: const bot = new TelegramBot(token, {polling: true});
. I would like to share this bot
instance with the index.js
files, so that in the index.js
files I can do something like:
bot.onText(/\/time (.+)/, (msg, match) => {
});
I'm not sure how I can acomplish this, the only way I can think of is doing this by using module.exports on app.js file, but I'm not sure if that is the correct way of doing it.
-edit-
In the app.js file I want to do:
require('./plugins/time')
require('./plugins/weather')
and then type node app.js
to run the bot.