Comparing version 2.45.1 to 2.45.2
@@ -354,3 +354,8 @@ const url = require('url'); | ||
request.get(`http://api.giphy.com/v1/gifs/search?q=${encodeURIComponent(args)}&api_key=${process.env.GIPHY_APIKEY || 'dc6zaTOxFJmzC'}`, { json: true }, function(err, res, body) { | ||
if (!process.env.GIPHY_API_KEY) { | ||
console.warn('GIPHY_API_KEY environment variable is not set'); | ||
return callback(); | ||
} | ||
request.get(`http://api.giphy.com/v1/gifs/search?q=${encodeURIComponent(args)}&api_key=${process.env.GIPHY_API_KEY}`, { json: true }, function(err, res, body) { | ||
if (err) { | ||
@@ -555,93 +560,2 @@ return callback(); | ||
}, | ||
wootstalker: function(args, callback) { | ||
if (!args || args === '--help' || args === '-h') { | ||
var help = 'Usage: /wootstalker site|url\n\n'; | ||
help += 'Show details of a deal from woot.com\n\n'; | ||
help += 'Examples:\n'; | ||
help += ' `/wootstalker home` shows the details for the current home.woot.com deal.\n'; | ||
help += ' `/wootstalker shirt` shows the details for the current shirt.woot.com deal.\n'; | ||
help += ' `/wootstalker https://sellout.woot.com/offers/cratpv3nt-4-a11` shows the details for the deal of the specified URL.\n'; | ||
return callback(null, `/wootstalker ${args || ''}\n${help}`); | ||
} | ||
// Remove secondary arguments and any pasted variables | ||
const search = args.split(' ')[0].split('?')[0]; | ||
if (['computers', 'electronics', 'gourmet', 'home', 'sellout', 'shirt', 'sport', 'tools', 'wine', 'woot'].includes(search.toLowerCase())) { | ||
var isSite = true; | ||
} | ||
const regExp = /(https:\/\/(computers|electronics|gourmet|home|sellout|shirt|sport|tools|wine|woot|www))\.woot.com\/(offers|plus)\/([-\w]+)/; | ||
var matches = search.match(regExp); | ||
if (matches && matches[1] && matches[2] && matches[3] && matches[4]) { | ||
var isUrl = true; | ||
} | ||
// Store original arguments | ||
const orig = args; | ||
var _markdown = `/wootstalker ${orig}\n`; | ||
// Inject affiliate code into valid URLs | ||
if (isUrl) { | ||
var affurl = `http://products.wootstalker.com?url=${orig}`; | ||
_markdown = `/wootstalker [${orig}](${affurl} "")\n`; | ||
} | ||
if (isSite || isUrl) { | ||
// Get details from API | ||
async.retry(function(callback) { | ||
request.get(`https://api.wootstalker.com/read?search=${search}`, { json: true }, function(err, res, events) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (res.statusCode !== 200) { | ||
return callback(new Error(res.statusCode)); | ||
} | ||
callback(null, events); | ||
}); | ||
}, function(err, events) { | ||
if (err) { | ||
return callback(null, `${_markdown}\nError: Unable to contact WootStalker :cry:`); | ||
} | ||
if (!events || !Array.isArray(events) || !events.length) { | ||
return callback(null, `${_markdown}\nI was unable to find details for the supplied deal :cry:`); | ||
} | ||
var success = false; | ||
events.forEach(e => { | ||
if (e.Offers) { | ||
e.Offers.forEach(o => { | ||
success = true; | ||
var price = `$${o.SalePrice.toString().replace('- ', '- $')}`; | ||
var url = `https://products.wootstalker.com?url=${o.Url.split('?')[0]}`; | ||
_markdown += `\n[![${o.Title}](${o.Image})](${url})`; | ||
_markdown += `\n**[${o.Title}](${url} "${o.Title}")**\nPrice: ${price}\nCondition: ${o.Condition}\n`; | ||
if (o.SoldOut) { | ||
_markdown += '**This deal is currently sold out**\n'; | ||
} | ||
}); | ||
} | ||
}); | ||
if (!success) { | ||
_markdown += '\nI was unable to find details for the specified deal :cry:'; | ||
return callback(null, _markdown); | ||
} | ||
callback(null, _markdown); | ||
}); | ||
} else { | ||
_markdown += '\nWootStalker lookup failed - invalid site or URL entered :cry:'; | ||
callback(null, _markdown); | ||
} | ||
}, | ||
youtube: function(args, callback) { | ||
@@ -648,0 +562,0 @@ // This command requires arguments. |
@@ -39,3 +39,3 @@ { | ||
}, | ||
"version": "2.45.1" | ||
"version": "2.45.2" | ||
} |
@@ -64,3 +64,2 @@ # mehdown | ||
- `/whatdog image-url` - What dog is this? | ||
- `/wootstalker url` - Display woot.com deal details | ||
- `/youtube text` - Post a random YouTube video | ||
@@ -67,0 +66,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1537145
1520
78
10