mirror of
				https://github.com/1disk/edp445.git
				synced 2024-08-14 22:47:02 +00:00 
			
		
		
		
	added a few messages that the bot would respond to
This commit is contained in:
		
							parent
							
								
									c63d9a6e13
								
							
						
					
					
						commit
						de29e2769c
					
				
					 384 changed files with 56249 additions and 43 deletions
				
			
		
							
								
								
									
										98
									
								
								node_modules/on-finished/HISTORY.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								node_modules/on-finished/HISTORY.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,98 @@ | |||
| 2.4.1 / 2022-02-22 | ||||
| ================== | ||||
| 
 | ||||
|   * Fix error on early async hooks implementations | ||||
| 
 | ||||
| 2.4.0 / 2022-02-21 | ||||
| ================== | ||||
| 
 | ||||
|   * Prevent loss of async hooks context | ||||
| 
 | ||||
| 2.3.0 / 2015-05-26 | ||||
| ================== | ||||
| 
 | ||||
|   * Add defined behavior for HTTP `CONNECT` requests | ||||
|   * Add defined behavior for HTTP `Upgrade` requests | ||||
|   * deps: ee-first@1.1.1 | ||||
| 
 | ||||
| 2.2.1 / 2015-04-22 | ||||
| ================== | ||||
| 
 | ||||
|   * Fix `isFinished(req)` when data buffered | ||||
| 
 | ||||
| 2.2.0 / 2014-12-22 | ||||
| ================== | ||||
| 
 | ||||
|   * Add message object to callback arguments | ||||
| 
 | ||||
| 2.1.1 / 2014-10-22 | ||||
| ================== | ||||
| 
 | ||||
|   * Fix handling of pipelined requests | ||||
| 
 | ||||
| 2.1.0 / 2014-08-16 | ||||
| ================== | ||||
| 
 | ||||
|   * Check if `socket` is detached | ||||
|   * Return `undefined` for `isFinished` if state unknown | ||||
| 
 | ||||
| 2.0.0 / 2014-08-16 | ||||
| ================== | ||||
| 
 | ||||
|   * Add `isFinished` function | ||||
|   * Move to `jshttp` organization | ||||
|   * Remove support for plain socket argument | ||||
|   * Rename to `on-finished` | ||||
|   * Support both `req` and `res` as arguments | ||||
|   * deps: ee-first@1.0.5 | ||||
| 
 | ||||
| 1.2.2 / 2014-06-10 | ||||
| ================== | ||||
| 
 | ||||
|   * Reduce listeners added to emitters | ||||
|     - avoids "event emitter leak" warnings when used multiple times on same request | ||||
| 
 | ||||
| 1.2.1 / 2014-06-08 | ||||
| ================== | ||||
| 
 | ||||
|   * Fix returned value when already finished | ||||
| 
 | ||||
| 1.2.0 / 2014-06-05 | ||||
| ================== | ||||
| 
 | ||||
|   * Call callback when called on already-finished socket | ||||
| 
 | ||||
| 1.1.4 / 2014-05-27 | ||||
| ================== | ||||
| 
 | ||||
|   * Support node.js 0.8 | ||||
| 
 | ||||
| 1.1.3 / 2014-04-30 | ||||
| ================== | ||||
| 
 | ||||
|   * Make sure errors passed as instanceof `Error` | ||||
| 
 | ||||
| 1.1.2 / 2014-04-18 | ||||
| ================== | ||||
| 
 | ||||
|   * Default the `socket` to passed-in object | ||||
| 
 | ||||
| 1.1.1 / 2014-01-16 | ||||
| ================== | ||||
| 
 | ||||
|   * Rename module to `finished` | ||||
| 
 | ||||
| 1.1.0 / 2013-12-25 | ||||
| ================== | ||||
| 
 | ||||
|   * Call callback when called on already-errored socket | ||||
| 
 | ||||
| 1.0.1 / 2013-12-20 | ||||
| ================== | ||||
| 
 | ||||
|   * Actually pass the error to the callback | ||||
| 
 | ||||
| 1.0.0 / 2013-12-20 | ||||
| ================== | ||||
| 
 | ||||
|   * Initial release | ||||
							
								
								
									
										23
									
								
								node_modules/on-finished/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								node_modules/on-finished/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| (The MIT License) | ||||
| 
 | ||||
| Copyright (c) 2013 Jonathan Ong <me@jongleberry.com> | ||||
| Copyright (c) 2014 Douglas Christopher Wilson <doug@somethingdoug.com> | ||||
| 
 | ||||
| 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. | ||||
							
								
								
									
										162
									
								
								node_modules/on-finished/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								node_modules/on-finished/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,162 @@ | |||
| # on-finished | ||||
| 
 | ||||
| [![NPM Version][npm-version-image]][npm-url] | ||||
| [![NPM Downloads][npm-downloads-image]][npm-url] | ||||
| [![Node.js Version][node-image]][node-url] | ||||
| [![Build Status][ci-image]][ci-url] | ||||
| [![Coverage Status][coveralls-image]][coveralls-url] | ||||
| 
 | ||||
| Execute a callback when a HTTP request closes, finishes, or errors. | ||||
| 
 | ||||
| ## Install | ||||
| 
 | ||||
| This is a [Node.js](https://nodejs.org/en/) module available through the | ||||
| [npm registry](https://www.npmjs.com/). Installation is done using the | ||||
| [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): | ||||
| 
 | ||||
| ```sh | ||||
| $ npm install on-finished | ||||
| ``` | ||||
| 
 | ||||
| ## API | ||||
| 
 | ||||
| ```js | ||||
| var onFinished = require('on-finished') | ||||
| ``` | ||||
| 
 | ||||
| ### onFinished(res, listener) | ||||
| 
 | ||||
| Attach a listener to listen for the response to finish. The listener will | ||||
| be invoked only once when the response finished. If the response finished | ||||
| to an error, the first argument will contain the error. If the response | ||||
| has already finished, the listener will be invoked. | ||||
| 
 | ||||
| Listening to the end of a response would be used to close things associated | ||||
| with the response, like open files. | ||||
| 
 | ||||
| Listener is invoked as `listener(err, res)`. | ||||
| 
 | ||||
| <!-- eslint-disable handle-callback-err --> | ||||
| 
 | ||||
| ```js | ||||
| onFinished(res, function (err, res) { | ||||
|   // clean up open fds, etc. | ||||
|   // err contains the error if request error'd | ||||
| }) | ||||
| ``` | ||||
| 
 | ||||
| ### onFinished(req, listener) | ||||
| 
 | ||||
| Attach a listener to listen for the request to finish. The listener will | ||||
| be invoked only once when the request finished. If the request finished | ||||
| to an error, the first argument will contain the error. If the request | ||||
| has already finished, the listener will be invoked. | ||||
| 
 | ||||
| Listening to the end of a request would be used to know when to continue | ||||
| after reading the data. | ||||
| 
 | ||||
| Listener is invoked as `listener(err, req)`. | ||||
| 
 | ||||
| <!-- eslint-disable handle-callback-err --> | ||||
| 
 | ||||
| ```js | ||||
| var data = '' | ||||
| 
 | ||||
| req.setEncoding('utf8') | ||||
| req.on('data', function (str) { | ||||
|   data += str | ||||
| }) | ||||
| 
 | ||||
| onFinished(req, function (err, req) { | ||||
|   // data is read unless there is err | ||||
| }) | ||||
| ``` | ||||
| 
 | ||||
| ### onFinished.isFinished(res) | ||||
| 
 | ||||
| Determine if `res` is already finished. This would be useful to check and | ||||
| not even start certain operations if the response has already finished. | ||||
| 
 | ||||
| ### onFinished.isFinished(req) | ||||
| 
 | ||||
| Determine if `req` is already finished. This would be useful to check and | ||||
| not even start certain operations if the request has already finished. | ||||
| 
 | ||||
| ## Special Node.js requests | ||||
| 
 | ||||
| ### HTTP CONNECT method | ||||
| 
 | ||||
| The meaning of the `CONNECT` method from RFC 7231, section 4.3.6: | ||||
| 
 | ||||
| > The CONNECT method requests that the recipient establish a tunnel to | ||||
| > the destination origin server identified by the request-target and, | ||||
| > if successful, thereafter restrict its behavior to blind forwarding | ||||
| > of packets, in both directions, until the tunnel is closed.  Tunnels | ||||
| > are commonly used to create an end-to-end virtual connection, through | ||||
| > one or more proxies, which can then be secured using TLS (Transport | ||||
| > Layer Security, [RFC5246]). | ||||
| 
 | ||||
| In Node.js, these request objects come from the `'connect'` event on | ||||
| the HTTP server. | ||||
| 
 | ||||
| When this module is used on a HTTP `CONNECT` request, the request is | ||||
| considered "finished" immediately, **due to limitations in the Node.js | ||||
| interface**. This means if the `CONNECT` request contains a request entity, | ||||
| the request will be considered "finished" even before it has been read. | ||||
| 
 | ||||
| There is no such thing as a response object to a `CONNECT` request in | ||||
| Node.js, so there is no support for one. | ||||
| 
 | ||||
| ### HTTP Upgrade request | ||||
| 
 | ||||
| The meaning of the `Upgrade` header from RFC 7230, section 6.1: | ||||
| 
 | ||||
| > The "Upgrade" header field is intended to provide a simple mechanism | ||||
| > for transitioning from HTTP/1.1 to some other protocol on the same | ||||
| > connection. | ||||
| 
 | ||||
| In Node.js, these request objects come from the `'upgrade'` event on | ||||
| the HTTP server. | ||||
| 
 | ||||
| When this module is used on a HTTP request with an `Upgrade` header, the | ||||
| request is considered "finished" immediately, **due to limitations in the | ||||
| Node.js interface**. This means if the `Upgrade` request contains a request | ||||
| entity, the request will be considered "finished" even before it has been | ||||
| read. | ||||
| 
 | ||||
| There is no such thing as a response object to a `Upgrade` request in | ||||
| Node.js, so there is no support for one. | ||||
| 
 | ||||
| ## Example | ||||
| 
 | ||||
| The following code ensures that file descriptors are always closed | ||||
| once the response finishes. | ||||
| 
 | ||||
| ```js | ||||
| var destroy = require('destroy') | ||||
| var fs = require('fs') | ||||
| var http = require('http') | ||||
| var onFinished = require('on-finished') | ||||
| 
 | ||||
| http.createServer(function onRequest (req, res) { | ||||
|   var stream = fs.createReadStream('package.json') | ||||
|   stream.pipe(res) | ||||
|   onFinished(res, function () { | ||||
|     destroy(stream) | ||||
|   }) | ||||
| }) | ||||
| ``` | ||||
| 
 | ||||
| ## License | ||||
| 
 | ||||
| [MIT](LICENSE) | ||||
| 
 | ||||
| [ci-image]: https://badgen.net/github/checks/jshttp/on-finished/master?label=ci | ||||
| [ci-url]: https://github.com/jshttp/on-finished/actions/workflows/ci.yml | ||||
| [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/on-finished/master | ||||
| [coveralls-url]: https://coveralls.io/r/jshttp/on-finished?branch=master | ||||
| [node-image]: https://badgen.net/npm/node/on-finished | ||||
| [node-url]: https://nodejs.org/en/download | ||||
| [npm-downloads-image]: https://badgen.net/npm/dm/on-finished | ||||
| [npm-url]: https://npmjs.org/package/on-finished | ||||
| [npm-version-image]: https://badgen.net/npm/v/on-finished | ||||
							
								
								
									
										234
									
								
								node_modules/on-finished/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										234
									
								
								node_modules/on-finished/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,234 @@ | |||
| /*! | ||||
|  * on-finished | ||||
|  * Copyright(c) 2013 Jonathan Ong | ||||
|  * Copyright(c) 2014 Douglas Christopher Wilson | ||||
|  * MIT Licensed | ||||
|  */ | ||||
| 
 | ||||
| 'use strict' | ||||
| 
 | ||||
| /** | ||||
|  * Module exports. | ||||
|  * @public | ||||
|  */ | ||||
| 
 | ||||
| module.exports = onFinished | ||||
| module.exports.isFinished = isFinished | ||||
| 
 | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| var asyncHooks = tryRequireAsyncHooks() | ||||
| var first = require('ee-first') | ||||
| 
 | ||||
| /** | ||||
|  * Variables. | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| /* istanbul ignore next */ | ||||
| var defer = typeof setImmediate === 'function' | ||||
|   ? setImmediate | ||||
|   : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) } | ||||
| 
 | ||||
| /** | ||||
|  * Invoke callback when the response has finished, useful for | ||||
|  * cleaning up resources afterwards. | ||||
|  * | ||||
|  * @param {object} msg | ||||
|  * @param {function} listener | ||||
|  * @return {object} | ||||
|  * @public | ||||
|  */ | ||||
| 
 | ||||
| function onFinished (msg, listener) { | ||||
|   if (isFinished(msg) !== false) { | ||||
|     defer(listener, null, msg) | ||||
|     return msg | ||||
|   } | ||||
| 
 | ||||
|   // attach the listener to the message
 | ||||
|   attachListener(msg, wrap(listener)) | ||||
| 
 | ||||
|   return msg | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Determine if message is already finished. | ||||
|  * | ||||
|  * @param {object} msg | ||||
|  * @return {boolean} | ||||
|  * @public | ||||
|  */ | ||||
| 
 | ||||
| function isFinished (msg) { | ||||
|   var socket = msg.socket | ||||
| 
 | ||||
|   if (typeof msg.finished === 'boolean') { | ||||
|     // OutgoingMessage
 | ||||
|     return Boolean(msg.finished || (socket && !socket.writable)) | ||||
|   } | ||||
| 
 | ||||
|   if (typeof msg.complete === 'boolean') { | ||||
|     // IncomingMessage
 | ||||
|     return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable)) | ||||
|   } | ||||
| 
 | ||||
|   // don't know
 | ||||
|   return undefined | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Attach a finished listener to the message. | ||||
|  * | ||||
|  * @param {object} msg | ||||
|  * @param {function} callback | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| function attachFinishedListener (msg, callback) { | ||||
|   var eeMsg | ||||
|   var eeSocket | ||||
|   var finished = false | ||||
| 
 | ||||
|   function onFinish (error) { | ||||
|     eeMsg.cancel() | ||||
|     eeSocket.cancel() | ||||
| 
 | ||||
|     finished = true | ||||
|     callback(error) | ||||
|   } | ||||
| 
 | ||||
|   // finished on first message event
 | ||||
|   eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish) | ||||
| 
 | ||||
|   function onSocket (socket) { | ||||
|     // remove listener
 | ||||
|     msg.removeListener('socket', onSocket) | ||||
| 
 | ||||
|     if (finished) return | ||||
|     if (eeMsg !== eeSocket) return | ||||
| 
 | ||||
|     // finished on first socket event
 | ||||
|     eeSocket = first([[socket, 'error', 'close']], onFinish) | ||||
|   } | ||||
| 
 | ||||
|   if (msg.socket) { | ||||
|     // socket already assigned
 | ||||
|     onSocket(msg.socket) | ||||
|     return | ||||
|   } | ||||
| 
 | ||||
|   // wait for socket to be assigned
 | ||||
|   msg.on('socket', onSocket) | ||||
| 
 | ||||
|   if (msg.socket === undefined) { | ||||
|     // istanbul ignore next: node.js 0.8 patch
 | ||||
|     patchAssignSocket(msg, onSocket) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Attach the listener to the message. | ||||
|  * | ||||
|  * @param {object} msg | ||||
|  * @return {function} | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| function attachListener (msg, listener) { | ||||
|   var attached = msg.__onFinished | ||||
| 
 | ||||
|   // create a private single listener with queue
 | ||||
|   if (!attached || !attached.queue) { | ||||
|     attached = msg.__onFinished = createListener(msg) | ||||
|     attachFinishedListener(msg, attached) | ||||
|   } | ||||
| 
 | ||||
|   attached.queue.push(listener) | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Create listener on message. | ||||
|  * | ||||
|  * @param {object} msg | ||||
|  * @return {function} | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| function createListener (msg) { | ||||
|   function listener (err) { | ||||
|     if (msg.__onFinished === listener) msg.__onFinished = null | ||||
|     if (!listener.queue) return | ||||
| 
 | ||||
|     var queue = listener.queue | ||||
|     listener.queue = null | ||||
| 
 | ||||
|     for (var i = 0; i < queue.length; i++) { | ||||
|       queue[i](err, msg) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   listener.queue = [] | ||||
| 
 | ||||
|   return listener | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Patch ServerResponse.prototype.assignSocket for node.js 0.8. | ||||
|  * | ||||
|  * @param {ServerResponse} res | ||||
|  * @param {function} callback | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| // istanbul ignore next: node.js 0.8 patch
 | ||||
| function patchAssignSocket (res, callback) { | ||||
|   var assignSocket = res.assignSocket | ||||
| 
 | ||||
|   if (typeof assignSocket !== 'function') return | ||||
| 
 | ||||
|   // res.on('socket', callback) is broken in 0.8
 | ||||
|   res.assignSocket = function _assignSocket (socket) { | ||||
|     assignSocket.call(this, socket) | ||||
|     callback(socket) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Try to require async_hooks | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| function tryRequireAsyncHooks () { | ||||
|   try { | ||||
|     return require('async_hooks') | ||||
|   } catch (e) { | ||||
|     return {} | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Wrap function with async resource, if possible. | ||||
|  * AsyncResource.bind static method backported. | ||||
|  * @private | ||||
|  */ | ||||
| 
 | ||||
| function wrap (fn) { | ||||
|   var res | ||||
| 
 | ||||
|   // create anonymous resource
 | ||||
|   if (asyncHooks.AsyncResource) { | ||||
|     res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn') | ||||
|   } | ||||
| 
 | ||||
|   // incompatible node.js
 | ||||
|   if (!res || !res.runInAsyncScope) { | ||||
|     return fn | ||||
|   } | ||||
| 
 | ||||
|   // return bound function
 | ||||
|   return res.runInAsyncScope.bind(res, fn, null) | ||||
| } | ||||
							
								
								
									
										39
									
								
								node_modules/on-finished/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								node_modules/on-finished/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| { | ||||
|   "name": "on-finished", | ||||
|   "description": "Execute a callback when a request closes, finishes, or errors", | ||||
|   "version": "2.4.1", | ||||
|   "contributors": [ | ||||
|     "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||||
|     "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)" | ||||
|   ], | ||||
|   "license": "MIT", | ||||
|   "repository": "jshttp/on-finished", | ||||
|   "dependencies": { | ||||
|     "ee-first": "1.1.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "7.32.0", | ||||
|     "eslint-config-standard": "14.1.1", | ||||
|     "eslint-plugin-import": "2.25.4", | ||||
|     "eslint-plugin-markdown": "2.2.1", | ||||
|     "eslint-plugin-node": "11.1.0", | ||||
|     "eslint-plugin-promise": "5.2.0", | ||||
|     "eslint-plugin-standard": "4.1.0", | ||||
|     "mocha": "9.2.1", | ||||
|     "nyc": "15.1.0" | ||||
|   }, | ||||
|   "engines": { | ||||
|     "node": ">= 0.8" | ||||
|   }, | ||||
|   "files": [ | ||||
|     "HISTORY.md", | ||||
|     "LICENSE", | ||||
|     "index.js" | ||||
|   ], | ||||
|   "scripts": { | ||||
|     "lint": "eslint .", | ||||
|     "test": "mocha --reporter spec --bail --check-leaks test/", | ||||
|     "test-ci": "nyc --reporter=lcovonly --reporter=text npm test", | ||||
|     "test-cov": "nyc --reporter=html --reporter=text npm test" | ||||
|   } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue