More work decoupling chatPreprocessor from src/app/channel.

This commit is contained in:
rainbow napkin 2025-10-02 03:38:40 -04:00
parent 23ad679473
commit 0ed1c0dd89
4 changed files with 24 additions and 50 deletions

View file

@ -18,7 +18,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
const validator = require('validator')
//local imports
const commandPreprocessor = require('./commandPreprocessor');
const chatPreprocessor = require('../chatPreprocessor');
const commandProcessor = require('./commandProcessor');
const tokebot = require('./tokebot');
const loggerUtils = require('../../utils/loggerUtils');
const linkUtils = require('../../utils/linkUtils');
const emoteValidator = require('../../validators/emoteValidator');
@ -42,7 +44,11 @@ class chatHandler{
/**
* Child Command Pre-Processor Object
*/
this.commandPreprocessor = new commandPreprocessor(server, this)
this.chatPreprocessor = new chatPreprocessor(
server,
new commandProcessor(server, this),
new tokebot(server, this)
);
/**
* Max chat buffer message count
@ -67,8 +73,15 @@ class chatHandler{
* @param {Socket} socket - Socket we're receiving the request from
* @param {Object} data - Event payload
*/
handleChat(socket, data){
this.commandPreprocessor.preprocess(socket, data);
async handleChat(socket, data){
//Preprocess chat data
const preprocessedChat = await this.chatPreprocessor.preprocess(socket, data);
//If send flag wasn't set to false
if(preprocessedChat != false){
//Send that shit!
this.relayUserChat(socket, preprocessedChat.message, preprocessedChat.chatType, preprocessedChat.links);
}
}
/**