modified: src/main.js

This commit is contained in:
Flummi 2016-08-14 02:20:26 +02:00
parent 015c94d22a
commit 0b220ced8f

View File

@ -1,5 +1,7 @@
var cfg = require('../../cfg.json');
var fs = require('fs');
var http = require('http');
var https = require('https');
var mysql = require('mysql');
var bot = require('coffea')();
const path = require('path');
@ -52,7 +54,7 @@ var getUser = (u, n) => {
var dl = (url, dest, cb) => {
var file = fs.createWriteStream(dest);
var request = adapterFor(url).get(url, (response) => {
var request = (url.match(/^https/)?https:http).get(url, (response) => {
try {
response.pipe(file);
file.on('finish', () => {
@ -69,15 +71,4 @@ var dl = (url, dest, cb) => {
e.reply(ex);
}
});
}
var adapterFor = (function() {
var url = require('url'),
adapters = {
'http:': require('http'),
'https:': require('https'),
};
return (inputUrl) => {
return adapters[url.parse(inputUrl).protocol]
}
}());
}