start nodejs bot

This commit is contained in:
2021-02-11 02:38:15 +01:00
parent 968105f35d
commit 6d84704b1f
1814 changed files with 303741 additions and 0 deletions

99
node_modules/download/index.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
'use strict';
const fs = require('fs');
const path = require('path');
const {URL} = require('url');
const contentDisposition = require('content-disposition');
const archiveType = require('archive-type');
const decompress = require('decompress');
const filenamify = require('filenamify');
const getStream = require('get-stream');
const got = require('got');
const makeDir = require('make-dir');
const pify = require('pify');
const pEvent = require('p-event');
const fileType = require('file-type');
const extName = require('ext-name');
const fsP = pify(fs);
const filenameFromPath = res => path.basename(new URL(res.requestUrl).pathname);
const getExtFromMime = res => {
const header = res.headers['content-type'];
if (!header) {
return null;
}
const exts = extName.mime(header);
if (exts.length !== 1) {
return null;
}
return exts[0].ext;
};
const getFilename = (res, data) => {
const header = res.headers['content-disposition'];
if (header) {
const parsed = contentDisposition.parse(header);
if (parsed.parameters && parsed.parameters.filename) {
return parsed.parameters.filename;
}
}
let filename = filenameFromPath(res);
if (!path.extname(filename)) {
const ext = (fileType(data) || {}).ext || getExtFromMime(res);
if (ext) {
filename = `${filename}.${ext}`;
}
}
return filename;
};
module.exports = (uri, output, opts) => {
if (typeof output === 'object') {
opts = output;
output = null;
}
opts = Object.assign({
encoding: null,
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false'
}, opts);
const stream = got.stream(uri, opts);
const promise = pEvent(stream, 'response').then(res => {
const encoding = opts.encoding === null ? 'buffer' : opts.encoding;
return Promise.all([getStream(stream, {encoding}), res]);
}).then(result => {
const [data, res] = result;
if (!output) {
return opts.extract && archiveType(data) ? decompress(data, opts) : data;
}
const filename = opts.filename || filenamify(getFilename(res, data));
const outputFilepath = path.join(output, filename);
if (opts.extract && archiveType(data)) {
return decompress(data, path.dirname(outputFilepath), opts);
}
return makeDir(path.dirname(outputFilepath))
.then(() => fsP.writeFile(outputFilepath, data))
.then(() => data);
});
stream.then = promise.then.bind(promise);
stream.catch = promise.catch.bind(promise);
return stream;
};

9
node_modules/download/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

83
node_modules/download/package.json generated vendored Normal file
View File

@@ -0,0 +1,83 @@
{
"_from": "download",
"_id": "download@8.0.0",
"_inBundle": false,
"_integrity": "sha512-ASRY5QhDk7FK+XrQtQyvhpDKanLluEEQtWl/J7Lxuf/b+i8RYh997QeXvL85xitrmRKVlx9c7eTrcRdq2GS4eA==",
"_location": "/download",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "download",
"name": "download",
"escapedName": "download",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/download/-/download-8.0.0.tgz",
"_shasum": "afc0b309730811731aae9f5371c9f46be73e51b1",
"_spec": "download",
"_where": "C:\\Users\\MCGFX\\OneDrive\\Dokumente\\GitHub\\UnknownBot",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/download/issues"
},
"bundleDependencies": false,
"dependencies": {
"archive-type": "^4.0.0",
"content-disposition": "^0.5.2",
"decompress": "^4.2.1",
"ext-name": "^5.0.0",
"file-type": "^11.1.0",
"filenamify": "^3.0.0",
"get-stream": "^4.1.0",
"got": "^8.3.1",
"make-dir": "^2.1.0",
"p-event": "^2.1.0",
"pify": "^4.0.1"
},
"deprecated": false,
"description": "Download and extract files",
"devDependencies": {
"ava": "^1.4.1",
"is-zip": "^1.0.0",
"nock": "^10.0.6",
"path-exists": "^3.0.0",
"random-buffer": "^0.1.0",
"rimraf": "^3.0.0",
"xo": "^0.24.0"
},
"engines": {
"node": ">=10"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/download#readme",
"keywords": [
"download",
"extract",
"http",
"request",
"url"
],
"license": "MIT",
"name": "download",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/download.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "8.0.0"
}

75
node_modules/download/readme.md generated vendored Normal file
View File

@@ -0,0 +1,75 @@
# download [![Build Status](https://travis-ci.org/kevva/download.svg?branch=master)](https://travis-ci.org/kevva/download)
> Download and extract files
*See [download-cli](https://github.com/kevva/download-cli) for the command-line version.*
## Install
```
$ npm install download
```
## Usage
```js
const fs = require('fs');
const download = require('download');
(async () => {
await download('http://unicorn.com/foo.jpg', 'dist');
fs.writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg'));
download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg'));
await Promise.all([
'unicorn.com/foo.jpg',
'cats.com/dancing.gif'
].map(url => download(url, 'dist')));
})();
```
### Proxies
To work with proxies, read the [`got documentation`](https://github.com/sindresorhus/got#proxies).
## API
### download(url, destination?, options?)
Returns both a `Promise<Buffer>` and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with [additional events](https://github.com/sindresorhus/got#streams-1).
#### url
Type: `string`
URL to download.
#### destination
Type: `string`
Path to where your file will be written.
#### options
Type: `Object`
Same options as [`got`](https://github.com/sindresorhus/got#options) and [`decompress`](https://github.com/kevva/decompress#options) in addition to the ones below.
##### extract
Type: `boolean`<br>
Default: `false`
If set to `true`, try extracting the file using [`decompress`](https://github.com/kevva/decompress).
##### filename
Type: `string`
Name of the saved file.