From 6fbea1b71025c16f537546459f739d73b1c3f3f9 Mon Sep 17 00:00:00 2001 From: gumi Date: Tue, 3 Apr 2018 19:55:12 -0400 Subject: fix a crash when no user is online on tmwa --- server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 9f39adc..2e9bb2b 100644 --- a/server.js +++ b/server.js @@ -22,8 +22,9 @@ const tmwa = { const last_online = Date.parse(lines[0].match(/\((.+)\)/)[1] + ` ${process.env.npm_package_config_timezone}`); if (Date.now() - last_online < 30000) { + const num = lines[lines.length - 2].match(/([0-9]+) users are online./); tmwa.status = "Online"; - tmwa.num_online = lines[lines.length - 2].match(/([0-9]+) users are online./)[1]; + tmwa.num_online = num ? num[1] : 0; } else { tmwa.status = "OfflineTemporarily"; tmwa.num_online = 0; -- cgit v1.2.3-60-g2f50