You are on page 1of 1

const { Telegraf, Markup } = require('telegraf');

process.env.BOT_TOKEN = '��� ������';


const bot = new Telegraf(process.env.BOT_TOKEN);

bot.command('start', ctx=>ctx.reply('Hi, '+ ctx.message.from.first_name));

bot.launch();

const fs = require('fs');
let rawdata = fs.readFileSync('data.json');
const quotes = JSON.parse(rawdata);

function getQuote(){
let rnd = Math.round(Math.random()*(quotes.length-1));
console.log(rnd);
return quotes[rnd];
}

bot.hears('next',ctx=>{ const q=getQuote();ctx.reply(q.q + q.a )},

Markup.keyboard(['next'])
.oneTime()
.resize()
)

You might also like