kallefrombosnia / hlds-log Goto Github PK
View Code? Open in Web Editor NEWHLDS remote log parser in node.js
License: MIT License
HLDS remote log parser in node.js
License: MIT License
Bad regex parsing lead to an incorrect name of a weapon in kill
event.
Example: {weapon: 'usp\n0000'}
/root/DiscordBot/node_modules/hlds-log/functions.js:63
this.emit(type.event, type);
^
TypeError: Cannot read property 'event' of undefined
at /root/DiscordBot/node_modules/hlds-log/functions.js:63:24
at Array.forEach (<anonymous>)
at HLDS_Log.regexSearch (/root/DiscordBot/node_modules/hlds-log/functions.js:60:16)
at Socket.<anonymous> (/root/DiscordBot/node_modules/hlds-log/functions.js:48:12)
at Socket.emit (events.js:315:20)
? nodejs -v
v12.17.0
When the server shuts down and message is being sent its not complete so parser fails with fatal error.
I'm getting an error when attempting to log 'say', 'say_team' and 'kill' signals.
am I doing something wrong? I've included my code at the end.
����log L 09/01/2021 - 07:55:32: "monkey<1><STEAM_ID_LAN><1>" say "lkjasldjsa"
Error spotted: TypeError: Cannot read property 'event' of null
Error spotted: TypeError: Cannot read property 'event' of null
at D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:58:36
at Array.forEach (<anonymous>)
at HLDS_Log.regexSearch (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:55:24)
at Socket.<anonymous> (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:44:18)
at Socket.emit (events.js:321:20)
at UDP.onMessage [as onmessage] (dgram.js:924:8)
log L 09/01/2021 - 08:14:15: "ryuichi<8>" killed "Billy<10>" with 9mmhandgun
Error spotted: TypeError: Cannot read property 'event' of null
Error spotted: TypeError: Cannot read property 'event' of null
at D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:58:36
at Array.forEach (<anonymous>)
at HLDS_Log.regexSearch (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:55:24)
at Socket.<anonymous> (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:44:18)
at Socket.emit (events.js:321:20)
at UDP.onMessage [as onmessage] (dgram.js:924:8)
/*jshint esversion: 6 */
const {HLDS_Log}= require('hlds-log');
//const {HLDS_Log} = require('../lib/app');
logger = new HLDS_Log(3000, true);
// Start logger
logger.start();
// Increase listeners limit to avoid warning
logger.setMaxListeners(15);
logger.once('hlds_connect', (info) => {
console.log('Server connected!' + info.address);
});
logger.on('kill', info =>{
console.log(info);
});
logger.on('raw', raw => {
console.log(raw);
});
logger.on('say_team', info => {
console.log(info);
});
logger.on('say', info => {
console.log(info);
});
logger.on('join', info => {
console.log(info);
});
logger.on('leave', info => {
console.log(info);
});
logger.on('enter', info => {
console.log(info);
});
logger.on('end_score', info => {
console.log(info);
});
logger.on('player_action', info => {
console.log(info);
});
logger.on('server_action', info => {
console.log(info);
});
logger.on('round_end', info => {
console.log(info);
});
logger.on('connect', info => {
console.log(info);
});
logger.on('map_change', info => {
console.log(info);
});
logger.on('map_start', info => {
console.log(info);
});
logger.on('suicide', info => {
console.log(info);
});
logger.on('shutdown', info => {
console.log(info);
});
logger.on('log_off', info => {
console.log(info);
});
logger.on('cvarsDone', info => {
console.log(info);
});
logger.on('kick', info => {
console.log(info);
});
logger.on('error', error =>{
console.log('Error spotted: ', error)
})
const cvar = (line) => {
//log L 12/16/2019 - 22:20:09: Server cvar "mp_friendlyfire" = "0"
const items = line.match(
/log L ([0-9]{2})\/([0-9]{2})\/([0-9]{4}) - ([01]?\d|2[0-3]):([0-5]\d):([0-5]\d): Server cvar "(.+)" = "(.*)"/i
);
return {
event: "cvar",
cvarName: items[7],
cvarValue: items[8],
time: {
ss: items[6],
mm: items[5],
hh: items[4]
},
date: {
dd: items[2],
mm: items[1],
yy: items[3]
}
};
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.