This commit is contained in:
Lukian LEIZOUR 2022-11-27 20:40:30 +01:00
parent cd8de8a386
commit 9032a0c9ac
4 changed files with 0 additions and 0 deletions

View file

@ -1,23 +0,0 @@
const request = require('request');
function getJoke(ctx, bot) {
const options = {
method: 'GET',
url: 'https://dad-jokes.p.rapidapi.com/random/joke',
headers: {
'X-RapidAPI-Key': process.env.DADJOKES,
'X-RapidAPI-Host': 'dad-jokes.p.rapidapi.com',
useQueryString: true
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
res = JSON.parse(body)
bot.telegram.sendMessage(ctx.chat.id, res.body[0].setup, {});
bot.telegram.sendMessage(ctx.chat.id, res.body[0].punchline, {});
});
}
module.exports = { getJoke };