mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-18 08:43:57 +00:00
31 lines
706 B
JavaScript
31 lines
706 B
JavaScript
import { createServer } from 'node:net';
|
|
import { deserialize } from 'bson';
|
|
import FastText from 'fasttext.js';
|
|
import { runAI, trainAI } from './events/index.js';
|
|
|
|
const ft = new FastText({
|
|
loadModel: './model/model.bin'
|
|
});
|
|
|
|
ft.load();
|
|
|
|
const server = createServer(async (client) => {
|
|
client.on('data', async (data) => {
|
|
const eventData = deserialize(data);
|
|
|
|
switch(eventData.event) {
|
|
case 'ai': {
|
|
runAI(client, eventData, ft.predict);
|
|
break;
|
|
}
|
|
|
|
case 'train_ai': {
|
|
trainAI(ft.unload, ft.load);
|
|
break;
|
|
}
|
|
}
|
|
|
|
});
|
|
});
|
|
|
|
server.listen(process.env.PORT || 3000); |