mirror of
https://github.com/Sithranduil/srcds_exporter.git
synced 2025-07-23 17:28:00 +02:00
Ajout du support de gametracker
This commit is contained in:
20
modules/gametracker.js
Normal file
20
modules/gametracker.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import utils from '../utils/utils.js';
|
||||
import metrics from './metrics.js';
|
||||
|
||||
export default {
|
||||
async request(ip, port) {
|
||||
const dom = await utils.requestGameTracker(ip, port);
|
||||
const htmlDivElement = dom.window.document.querySelector('.block630_content_left');
|
||||
let rankLine = utils.searchLine(htmlDivElement.textContent, 'Percentile');
|
||||
rankLine = rankLine[0].trim();
|
||||
const rankRegex = RegExp('^(\\d+)');
|
||||
const rank = rankRegex.exec(rankLine)[0];
|
||||
return {
|
||||
rank,
|
||||
};
|
||||
},
|
||||
setMetrics(response) {
|
||||
const rank = response.rank || 0;
|
||||
metrics.gametrackerRank.set((Number(rank)));
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user