mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Core hook upgrade, misc fixes
(See ChangeLog.md tbh)
This commit is contained in:
parent
02f6fbf701
commit
a488301655
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [2.1.9] - 2019-02-21
|
||||||
|
### Added
|
||||||
|
- `./server/src/commands/core/emote.js` module to provide action text
|
||||||
|
- `./server/src/core/server.js` priorities to command hooking
|
||||||
|
- Priority levels to all command modules
|
||||||
|
- `./server/src/commands/core/chat.js` Unknown '/' commands will now return a warning
|
||||||
|
- `./server/src/commands/internal/legacylayer.js` to provide compatibility to legacy connections
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated all libraries to latest
|
||||||
|
- `./server/src/core/server.js` Removed unneeded function bindings
|
||||||
|
- `./server/src/core/server.js` Hook function layout
|
||||||
|
- `./server/src/managers/config.js` Documentation wording
|
||||||
|
|
||||||
## [2.1.0] - 2018-09-29
|
## [2.1.0] - 2018-09-29
|
||||||
### Added
|
### Added
|
||||||
- Module hook framework, isolating modules and making them truly drop-to-install
|
- Module hook framework, isolating modules and making them truly drop-to-install
|
||||||
|
|
30
clientSource/package-lock.json
generated
30
clientSource/package-lock.json
generated
|
@ -28,14 +28,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ecstatic": {
|
"ecstatic": {
|
||||||
"version": "3.2.0",
|
"version": "3.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/ecstatic/-/ecstatic-3.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ecstatic/-/ecstatic-3.3.0.tgz",
|
||||||
"integrity": "sha512-Goilx/2cfU9vvfQjgtNgc2VmJAD8CasQ6rZDqCd2u4Hsyd/qFET6nBf60jiHodevR3nl3IGzNKtrzPXWP88utQ==",
|
"integrity": "sha512-EblWYTd+wPIAMQ0U4oYJZ7QBypT9ZUIwpqli0bKDjeIIQnXDBK2dXtZ9yzRCOlkW1HkO8gn7/FxLK1yPIW17pw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"he": "^1.1.1",
|
"he": "^1.1.1",
|
||||||
"mime": "^1.4.1",
|
"mime": "^1.6.0",
|
||||||
"minimist": "^1.1.0",
|
"minimist": "^1.1.0",
|
||||||
"url-join": "^2.0.2"
|
"url-join": "^2.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventemitter3": {
|
"eventemitter3": {
|
||||||
|
@ -44,17 +44,17 @@
|
||||||
"integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA=="
|
"integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA=="
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
"follow-redirects": {
|
||||||
"version": "1.5.0",
|
"version": "1.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz",
|
||||||
"integrity": "sha512-fdrt472/9qQ6Kgjvb935ig6vJCuofpBUD14f9Vb+SLlm7xIe4Qva5gey8EKtv8lp7ahE1wilg3xL1znpVGtZIA==",
|
"integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^3.1.0"
|
"debug": "=3.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"he": {
|
"he": {
|
||||||
"version": "1.1.1",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||||
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0="
|
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
|
||||||
},
|
},
|
||||||
"http-proxy": {
|
"http-proxy": {
|
||||||
"version": "1.17.0",
|
"version": "1.17.0",
|
||||||
|
@ -133,9 +133,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"portfinder": {
|
"portfinder": {
|
||||||
"version": "1.0.13",
|
"version": "1.0.20",
|
||||||
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.20.tgz",
|
||||||
"integrity": "sha1-uzLs2HwnEErm7kS1o8y/Drsa7ek=",
|
"integrity": "sha512-Yxe4mTyDzTd59PZJY4ojZR8F+E5e97iq2ZOHPz3HDgSvYC5siNad2tLooQ5y5QHyQhc3xVqvyk/eNA3wuoa7Sw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "^1.5.2",
|
"async": "^1.5.2",
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
|
|
1411
package-lock.json
generated
1411
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hack.chat-v2",
|
"name": "hack.chat-v2",
|
||||||
"version": "2.1.0",
|
"version": "2.1.9",
|
||||||
"description": "a minimal distraction free chat application",
|
"description": "a minimal distraction free chat application",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -8,16 +8,16 @@
|
||||||
"url": "git+https://github.com/hack-chat/main.git"
|
"url": "git+https://github.com/hack-chat/main.git"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8.10.0",
|
"node": ">= 10.15.1",
|
||||||
"npm": ">= 5.7.1"
|
"npm": ">= 6.7.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "pm2 start ./server/main.js --name hackchat-dev-server && cd ./clientSource && npm start && pm2 stop hackchat-dev-server",
|
"start": "pm2 start ./server/main.js --name hackchat-dev-server && cd ./clientSource && npm start && pm2 stop hackchat-dev-server",
|
||||||
"postinstall": "cd ./clientSource && npm install && cd.. & cd ./server && npm install && npm run config"
|
"postinstall": "cd ./clientSource && npm install && cd .. & cd ./server && npm install && npm run config"
|
||||||
},
|
},
|
||||||
"author": "Marzavec",
|
"author": "Marzavec",
|
||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pm2": "^2.10.4"
|
"pm2": "^3.2.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
138
server/package-lock.json
generated
138
server/package-lock.json
generated
|
@ -22,15 +22,6 @@
|
||||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
|
||||||
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
|
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
|
||||||
},
|
},
|
||||||
"babel-runtime": {
|
|
||||||
"version": "6.26.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
|
||||||
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
|
|
||||||
"requires": {
|
|
||||||
"core-js": "^2.4.0",
|
|
||||||
"regenerator-runtime": "^0.11.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||||
|
@ -51,9 +42,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||||
"integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==",
|
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-styles": "^3.2.1",
|
"ansi-styles": "^3.2.1",
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
|
@ -61,11 +52,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"color-convert": {
|
"color-convert": {
|
||||||
"version": "1.9.1",
|
"version": "1.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||||
"integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
|
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"color-name": "^1.1.1"
|
"color-name": "1.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"color-name": {
|
"color-name": {
|
||||||
|
@ -74,28 +65,20 @@
|
||||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||||
},
|
},
|
||||||
"colors": {
|
"colors": {
|
||||||
"version": "1.2.5",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz",
|
||||||
"integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg=="
|
"integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg=="
|
||||||
},
|
},
|
||||||
"common-tags": {
|
"common-tags": {
|
||||||
"version": "1.7.2",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
|
||||||
"integrity": "sha512-joj9ZlUOjCrwdbmiLqafeUSgkUM74NqhLsZtSqDmhKudaIY197zTrb8JMl31fMnCUuxwFT23eC/oWvrZzDLRJQ==",
|
"integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
|
||||||
"requires": {
|
|
||||||
"babel-runtime": "^6.26.0"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||||
},
|
},
|
||||||
"core-js": {
|
|
||||||
"version": "2.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.6.tgz",
|
|
||||||
"integrity": "sha512-lQUVfQi0aLix2xpyjrrJEvfuYCqPc/HwmTKsC/VNf8q0zsjX7SQZtp4+oRONN5Tsur9GDETPjj+Ub2iDiGZfSQ=="
|
|
||||||
},
|
|
||||||
"cycle": {
|
"cycle": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
|
||||||
|
@ -107,12 +90,12 @@
|
||||||
"integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q=="
|
"integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q=="
|
||||||
},
|
},
|
||||||
"deasync": {
|
"deasync": {
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.13.tgz",
|
"resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.14.tgz",
|
||||||
"integrity": "sha512-/6ngYM7AapueqLtvOzjv9+11N2fHDSrkxeMF1YPE20WIfaaawiBg+HZH1E5lHrcJxlKR42t6XPOEmMmqcAsU1g==",
|
"integrity": "sha512-wN8sIuEqIwyQh72AG7oY6YQODCxIp1eXzEZlZznBuwDF8Q03Tdy9QNp1BNZXeadXoklNrw+Ip1fch+KXo/+ASw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bindings": "~1.2.1",
|
"bindings": "~1.2.1",
|
||||||
"nan": "^2.0.7"
|
"node-addon-api": "^1.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deep-equal": {
|
"deep-equal": {
|
||||||
|
@ -121,12 +104,13 @@
|
||||||
"integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0="
|
"integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0="
|
||||||
},
|
},
|
||||||
"didyoumean2": {
|
"didyoumean2": {
|
||||||
"version": "1.3.0",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/didyoumean2/-/didyoumean2-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/didyoumean2/-/didyoumean2-2.0.2.tgz",
|
||||||
"integrity": "sha1-bjT0AUM1HJIGlulyO7oB/8C5ZAI=",
|
"integrity": "sha512-YEpkuyJ4lN8fSuuQy1UgfzGTAPi92rehUIcNmO+dcPhka0j2jWWniAy8tWEyJ2WJJQ3DLVI0C1Kjy31MJgFseA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"leven": "^2.0.0",
|
"leven": "^2.0.0",
|
||||||
"lodash": "^4.17.2"
|
"lodash.deburr": "^4.1.0",
|
||||||
|
"ramda": "^0.26.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"escape-string-regexp": {
|
"escape-string-regexp": {
|
||||||
|
@ -140,9 +124,9 @@
|
||||||
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
|
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
|
||||||
},
|
},
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
"version": "5.0.0",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
|
||||||
"integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==",
|
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "^4.1.2",
|
"graceful-fs": "^4.1.2",
|
||||||
"jsonfile": "^4.0.0",
|
"jsonfile": "^4.0.0",
|
||||||
|
@ -155,9 +139,9 @@
|
||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||||
},
|
},
|
||||||
"glob": {
|
"glob": {
|
||||||
"version": "7.1.2",
|
"version": "7.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
|
||||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs.realpath": "^1.0.0",
|
"fs.realpath": "^1.0.0",
|
||||||
"inflight": "^1.0.4",
|
"inflight": "^1.0.4",
|
||||||
|
@ -168,9 +152,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"graceful-fs": {
|
"graceful-fs": {
|
||||||
"version": "4.1.11",
|
"version": "4.1.15",
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz",
|
||||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
|
"integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA=="
|
||||||
},
|
},
|
||||||
"has-flag": {
|
"has-flag": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -214,10 +198,10 @@
|
||||||
"resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
|
||||||
"integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA="
|
"integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA="
|
||||||
},
|
},
|
||||||
"lodash": {
|
"lodash.deburr": {
|
||||||
"version": "4.17.10",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.deburr/-/lodash.deburr-4.1.0.tgz",
|
||||||
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
|
"integrity": "sha1-3bG7s+8HRYwBd7oH3hRCLLAz/5s="
|
||||||
},
|
},
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
|
@ -241,20 +225,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mute-stream": {
|
"mute-stream": {
|
||||||
"version": "0.0.7",
|
"version": "0.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
|
||||||
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s="
|
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA=="
|
||||||
},
|
|
||||||
"nan": {
|
|
||||||
"version": "2.10.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
|
|
||||||
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
|
|
||||||
},
|
},
|
||||||
"ncp": {
|
"ncp": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz",
|
||||||
"integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY="
|
"integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY="
|
||||||
},
|
},
|
||||||
|
"node-addon-api": {
|
||||||
|
"version": "1.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.6.2.tgz",
|
||||||
|
"integrity": "sha512-479Bjw9nTE5DdBSZZWprFryHGjUaQC31y1wHo19We/k0BZlrmhqQitWoUL0cD8+scljCbIUL+E58oRDEakdGGA=="
|
||||||
|
},
|
||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
|
@ -286,6 +270,11 @@
|
||||||
"winston": "2.1.x"
|
"winston": "2.1.x"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ramda": {
|
||||||
|
"version": "0.26.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz",
|
||||||
|
"integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ=="
|
||||||
|
},
|
||||||
"read": {
|
"read": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
||||||
|
@ -299,22 +288,17 @@
|
||||||
"resolved": "https://registry.npmjs.org/readdir-recursive/-/readdir-recursive-0.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/readdir-recursive/-/readdir-recursive-0.0.4.tgz",
|
||||||
"integrity": "sha1-mvQ1q6nFi9gNvclIi025up8SMB8="
|
"integrity": "sha1-mvQ1q6nFi9gNvclIi025up8SMB8="
|
||||||
},
|
},
|
||||||
"regenerator-runtime": {
|
|
||||||
"version": "0.11.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
|
|
||||||
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
|
|
||||||
},
|
|
||||||
"revalidator": {
|
"revalidator": {
|
||||||
"version": "0.1.8",
|
"version": "0.1.8",
|
||||||
"resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz",
|
||||||
"integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs="
|
"integrity": "sha1-/s5hv6DBtSoga9axgZgYS91SOjs="
|
||||||
},
|
},
|
||||||
"rimraf": {
|
"rimraf": {
|
||||||
"version": "2.6.2",
|
"version": "2.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
|
||||||
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
|
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"glob": "^7.0.5"
|
"glob": "^7.1.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stack-trace": {
|
"stack-trace": {
|
||||||
|
@ -323,17 +307,17 @@
|
||||||
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
|
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
|
||||||
},
|
},
|
||||||
"supports-color": {
|
"supports-color": {
|
||||||
"version": "5.4.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
|
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"has-flag": "^3.0.0"
|
"has-flag": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"universalify": {
|
"universalify": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||||
"integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc="
|
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
|
||||||
},
|
},
|
||||||
"utile": {
|
"utile": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
|
@ -385,9 +369,9 @@
|
||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "5.1.1",
|
"version": "6.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
|
||||||
"integrity": "sha512-bOusvpCb09TOBLbpMKszd45WKC2KPtxiyiHanv+H2DE3Az+1db5a/L7sVJZVDPUC1Br8f0SKRr1KjLpD1U/IAw==",
|
"integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async-limiter": "~1.0.0"
|
"async-limiter": "~1.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hack.chat-v2",
|
"name": "hack.chat-v2",
|
||||||
"version": "2.1.0",
|
"version": "2.1.9",
|
||||||
"description": "a minimal distraction free chat application",
|
"description": "a minimal distraction free chat application",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -18,14 +18,14 @@
|
||||||
"author": "Marzavec",
|
"author": "Marzavec",
|
||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^2.3.2",
|
"chalk": "^2.4.2",
|
||||||
"common-tags": "^1.7.2",
|
"common-tags": "^1.8.0",
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
"deasync": "^0.1.12",
|
"deasync": "^0.1.14",
|
||||||
"didyoumean2": "^1.3.0",
|
"didyoumean2": "^2.0.2",
|
||||||
"fs-extra": "^5.0.0",
|
"fs-extra": "^7.0.1",
|
||||||
"prompt": "^1.0.0",
|
"prompt": "^1.0.0",
|
||||||
"readdir-recursive": "0.0.4",
|
"readdir-recursive": "0.0.4",
|
||||||
"ws": "^5.0.0"
|
"ws": "^6.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,12 @@ exports.run = async (core, server, socket, data) => {
|
||||||
return server._police.frisk(socket.remoteAddress, 20);
|
return server._police.frisk(socket.remoteAddress, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do command reloads and store results
|
// do command reload and store results
|
||||||
let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands');
|
let loadResult = core.managers.dynamicImports.reloadDirCache('src/commands');
|
||||||
loadResult += core.commands.loadCommands();
|
loadResult += core.commands.loadCommands();
|
||||||
|
|
||||||
// clear and rebuild all module hooks
|
// clear and rebuild all module hooks
|
||||||
server.clearHooks();
|
server.loadHooks();
|
||||||
core.commands.initCommandHooks(server);
|
|
||||||
|
|
||||||
// build reply based on reload results
|
// build reply based on reload results
|
||||||
if (loadResult == '') {
|
if (loadResult == '') {
|
||||||
|
|
|
@ -85,10 +85,10 @@ exports.run = async (core, server, socket, data) => {
|
||||||
|
|
||||||
// module hook functions
|
// module hook functions
|
||||||
exports.initHooks = (server) => {
|
exports.initHooks = (server) => {
|
||||||
server.registerHook('in', 'chat', this.nickCheck);
|
server.registerHook('in', 'chat', this.nickCheck, 29);
|
||||||
};
|
};
|
||||||
|
|
||||||
// hooks chat commands checking for /whisper
|
// hooks chat commands checking for /nick
|
||||||
exports.nickCheck = (core, server, socket, payload) => {
|
exports.nickCheck = (core, server, socket, payload) => {
|
||||||
if (typeof payload.text !== 'string') {
|
if (typeof payload.text !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -62,8 +62,8 @@ exports.run = async (core, server, socket, data) => {
|
||||||
|
|
||||||
// module hook functions
|
// module hook functions
|
||||||
exports.initHooks = (server) => {
|
exports.initHooks = (server) => {
|
||||||
server.registerHook('in', 'chat', this.commandCheckIn);
|
server.registerHook('in', 'chat', this.commandCheckIn, 20);
|
||||||
server.registerHook('out', 'chat', this.commandCheckOut);
|
server.registerHook('in', 'chat', this.finalCmdCheck, 254);
|
||||||
};
|
};
|
||||||
|
|
||||||
// checks for miscellaneous '/' based commands
|
// checks for miscellaneous '/' based commands
|
||||||
|
@ -84,31 +84,26 @@ exports.commandCheckIn = (core, server, socket, payload) => {
|
||||||
return payload;
|
return payload;
|
||||||
};
|
};
|
||||||
|
|
||||||
// checks for miscellaneous '/' based commands
|
exports.finalCmdCheck = (core, server, socket, payload) => {
|
||||||
exports.commandCheckOut = (core, server, socket, payload) => {
|
if (typeof payload.text !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!payload.text.startsWith('/')) {
|
if (!payload.text.startsWith('/')) {
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make emotes their own module/event #lazydev
|
if (payload.text.startsWith('//')) {
|
||||||
if (payload.text.startsWith('//me ')) {
|
payload.text = payload.text.substr(1);
|
||||||
payload.text = payload.text.substr(1, payload.text.length);
|
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
} else if (payload.text.startsWith('/me ')) {
|
} else {
|
||||||
let emote = payload.text.substr(4);
|
server.reply({
|
||||||
if (emote.trim() === '') {
|
cmd: 'warn',
|
||||||
emote = 'fails at life';
|
text: `Unknown command: ${payload.text}`
|
||||||
}
|
}, socket);
|
||||||
|
|
||||||
let newPayload = {
|
return false;
|
||||||
cmd: 'info',
|
|
||||||
type: 'emote',
|
|
||||||
nick: payload.nick,
|
|
||||||
text: `@${payload.nick} ${emote}`
|
|
||||||
};
|
|
||||||
|
|
||||||
return newPayload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
|
@ -123,6 +118,5 @@ exports.info = {
|
||||||
API: { cmd: 'chat', text: '<text to send>' }
|
API: { cmd: 'chat', text: '<text to send>' }
|
||||||
Text: Uuuuhm. Just kind type in that little box at the bottom and hit enter.\n
|
Text: Uuuuhm. Just kind type in that little box at the bottom and hit enter.\n
|
||||||
Bonus super secret hidden commands:
|
Bonus super secret hidden commands:
|
||||||
/me <emote>
|
|
||||||
/myhash`
|
/myhash`
|
||||||
};
|
};
|
||||||
|
|
96
server/src/commands/core/emote.js
Normal file
96
server/src/commands/core/emote.js
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
Description: Broadcasts an emote to the current channel
|
||||||
|
*/
|
||||||
|
|
||||||
|
// module support functions
|
||||||
|
const parseText = (text) => {
|
||||||
|
// verifies user input is text
|
||||||
|
if (typeof text !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// strip newlines from beginning and end
|
||||||
|
text = text.replace(/^\s*\n|^\s+$|\n\s*$/g, '');
|
||||||
|
// replace 3+ newlines with just 2 newlines
|
||||||
|
text = text.replace(/\n{3,}/g, "\n\n");
|
||||||
|
|
||||||
|
return text;
|
||||||
|
};
|
||||||
|
|
||||||
|
// module main
|
||||||
|
exports.run = async (core, server, socket, payload) => {
|
||||||
|
// check user input
|
||||||
|
let text = parseText(payload.text);
|
||||||
|
|
||||||
|
if (!text) {
|
||||||
|
// lets not send objects or empty text, yea?
|
||||||
|
return server._police.frisk(socket.remoteAddress, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for spam
|
||||||
|
let score = text.length / 83 / 4;
|
||||||
|
if (server._police.frisk(socket.remoteAddress, score)) {
|
||||||
|
return server.reply({
|
||||||
|
cmd: 'warn',
|
||||||
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.'
|
||||||
|
}, socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
let newPayload = {
|
||||||
|
cmd: 'info',
|
||||||
|
type: 'emote',
|
||||||
|
nick: socket.nick,
|
||||||
|
text: `@${socket.nick} ${text}`
|
||||||
|
};
|
||||||
|
|
||||||
|
// broadcast to channel peers
|
||||||
|
server.broadcast( newPayload, { channel: socket.channel});
|
||||||
|
};
|
||||||
|
|
||||||
|
// module hook functions
|
||||||
|
exports.initHooks = (server) => {
|
||||||
|
server.registerHook('in', 'chat', this.emoteCheck, 30);
|
||||||
|
};
|
||||||
|
|
||||||
|
// hooks chat commands checking for /me
|
||||||
|
exports.emoteCheck = (core, server, socket, payload) => {
|
||||||
|
if (typeof payload.text !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.text.startsWith('/me ')) {
|
||||||
|
let input = payload.text.split(' ');
|
||||||
|
|
||||||
|
// If there is no emote target parameter
|
||||||
|
if (input[1] === undefined) {
|
||||||
|
server.reply({
|
||||||
|
cmd: 'warn',
|
||||||
|
text: 'Refer to `/help emote` for instructions on how to use this command.'
|
||||||
|
}, socket);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.splice(0, 1);
|
||||||
|
let actionText = input.join(' ');
|
||||||
|
|
||||||
|
this.run(core, server, socket, {
|
||||||
|
cmd: 'emote',
|
||||||
|
text: actionText
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
};
|
||||||
|
|
||||||
|
// module meta
|
||||||
|
exports.requiredData = ['text'];
|
||||||
|
exports.info = {
|
||||||
|
name: 'emote',
|
||||||
|
description: 'Typical emote / action text',
|
||||||
|
usage: `
|
||||||
|
API: { cmd: 'emote', text: '<emote/action text>' }
|
||||||
|
Text: /me <emote/action text>`
|
||||||
|
};
|
|
@ -57,7 +57,7 @@ exports.run = async (core, server, socket, payload) => {
|
||||||
|
|
||||||
// module hook functions
|
// module hook functions
|
||||||
exports.initHooks = (server) => {
|
exports.initHooks = (server) => {
|
||||||
server.registerHook('in', 'chat', this.helpCheck);
|
server.registerHook('in', 'chat', this.helpCheck, 28);
|
||||||
};
|
};
|
||||||
|
|
||||||
// hooks chat commands checking for /whisper
|
// hooks chat commands checking for /whisper
|
||||||
|
@ -67,7 +67,7 @@ exports.helpCheck = (core, server, socket, payload) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.text.startsWith('/help')) {
|
if (payload.text.startsWith('/help')) {
|
||||||
let input = payload.text.substr(1, payload.text.length).split(' ', 2);
|
let input = payload.text.substr(1).split(' ', 2);
|
||||||
|
|
||||||
this.run(core, server, socket, {
|
this.run(core, server, socket, {
|
||||||
cmd: input[0],
|
cmd: input[0],
|
||||||
|
|
|
@ -58,7 +58,7 @@ exports.run = async (core, server, socket, data) => {
|
||||||
|
|
||||||
// module hook functions
|
// module hook functions
|
||||||
exports.initHooks = (server) => {
|
exports.initHooks = (server) => {
|
||||||
server.registerHook('in', 'chat', this.statsCheck);
|
server.registerHook('in', 'chat', this.statsCheck, 26);
|
||||||
};
|
};
|
||||||
|
|
||||||
// hooks chat commands checking for /stats
|
// hooks chat commands checking for /stats
|
||||||
|
|
|
@ -74,7 +74,7 @@ exports.run = async (core, server, socket, payload) => {
|
||||||
|
|
||||||
// module hook functions
|
// module hook functions
|
||||||
exports.initHooks = (server) => {
|
exports.initHooks = (server) => {
|
||||||
server.registerHook('in', 'chat', this.whisperCheck);
|
server.registerHook('in', 'chat', this.whisperCheck, 20);
|
||||||
};
|
};
|
||||||
|
|
||||||
// hooks chat commands checking for /whisper
|
// hooks chat commands checking for /whisper
|
||||||
|
|
20
server/src/commands/internal/legacylayer.js
Normal file
20
server/src/commands/internal/legacylayer.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
Description: This module adjusts outgoing data, making it compatible with legacy clients
|
||||||
|
*/
|
||||||
|
|
||||||
|
// module main
|
||||||
|
exports.run = async (core, server, socket, data) => {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
// module hook functions
|
||||||
|
exports.initHooks = (server) => {
|
||||||
|
// module is only a placeholder
|
||||||
|
//server.registerHook('out', '', this.);
|
||||||
|
};
|
||||||
|
|
||||||
|
// module meta
|
||||||
|
exports.info = {
|
||||||
|
name: 'legacylayer',
|
||||||
|
description: 'This module adjusts outgoing data, making it compatible with legacy clients'
|
||||||
|
};
|
|
@ -61,8 +61,8 @@ exports.run = async (core, server, socket, data) => {
|
||||||
|
|
||||||
// module hook functions
|
// module hook functions
|
||||||
exports.initHooks = (server) => {
|
exports.initHooks = (server) => {
|
||||||
server.registerHook('in', 'chat', this.chatCheck);
|
server.registerHook('in', 'chat', this.chatCheck, 25);
|
||||||
server.registerHook('in', 'invite', this.inviteCheck);
|
server.registerHook('in', 'invite', this.inviteCheck, 25);
|
||||||
// TODO: add whisper hook, need hook priorities todo finished first
|
// TODO: add whisper hook, need hook priorities todo finished first
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,7 @@ class server extends wsServer {
|
||||||
this._cmdBlacklist = {};
|
this._cmdBlacklist = {};
|
||||||
this._cmdKey = internalCmdKey;
|
this._cmdKey = internalCmdKey;
|
||||||
|
|
||||||
this._heartBeat = setInterval(((data) => {
|
this._heartBeat = setInterval(() => this.beatHeart(), pulseSpeed);
|
||||||
this.beatHeart();
|
|
||||||
}).bind(this), pulseSpeed);
|
|
||||||
|
|
||||||
this.on('error', (err) => {
|
this.on('error', (err) => {
|
||||||
this.handleError('server', err);
|
this.handleError('server', err);
|
||||||
|
@ -42,7 +40,7 @@ class server extends wsServer {
|
||||||
this.newConnection(socket, request);
|
this.newConnection(socket, request);
|
||||||
});
|
});
|
||||||
|
|
||||||
this._core.commands.initCommandHooks(this);
|
this.loadHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,17 +72,17 @@ class server extends wsServer {
|
||||||
newConnection (socket, request) {
|
newConnection (socket, request) {
|
||||||
socket.remoteAddress = request.headers['x-forwarded-for'] || request.connection.remoteAddress;
|
socket.remoteAddress = request.headers['x-forwarded-for'] || request.connection.remoteAddress;
|
||||||
|
|
||||||
socket.on('message', ((data) => {
|
socket.on('message', (data) => {
|
||||||
this.handleData(socket, data);
|
this.handleData(socket, data);
|
||||||
}).bind(this));
|
});
|
||||||
|
|
||||||
socket.on('close', (() => {
|
socket.on('close', () => {
|
||||||
this.handleClose(socket);
|
this.handleClose(socket);
|
||||||
}).bind(this));
|
});
|
||||||
|
|
||||||
socket.on('error', ((err) => {
|
socket.on('error', (err) => {
|
||||||
this.handleError(socket, err);
|
this.handleError(socket, err);
|
||||||
}).bind(this));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,6 +323,39 @@ class server extends wsServer {
|
||||||
return sha.digest('base64').substr(0, 15);
|
return sha.digest('base64').substr(0, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Re)loads all command module hooks, then sorts their order of operation by
|
||||||
|
* priority, ascending (0 being highest priority)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
loadHooks () {
|
||||||
|
// clear current hooks (if any)
|
||||||
|
this.clearHooks();
|
||||||
|
// notify each module to register their hooks (if any)
|
||||||
|
this._core.commands.initCommandHooks(this);
|
||||||
|
|
||||||
|
if (typeof this._hooks['in'] !== 'undefined') {
|
||||||
|
// start sorting, with incoming first
|
||||||
|
let curHooks = [ ...this._hooks['in'].keys() ];
|
||||||
|
let hookObj = [];
|
||||||
|
for (let i = 0, j = curHooks.length; i < j; i++) {
|
||||||
|
hookObj = this._hooks['in'].get(curHooks[i]);
|
||||||
|
hookObj.sort( (h1, h2) => h1.priority - h2.priority );
|
||||||
|
this._hooks['in'].set(hookObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof this._hooks['out'] !== 'undefined') {
|
||||||
|
// then outgoing
|
||||||
|
curHooks = [ ...this._hooks['out'].keys() ];
|
||||||
|
for (let i = 0, j = curHooks.length; i < j; i++) {
|
||||||
|
hookObj = this._hooks['out'].get(curHooks[i]);
|
||||||
|
hookObj.sort( (h1, h2) => h1.priority - h2.priority );
|
||||||
|
this._hooks['out'].set(hookObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a target function to an array of hooks. Hooks are executed either before
|
* Adds a target function to an array of hooks. Hooks are executed either before
|
||||||
* processing user input (`in`) or before sending data back to the client (`out`)
|
* processing user input (`in`) or before sending data back to the client (`out`)
|
||||||
|
@ -333,9 +364,13 @@ class server extends wsServer {
|
||||||
* @param {String} type The type of event, typically `in` (incoming) or `out` (outgoing)
|
* @param {String} type The type of event, typically `in` (incoming) or `out` (outgoing)
|
||||||
* @param {String} command Should match the desired `cmd` attrib of the payload
|
* @param {String} command Should match the desired `cmd` attrib of the payload
|
||||||
* @param {Function} hookFunction Target function to execute, should accept `server`, `socket` and `payload` as parameters
|
* @param {Function} hookFunction Target function to execute, should accept `server`, `socket` and `payload` as parameters
|
||||||
|
* @param {Number} priority Execution priority, hooks with priority 1 will be executed before hooks with priority 200 for example
|
||||||
*/
|
*/
|
||||||
// TODO: add hook priority levels
|
registerHook (type, command, hookFunction, priority) {
|
||||||
registerHook (type, command, hookFunction) {
|
if (typeof priority === 'undefined') {
|
||||||
|
priority = 25;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof this._hooks[type] === 'undefined') {
|
if (typeof this._hooks[type] === 'undefined') {
|
||||||
this._hooks[type] = new Map();
|
this._hooks[type] = new Map();
|
||||||
}
|
}
|
||||||
|
@ -344,7 +379,10 @@ class server extends wsServer {
|
||||||
this._hooks[type].set(command, []);
|
this._hooks[type].set(command, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._hooks[type].get(command).push(hookFunction);
|
this._hooks[type].get(command).push({
|
||||||
|
run: hookFunction,
|
||||||
|
priority: priority
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -367,14 +405,14 @@ class server extends wsServer {
|
||||||
|
|
||||||
for (let i = 0, j = hooks.length; i < j; i++) {
|
for (let i = 0, j = hooks.length; i < j; i++) {
|
||||||
try {
|
try {
|
||||||
payload = hooks[i](this._core, this, socket, payload);
|
payload = hooks[i].run(this._core, this, socket, payload);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
let errText = `Hook failure, '${type}', '${command}': ${err}`;
|
let errText = `Hook failure, '${type}', '${command}': ${err}`;
|
||||||
console.log(errText);
|
console.log(errText);
|
||||||
return errText;
|
return errText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A payload may choose to return false to prevent all further processing
|
// A hook function may choose to return false to prevent all further processing
|
||||||
if (payload === false) {
|
if (payload === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,6 @@ class ConfigManager {
|
||||||
conf = this.load();
|
conf = this.load();
|
||||||
|
|
||||||
// websocketport is the last core config question, wait until it's been populated
|
// websocketport is the last core config question, wait until it's been populated
|
||||||
// TODO: update this to work with new plugin support
|
|
||||||
while(conf === null || typeof conf.websocketPort === 'undefined') {
|
while(conf === null || typeof conf.websocketPort === 'undefined') {
|
||||||
deSync.sleep(100);
|
deSync.sleep(100);
|
||||||
}
|
}
|
||||||
|
@ -138,8 +137,8 @@ class ConfigManager {
|
||||||
${chalk.gray('--------------(') + chalk.white(' HackChat Setup Wizard v1.0 ') + chalk.gray(')--------------')}
|
${chalk.gray('--------------(') + chalk.white(' HackChat Setup Wizard v1.0 ') + chalk.gray(')--------------')}
|
||||||
${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')}
|
${chalk.magenta('°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸°º¤ø,¸¸,ø¤º°`°º¤ø')}
|
||||||
|
|
||||||
For advanced setup, see the HackChat wiki at:
|
For advanced setup, see the documentation at:
|
||||||
${chalk.green('https://github.com/')}
|
${chalk.green('https://github.com/hack-chat/main/tree/master/documentation')}
|
||||||
|
|
||||||
${chalk.white('Note:')} ${chalk.green('npm/yarn run config')} will re-run this utility.
|
${chalk.white('Note:')} ${chalk.green('npm/yarn run config')} will re-run this utility.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user