Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.run = async (client, message, args) => { // eslint-disable-line no-unused-vars
const image = await client.getImage(message).catch(error => {
message.reply("you need to provide an image to make a wall from!");
console.log(error);
});
const imageResized = tempy.file({ extension: "png" });
if (image !== undefined) {
message.channel.startTyping();
gm(request.get(image)).resize(128).strip().write(imageResized, (error) => {
if (error) throw new Error(error);
gm(imageResized).virtualPixel("tile").matteColor("none").out("-background", "none").resize("512x512!").out("-distort").out("Perspective").out("0,0,57,42 0,128,63,130 128,0,140,60 128,128,140,140").strip().stream((error, stdout) => {
if (error) throw new Error(error);
message.channel.stopTyping();
message.channel.send({
files: [{
attachment: stdout,
name: "wall.png"
}]
});
});
});
}
};
.then((token) => {
if (token == null) {
const tokeninfoURL = config.authorization.tokeninfoURL;
request.get(tokeninfoURL + accessToken, (error, response, body) => {
if (error != null || response.statusCode !== 200) {
throw new Error('Token request not valid');
}
const { expires_in } = JSON.parse(body);
const expirationDate = expires_in ? new Date(Date.now() + (expires_in * 1000)) : null;
// TODO: scopes
return db.accessTokens.save(accessToken, expirationDate, config.client.clientID);
});
}
return token;
})
.then(() => done(null, accessToken))
app.listen('http://test2.local.com:9003/', function(){
app.get('/', function($){
$.end('hello from http://test2.local.com:9003/');
});
request.get('http://test2.local.com:9003/', function(error, response, body){
if(error) throw error;
assert.equal(body, 'hello from http://test2.local.com:9003/');
assert.equal(response.headers['content-type'], 'text/plain');
assert.equal(response.statusCode, 200);
done();
});
});
})
if(slackArchiveRegex.test(msg.text)) {
var archiveItems = slackArchiveRegex.exec(msg.text),
channel = this.slack.getChannelGroupOrDMByName(archiveItems[1]),
messageId = archiveItems[2];
if(!channel || channel.id.indexOf('D') === 0) {
incomingDM.send(`Hmm. I don't know a channel/group named #{archiveItems[1]} or I'm not part of it. :white_frowning_face:`);
} else {
incomingDM.send('An archive link, huh? Let me check it out... :thinking_face:');
var endpoint = channel.id.indexOf('C') === 0 ? 'channels' : 'groups',
messageIdParts = messageIdSplitter.exec(messageId);
messageIdParts.shift();
var ts = messageIdParts.join('.');
var url = `https://slack.com/api/${endpoint}.history?token=${settings.token}&channel=${channel.id}&latest=${ts}&oldest=${ts}&inclusive=1&count=1`;
logger.verbose('collector', 'Requesting: ', url);
request.get(url, (e, r, body) => {
if(!e) {
try {
var data = JSON.parse(body);
if(data.ok) {
var remoteMessage = data.messages[0];
if(remoteMessage) {
remoteMessage.channel = channel.id;
var doc = this.serializeSlackMessage(remoteMessage);
doc.reactions = {};
if(remoteMessage.reactions) {
remoteMessage.reactions.forEach((r) => {
doc.reactions[r.name] = r.count;
});
}
var serialized = JSON.stringify({
type: 'process_archived_message',
function readConfiguration(source, callback) {
console.log('Reading default configuration from file: ' + DEFAULT_CONFIG);
var defaultConfig = JSON.parse(fs.readFileSync(DEFAULT_CONFIG, 'utf8'));
if (source.indexOf('htt') == 0) {
console.log('Reading configuration from remote source: ' + source);
request.get(source, (error, res, body) => { callback(mergeConfig(defaultConfig, JSON.parse(body))); });
}
else {
console.log('Reading configuration from file: ' + source);
var config = JSON.parse(fs.readFileSync(source, 'utf8'));
callback(mergeConfig(defaultConfig, config));
}
}
function _getPages(champion, callback) {
var res = {pages: {}};
var champUrl = url + "/champion/" + champion;
console.log(champUrl)
request.get(champUrl, (error, response, html) => {
if(!error && response.statusCode == 200) {
exctractPage(html, champion, true, (pages) => {
pages.forEach((page) => {
res.pages[page.name] = page;
});
console.log(res)
callback(res);
});
}
else {
callback(res);
throw Error("rune page not loaded");
}
});
}
function createRequestStream (options) {
return request.get(getRequestParameters(options))
}
function checkGlobalBlacklist(author, sender, callback) {
if(!config.blacklist_settings || !config.blacklist_settings.global_api_blacklists || !Array.isArray(config.blacklist_settings.global_api_blacklists)) {
callback(null);
return;
}
request.get('http://blacklist.usesteem.com/user/' + author, function(e, r, data) {
try {
var result = JSON.parse(data);
if(!result.blacklisted || !Array.isArray(result.blacklisted)) {
callback(null);
return;
}
if(author != sender) {
checkGlobalBlacklist(sender, sender, callback);
} else
callback(config.blacklist_settings.global_api_blacklists.find(b => result.blacklisted.indexOf(b) >= 0));
} catch(err) {
utils.log('Error loading global blacklist info for user @' + author + ', Error: ' + err);
callback(null);
}
function getgist(gistid, callback) {
var url = 'https://api.github.com/gists/' + gistid
+ "?client_id=" + settings.GITHUB_CLIENT_ID
+ "&client_secret=" + settings.GITHUB_CLIENT_SECRET;
request.get({
url: url
, headers: { 'User-Agent': 'tributary' }
}, callback);
}
exports.getByID = id => new Promise( (resolve, reject) => {
const url = `https://www.googleapis.com/books/v1/volumes/${id}`
request.get( url, (err, res, body) => {
if (err) reject(Error('could not complete request'))
const json = JSON.parse(body)
if (json.totalItems === 0) {
reject(Error('book not found'))
}
const data = {
title: `${json.volumeInfo.title}: ${json.volumeInfo.subtitle}`,
authors: json.volumeInfo.authors[0],
description: json.volumeInfo.description.replace(/<(.|\n)*?>/g, ''),
bookID: id
}
resolve(data)
})
})