fix ttl on cahce

This commit is contained in:
karl.hudgell 2020-06-24 10:32:14 +01:00
parent fd9446db1b
commit 1e00780395

13
app.js
View File

@ -61,6 +61,11 @@ bot.on('message', (msg) => {
bot.sendMessage(msg.chat.id, "I love you too " + msg.from.first_name);
}
const thankYou = "thank you " + name.toLowerCase();
if (msg.text && msg.text.toString().toLowerCase().includes(thankYou)) {
logger.info("ID - " + msg.from.id + " First Name - " + msg.from.first_name + " Said thank you");
bot.sendMessage(msg.chat.id, "You're welcome " + msg.from.first_name);
}
const footballToday = "football today";
if (msg.text && msg.text.toString().toLowerCase().includes(footballToday)) {
@ -75,7 +80,7 @@ bot.on('message', (msg) => {
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
useQueryString: true
},
ttl: 18000 //5 hours
ttl: 18000000 //5 hours
};
cachedRequest(options, function (error, response, body) {
@ -108,16 +113,16 @@ bot.on('message', (msg) => {
var options = {
method: 'GET',
url: 'https://joke3.p.rapidapi.com/v1/joke',
qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' },
// qs: { tz: 'Europe/London', leagues: '8', include: 'localTeam,visitorTeam' },
headers: {
'x-rapidapi-host': 'joke3.p.rapidapi.com',
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
useQueryString: true
},
ttl: 18000 //5 hours
// ttl: 18000 //5 hours
};
cachedRequest(options, function (error, response, body) {
request(options, function (error, response, body) {
if (error) throw new Error(error);
let jsonBody = JSON.parse(body)
bot.sendMessage(msg.chat.id, jsonBody.content)