commit
This commit is contained in:
parent
cd8de8a386
commit
9032a0c9ac
4 changed files with 0 additions and 0 deletions
23
dadJokes.js
23
dadJokes.js
|
@ -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 };
|
Loading…
Add table
Add a link
Reference in a new issue