mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
chore: initialize a new project
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
import { Socket } from 'node:net';
|
||||
import { serialize, deserialize } from 'bson';
|
||||
import EventEmitter from 'node:events';
|
||||
|
||||
class HelperClient extends EventEmitter {
|
||||
constructor({ server }) {
|
||||
super();
|
||||
if (!server?.port) throw new Error('You did not specify the server port.');
|
||||
this.server = server;
|
||||
this.client = new Socket();
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.client.connect(
|
||||
this.server.port,
|
||||
this.server.host ? this.server.host : 'localhost'
|
||||
);
|
||||
|
||||
this.client.on('data', (data) => {
|
||||
const eventData = deserialize(data, {
|
||||
allowObjectSmallerThanBufferSize: true
|
||||
});
|
||||
|
||||
switch (eventData.op) {
|
||||
case 2: {
|
||||
// The 'aiResponse' event.
|
||||
|
||||
this.emit('aiResponse', eventData);
|
||||
break;
|
||||
}
|
||||
|
||||
case 6: {
|
||||
// The 'ocrResponse' event.
|
||||
|
||||
this.emit('ocrResponse', eventData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.client.on('connect', () => {
|
||||
if (this.reconnectionInterval) {
|
||||
clearInterval(this.reconnectionInterval);
|
||||
this.reconnectionInterval = null;
|
||||
}
|
||||
|
||||
this.emit('connect');
|
||||
});
|
||||
|
||||
this.client.on('close', () => {
|
||||
this.reconnectionInterval = setInterval(() => {
|
||||
this.client.connect(
|
||||
this.server.port,
|
||||
this.server.host ? this.server.host : 'localhost'
|
||||
);
|
||||
}, 5000);
|
||||
})
|
||||
}
|
||||
|
||||
sendData(data) {
|
||||
this.client.write(serialize(data));
|
||||
return;
|
||||
}
|
||||
|
||||
scanText(text, id) {
|
||||
this.sendData({
|
||||
op: 1,
|
||||
id,
|
||||
text
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
scanImage(url, id) {
|
||||
this.sendData({
|
||||
op: 5,
|
||||
id,
|
||||
url
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sendTrainData(text, label) {
|
||||
this.sendData({
|
||||
op: 3,
|
||||
label,
|
||||
text
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trainAI() {
|
||||
this.sendData({ op: 4 });
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export default HelperClient;
|
||||
117
packages/client/package-lock.json
generated
117
packages/client/package-lock.json
generated
@@ -1,117 +0,0 @@
|
||||
{
|
||||
"name": "helper-client",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "helper-client",
|
||||
"version": "1.0.0",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"bson": "^4.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/bson": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
|
||||
"integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==",
|
||||
"dependencies": {
|
||||
"buffer": "^5.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"base64-js": "^1.3.1",
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
"node_modules/ieee754": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"bson": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
|
||||
"integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==",
|
||||
"requires": {
|
||||
"buffer": "^5.6.0"
|
||||
}
|
||||
},
|
||||
"buffer": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"requires": {
|
||||
"base64-js": "^1.3.1",
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
"ieee754": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "@revanced-helper/helper-client",
|
||||
"version": "1.0.0",
|
||||
"description": "The ReVanced Helper client.",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Reis Can",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"bson": "^4.7.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user