add !whisper command for tiny chats

This commit is contained in:
rainbow napkin 2024-12-08 13:05:09 -05:00
parent 4c1f0f10a7
commit 0182c6927e
6 changed files with 92 additions and 37 deletions

View file

@ -14,9 +14,6 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//NPM Imports
const validator = require('validator');//No express here, so regular validator it is!
//local imports
const commandPreprocessor = require('./commandPreprocessor');
const loggerUtils = require('../../utils/loggerUtils');
@ -38,19 +35,6 @@ module.exports = class{
this.commandPreprocessor.preprocess(socket, data);
}
relayChat(socket, data){
//Trim and Sanatize for XSS
const msg = validator.trim(validator.escape(data));
const user = this.server.getSocketInfo(socket);
//nuke the message if its empty or huge
if(!validator.isLength(msg, {min: 1, max: 255})){
return;
}
this.server.io.in(socket.chan).emit("chatMessage", {user: user.user, flair: user.flair, highLevel: user.highLevel, msg});
}
async setFlair(socket, data){
var userDB = await userModel.findOne({user: socket.user.user});
@ -94,4 +78,9 @@ module.exports = class{
}
}
}
relayChat(socket, msg, type = 'chat'){
const user = this.server.getSocketInfo(socket);
this.server.io.in(socket.chan).emit("chatMessage", {user: user.user, flair: user.flair, highLevel: user.highLevel, msg, type});
}
}