fix ttl on cahce
This commit is contained in:
parent
fd9446db1b
commit
1e00780395
13
app.js
13
app.js
@ -61,6 +61,11 @@ bot.on('message', (msg) => {
|
|||||||
bot.sendMessage(msg.chat.id, "I love you too " + msg.from.first_name);
|
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";
|
const footballToday = "football today";
|
||||||
if (msg.text && msg.text.toString().toLowerCase().includes(footballToday)) {
|
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,
|
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
||||||
useQueryString: true
|
useQueryString: true
|
||||||
},
|
},
|
||||||
ttl: 18000 //5 hours
|
ttl: 18000000 //5 hours
|
||||||
};
|
};
|
||||||
|
|
||||||
cachedRequest(options, function (error, response, body) {
|
cachedRequest(options, function (error, response, body) {
|
||||||
@ -108,16 +113,16 @@ bot.on('message', (msg) => {
|
|||||||
var options = {
|
var options = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: 'https://joke3.p.rapidapi.com/v1/joke',
|
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: {
|
headers: {
|
||||||
'x-rapidapi-host': 'joke3.p.rapidapi.com',
|
'x-rapidapi-host': 'joke3.p.rapidapi.com',
|
||||||
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
'x-rapidapi-key': process.env.RAPIDAPI_API_KEY,
|
||||||
useQueryString: true
|
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);
|
if (error) throw new Error(error);
|
||||||
let jsonBody = JSON.parse(body)
|
let jsonBody = JSON.parse(body)
|
||||||
bot.sendMessage(msg.chat.id, jsonBody.content)
|
bot.sendMessage(msg.chat.id, jsonBody.content)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user