diff options
author | gumi <git@gumi.ca> | 2018-04-03 19:55:12 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-04-03 19:55:12 -0400 |
commit | 6fbea1b71025c16f537546459f739d73b1c3f3f9 (patch) | |
tree | d6be913e2acfabcc57534c3ae3d381ea970dd9ac | |
parent | b710b746b9aadf82e7ba60cd11e384378e51e206 (diff) | |
download | apiv1-6fbea1b71025c16f537546459f739d73b1c3f3f9.tar.gz apiv1-6fbea1b71025c16f537546459f739d73b1c3f3f9.tar.bz2 apiv1-6fbea1b71025c16f537546459f739d73b1c3f3f9.tar.xz apiv1-6fbea1b71025c16f537546459f739d73b1c3f3f9.zip |
fix a crash when no user is online on tmwav0.1.1
-rw-r--r-- | server.js | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; |