///////////////////////////// CONNECT MONGOOSE
const mongo = require('mongoose');
const botSchema = new mongo.Schema({
uid: Number,
id: Number,
token: String,
name: String
})
const $bot = mongo.model("Bots", botSchema);
module.exports = {
$bot,
mongo
}
////////////////////////////// MAIN
const { mongo } = ...
bot.hears('test', async(ctx) => {
const data = await ctx.dbConnection. ???
});
for (const processing of bots) {
const botInstance = new Telegraf(processing.token)
botInstance.use(bot)
botInstance.context.dbConnection = mongo.connect(`mongodb://localhost:27017/bot-${processing.id}`);
botInstance.catch(console.log)
botInstance.launch()
}