2015-09-11 03:01:04 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2018-06-23 03:26:46 +00:00
|
|
|
// ENiGMA½
|
2022-06-05 20:04:25 +00:00
|
|
|
const Config = require('./config.js').get;
|
|
|
|
const Log = require('./logger.js').log;
|
|
|
|
const { getMessageAreaByTag, getMessageConferenceByTag } = require('./message_area.js');
|
|
|
|
const clientConnections = require('./client_connections.js');
|
|
|
|
const StatLog = require('./stat_log.js');
|
|
|
|
const FileBaseFilters = require('./file_base_filter.js');
|
|
|
|
const { formatByteSize } = require('./string_util.js');
|
|
|
|
const ANSI = require('./ansi_term.js');
|
|
|
|
const UserProps = require('./user_property.js');
|
|
|
|
const SysProps = require('./system_property.js');
|
|
|
|
const SysLogKeys = require('./system_log.js');
|
2018-06-23 03:26:46 +00:00
|
|
|
|
|
|
|
// deps
|
|
|
|
const packageJson = require('../package.json');
|
|
|
|
const os = require('os');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const moment = require('moment');
|
2020-11-22 19:25:19 +00:00
|
|
|
const async = require('async');
|
2018-06-23 03:26:46 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
exports.getPredefinedMCIValue = getPredefinedMCIValue;
|
|
|
|
exports.init = init;
|
2016-08-11 04:48:13 +00:00
|
|
|
|
|
|
|
function init(cb) {
|
2020-11-22 19:25:19 +00:00
|
|
|
async.series(
|
|
|
|
[
|
|
|
|
(callback) => {
|
|
|
|
return setNextRandomRumor(callback);
|
|
|
|
},
|
2020-11-23 01:54:49 +00:00
|
|
|
(callback) => {
|
|
|
|
// by fetching a memory or load we'll force a refresh now
|
|
|
|
StatLog.getSystemStat(SysProps.SystemMemoryStats);
|
|
|
|
return callback(null);
|
|
|
|
}
|
2020-11-22 19:25:19 +00:00
|
|
|
],
|
|
|
|
err => {
|
|
|
|
return cb(err);
|
|
|
|
}
|
|
|
|
);
|
2016-08-11 04:48:13 +00:00
|
|
|
}
|
|
|
|
|
2020-11-23 01:54:49 +00:00
|
|
|
// :TODO: move this to stat_log.js like system memory is handled
|
2016-08-11 04:48:13 +00:00
|
|
|
function setNextRandomRumor(cb) {
|
2022-06-05 20:04:25 +00:00
|
|
|
StatLog.getSystemLogEntries(
|
|
|
|
SysLogKeys.UserAddedRumorz,
|
|
|
|
StatLog.Order.Random,
|
|
|
|
1,
|
|
|
|
(err, entry) => {
|
|
|
|
if (entry) {
|
|
|
|
entry = entry[0];
|
|
|
|
}
|
|
|
|
const randRumor = entry && entry.log_value ? entry.log_value : '';
|
|
|
|
StatLog.setNonPersistentSystemStat(SysProps.NextRandomRumor, randRumor);
|
|
|
|
if (cb) {
|
|
|
|
return cb(null);
|
|
|
|
}
|
2018-06-22 05:15:04 +00:00
|
|
|
}
|
2022-06-05 20:04:25 +00:00
|
|
|
);
|
2016-08-11 04:48:13 +00:00
|
|
|
}
|
2015-09-11 03:01:04 +00:00
|
|
|
|
2017-07-09 22:48:53 +00:00
|
|
|
function getUserRatio(client, propA, propB) {
|
2018-06-22 05:15:04 +00:00
|
|
|
const a = StatLog.getUserStatNum(client.user, propA);
|
2018-06-23 03:26:46 +00:00
|
|
|
const b = StatLog.getUserStatNum(client.user, propB);
|
|
|
|
const ratio = ~~((a / b) * 100);
|
2018-06-22 05:15:04 +00:00
|
|
|
return `${ratio}%`;
|
2017-01-19 05:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function userStatAsString(client, statName, defaultValue) {
|
2018-06-22 05:15:04 +00:00
|
|
|
return (StatLog.getUserStat(client.user, statName) || defaultValue).toLocaleString();
|
2017-01-19 05:23:53 +00:00
|
|
|
}
|
|
|
|
|
2019-01-26 19:57:29 +00:00
|
|
|
function toNumberWithCommas(x) {
|
|
|
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
|
|
}
|
|
|
|
|
|
|
|
function userStatAsCountString(client, statName, defaultValue) {
|
|
|
|
const value = StatLog.getUserStatNum(client.user, statName) || defaultValue;
|
|
|
|
return toNumberWithCommas(value);
|
|
|
|
}
|
|
|
|
|
2017-05-11 03:17:19 +00:00
|
|
|
const PREDEFINED_MCI_GENERATORS = {
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// Board
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2022-06-05 20:04:25 +00:00
|
|
|
BN: function boardName() {
|
|
|
|
return Config().general.boardName;
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2018-06-23 03:26:46 +00:00
|
|
|
// ENiGMA
|
2022-06-05 20:04:25 +00:00
|
|
|
VL: function versionLabel() {
|
|
|
|
return 'ENiGMA½ v' + packageJson.version;
|
|
|
|
},
|
|
|
|
VN: function version() {
|
|
|
|
return packageJson.version;
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2018-06-23 03:26:46 +00:00
|
|
|
// +op info
|
2018-11-26 02:05:16 +00:00
|
|
|
SN : function opUserName() { return StatLog.getSystemStat(SysProps.SysOpUsername); },
|
|
|
|
SR : function opRealName() { return StatLog.getSystemStat(SysProps.SysOpRealName); },
|
|
|
|
SL : function opLocation() { return StatLog.getSystemStat(SysProps.SysOpLocation); },
|
|
|
|
SA : function opAffils() { return StatLog.getSystemStat(SysProps.SysOpAffiliations); },
|
|
|
|
SS : function opSex() { return StatLog.getSystemStat(SysProps.SysOpSex); },
|
|
|
|
SE : function opEmail() { return StatLog.getSystemStat(SysProps.SysOpEmailAddress); },
|
2018-06-22 05:15:04 +00:00
|
|
|
|
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// Current user / session
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
UN : function userName(client) { return client.user.username; },
|
|
|
|
UI : function userId(client) { return client.user.userId.toString(); },
|
|
|
|
UG : function groups(client) { return _.values(client.user.groups).join(', '); },
|
2018-11-24 05:02:36 +00:00
|
|
|
UR : function realName(client) { return userStatAsString(client, UserProps.RealName, ''); },
|
|
|
|
LO : function location(client) { return userStatAsString(client, UserProps.Location, ''); },
|
2018-06-23 03:26:46 +00:00
|
|
|
UA : function age(client) { return client.user.getAge().toString(); },
|
2018-11-24 00:41:16 +00:00
|
|
|
BD : function birthdate(client) { // iNiQUiTY
|
|
|
|
return moment(client.user.properties[UserProps.Birthdate]).format(client.currentTheme.helpers.getDateFormat());
|
|
|
|
},
|
2018-11-24 05:02:36 +00:00
|
|
|
US : function sex(client) { return userStatAsString(client, UserProps.Sex, ''); },
|
2019-01-05 17:49:19 +00:00
|
|
|
UE : function emailAddress(client) { return userStatAsString(client, UserProps.EmailAddress, ''); },
|
2018-11-24 05:02:36 +00:00
|
|
|
UW : function webAddress(client) { return userStatAsString(client, UserProps.WebAddress, ''); },
|
|
|
|
UF : function affils(client) { return userStatAsString(client, UserProps.Affiliations, ''); },
|
2018-11-25 17:35:05 +00:00
|
|
|
UT : function themeName(client) {
|
|
|
|
return _.get(client, 'currentTheme.info.name', userStatAsString(client, UserProps.ThemeId, ''));
|
|
|
|
},
|
|
|
|
UD : function themeId(client) { return userStatAsString(client, UserProps.ThemeId, ''); },
|
2019-01-26 19:57:29 +00:00
|
|
|
UC : function loginCount(client) { return userStatAsCountString(client, UserProps.LoginCount, 0); },
|
2018-06-23 03:26:46 +00:00
|
|
|
ND : function connectedNode(client) { return client.node.toString(); },
|
2022-06-10 22:08:22 +00:00
|
|
|
IP : function clientIpAddress(client) { return client.friendlyRemoteAddress() },
|
2018-06-23 03:26:46 +00:00
|
|
|
ST : function serverName(client) { return client.session.serverName; },
|
|
|
|
FN : function activeFileBaseFilterName(client) {
|
2018-06-22 05:15:04 +00:00
|
|
|
const activeFilter = FileBaseFilters.getActiveFilter(client);
|
2018-11-17 20:24:16 +00:00
|
|
|
return activeFilter ? activeFilter.name : '(Unknown)';
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
DN: function userNumDownloads(client) {
|
|
|
|
return userStatAsCountString(client, UserProps.FileDlTotalCount, 0);
|
|
|
|
}, // Obv/2
|
|
|
|
DK: function userByteDownload(client) {
|
|
|
|
// Obv/2 uses DK=downloaded Kbytes
|
2018-11-24 05:02:36 +00:00
|
|
|
const byteSize = StatLog.getUserStatNum(client.user, UserProps.FileDlTotalBytes);
|
2022-06-05 20:04:25 +00:00
|
|
|
return formatByteSize(byteSize, true); // true=withAbbr
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
UP: function userNumUploads(client) {
|
|
|
|
return userStatAsCountString(client, UserProps.FileUlTotalCount, 0);
|
|
|
|
}, // Obv/2
|
|
|
|
UK: function userByteUpload(client) {
|
|
|
|
// Obv/2 uses UK=uploaded Kbytes
|
2018-11-24 05:02:36 +00:00
|
|
|
const byteSize = StatLog.getUserStatNum(client.user, UserProps.FileUlTotalBytes);
|
2022-06-05 20:04:25 +00:00
|
|
|
return formatByteSize(byteSize, true); // true=withAbbr
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
NR: function userUpDownRatio(client) {
|
|
|
|
// Obv/2
|
|
|
|
return getUserRatio(
|
|
|
|
client,
|
|
|
|
UserProps.FileUlTotalCount,
|
|
|
|
UserProps.FileDlTotalCount
|
|
|
|
);
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
KR: function userUpDownByteRatio(client) {
|
|
|
|
// Obv/2 uses KR=upload/download Kbyte ratio
|
|
|
|
return getUserRatio(
|
|
|
|
client,
|
|
|
|
UserProps.FileUlTotalBytes,
|
|
|
|
UserProps.FileDlTotalBytes
|
|
|
|
);
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
MS: function accountCreated(client) {
|
|
|
|
return moment(client.user.properties[UserProps.AccountCreated]).format(
|
|
|
|
client.currentTheme.helpers.getDateFormat()
|
|
|
|
);
|
|
|
|
},
|
|
|
|
PS: function userPostCount(client) {
|
|
|
|
return userStatAsCountString(client, UserProps.MessagePostCount, 0);
|
|
|
|
},
|
|
|
|
PC: function userPostCallRatio(client) {
|
|
|
|
return getUserRatio(client, UserProps.MessagePostCount, UserProps.LoginCount);
|
2018-11-24 00:41:16 +00:00
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
MD: function currentMenuDescription(client) {
|
|
|
|
return _.has(client, 'currentMenuModule.menuConfig.desc')
|
|
|
|
? client.currentMenuModule.menuConfig.desc
|
|
|
|
: '';
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
MA: function messageAreaName(client) {
|
|
|
|
const area = getMessageAreaByTag(
|
|
|
|
client.user.properties[UserProps.MessageAreaTag]
|
|
|
|
);
|
2018-06-22 05:15:04 +00:00
|
|
|
return area ? area.name : '';
|
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
MC: function messageConfName(client) {
|
|
|
|
const conf = getMessageConferenceByTag(
|
|
|
|
client.user.properties[UserProps.MessageConfTag]
|
|
|
|
);
|
2018-06-22 05:15:04 +00:00
|
|
|
return conf ? conf.name : '';
|
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
ML: function messageAreaDescription(client) {
|
|
|
|
const area = getMessageAreaByTag(
|
|
|
|
client.user.properties[UserProps.MessageAreaTag]
|
|
|
|
);
|
2018-06-22 05:15:04 +00:00
|
|
|
return area ? area.desc : '';
|
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
CM: function messageConfDescription(client) {
|
|
|
|
const conf = getMessageConferenceByTag(
|
|
|
|
client.user.properties[UserProps.MessageConfTag]
|
|
|
|
);
|
2018-06-22 05:15:04 +00:00
|
|
|
return conf ? conf.desc : '';
|
|
|
|
},
|
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
SH: function termHeight(client) {
|
|
|
|
return client.term.termHeight.toString();
|
|
|
|
},
|
|
|
|
SW: function termWidth(client) {
|
|
|
|
return client.term.termWidth.toString();
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
AC: function achievementCount(client) {
|
|
|
|
return userStatAsCountString(client, UserProps.AchievementTotalCount, 0);
|
|
|
|
},
|
|
|
|
AP: function achievementPoints(client) {
|
|
|
|
return userStatAsCountString(client, UserProps.AchievementTotalPoints, 0);
|
|
|
|
},
|
2019-01-05 17:49:19 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
DR: function doorRuns(client) {
|
|
|
|
return userStatAsCountString(client, UserProps.DoorRunTotalCount, 0);
|
|
|
|
},
|
|
|
|
DM: function doorFriendlyRunTime(client) {
|
2019-01-06 04:17:53 +00:00
|
|
|
const minutes = client.user.properties[UserProps.DoorRunTotalMinutes] || 0;
|
|
|
|
return moment.duration(minutes, 'minutes').humanize();
|
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
TO: function friendlyTotalTimeOnSystem(client) {
|
2019-01-11 03:34:52 +00:00
|
|
|
const minutes = client.user.properties[UserProps.MinutesOnlineTotalCount] || 0;
|
|
|
|
return moment.duration(minutes, 'minutes').humanize();
|
|
|
|
},
|
2022-05-12 02:30:25 +00:00
|
|
|
NM : function userNewMessagesAddressedToCount(client) {
|
|
|
|
return StatLog.getUserStatNumByClient(client, UserProps.NewAddressedToMessageCount);
|
|
|
|
},
|
|
|
|
NP : function userNewPrivateMailCount(client) {
|
|
|
|
return StatLog.getUserStatNumByClient(client, UserProps.NewPrivateMailCount);
|
|
|
|
},
|
2022-05-25 01:46:39 +00:00
|
|
|
IA : function userStatusAvailableIndicator(client) {
|
|
|
|
const indicators = client.currentTheme.helpers.getStatusAvailIndicators();
|
|
|
|
return client.user.isAvailable() ? (indicators[0] || 'Y') : (indicators[1] || 'N');
|
|
|
|
},
|
|
|
|
IV : function userStatusVisibleIndicator(client) {
|
|
|
|
const indicators = client.currentTheme.helpers.getStatusVisibleIndicators();
|
|
|
|
return client.user.isVisible() ? (indicators[0] || 'Y') : (indicators[1] || 'N');
|
|
|
|
},
|
2019-01-06 04:17:53 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// Date/Time
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2022-06-05 20:04:25 +00:00
|
|
|
DT: function date(client) {
|
|
|
|
return moment().format(client.currentTheme.helpers.getDateFormat());
|
|
|
|
},
|
|
|
|
CT: function time(client) {
|
|
|
|
return moment().format(client.currentTheme.helpers.getTimeFormat());
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// OS/System Info
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2018-11-28 04:21:00 +00:00
|
|
|
// https://github.com/nodejs/node-v0.x-archive/issues/25769
|
|
|
|
//
|
2022-06-05 20:04:25 +00:00
|
|
|
OS: function operatingSystem() {
|
|
|
|
return (
|
|
|
|
{
|
|
|
|
linux: 'Linux',
|
|
|
|
darwin: 'OS X',
|
|
|
|
win32: 'Windows',
|
|
|
|
sunos: 'SunOS',
|
|
|
|
freebsd: 'FreeBSD',
|
|
|
|
android: 'Android',
|
|
|
|
openbsd: 'OpenBSD',
|
|
|
|
aix: 'IBM AIX',
|
|
|
|
}[os.platform()] || os.type()
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
OA: function systemArchitecture() {
|
|
|
|
return os.arch();
|
|
|
|
},
|
|
|
|
|
|
|
|
SC: function systemCpuModel() {
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// Clean up CPU strings a bit for better display
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2022-06-05 20:04:25 +00:00
|
|
|
return os
|
|
|
|
.cpus()[0]
|
|
|
|
.model.replace(/\(R\)|\(TM\)|processor|CPU/gi, '')
|
2018-11-24 00:41:16 +00:00
|
|
|
.replace(/\s+(?= )/g, '')
|
|
|
|
.trim();
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
|
|
|
|
2020-11-23 01:54:49 +00:00
|
|
|
MB : function totalMemoryBytes() {
|
|
|
|
const stats = StatLog.getSystemStat(SysProps.SystemMemoryStats) || { totalBytes : 0 };
|
|
|
|
return formatByteSize(stats.totalBytes, true); // true=withAbbr
|
|
|
|
},
|
|
|
|
MF : function totalMemoryFreeBytes() {
|
|
|
|
const stats = StatLog.getSystemStat(SysProps.SystemMemoryStats) || { freeBytes : 0 };
|
|
|
|
return formatByteSize(stats.freeBytes, true); // true=withAbbr
|
|
|
|
},
|
|
|
|
LA : function systemLoadAverage() {
|
|
|
|
const stats = StatLog.getSystemStat(SysProps.SystemLoadStats) || { average : 0.0 };
|
|
|
|
return stats.average.toLocaleString();
|
|
|
|
},
|
|
|
|
CL : function systemCurrentLoad() {
|
|
|
|
const stats = StatLog.getSystemStat(SysProps.SystemLoadStats) || { current : 0 };
|
|
|
|
return `${stats.current}%`;
|
|
|
|
},
|
|
|
|
UU : function systemUptime() {
|
|
|
|
return moment.duration(process.uptime(), 'seconds').humanize();
|
|
|
|
},
|
2018-06-23 03:26:46 +00:00
|
|
|
NV : function nodeVersion() { return process.version; },
|
2022-05-12 02:30:25 +00:00
|
|
|
AN : function activeNodes() { return clientConnections.getActiveConnections(clientConnections.UserVisibleConnections).length.toString(); },
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
TC: function totalCalls() {
|
|
|
|
return StatLog.getSystemStat(SysProps.LoginCount).toLocaleString();
|
|
|
|
},
|
|
|
|
TT: function totalCallsToday() {
|
2018-11-26 03:13:48 +00:00
|
|
|
return StatLog.getSystemStat(SysProps.LoginsToday).toLocaleString();
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
RR: function randomRumor() {
|
2018-06-23 03:26:46 +00:00
|
|
|
// start the process of picking another random one
|
2018-06-22 05:15:04 +00:00
|
|
|
setNextRandomRumor();
|
|
|
|
|
|
|
|
return StatLog.getSystemStat('random_rumor');
|
|
|
|
},
|
|
|
|
|
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// System File Base, Up/Download Info
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2020-11-22 19:25:19 +00:00
|
|
|
SD : function systemNumDownloads() { return StatLog.getFriendlySystemStat(SysProps.FileDlTotalCount, 0); },
|
2018-06-23 03:26:46 +00:00
|
|
|
SO : function systemByteDownload() {
|
2018-11-26 02:05:16 +00:00
|
|
|
const byteSize = StatLog.getSystemStatNum(SysProps.FileDlTotalBytes);
|
2022-06-05 20:04:25 +00:00
|
|
|
return formatByteSize(byteSize, true); // true=withAbbr
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2020-11-22 19:25:19 +00:00
|
|
|
SU : function systemNumUploads() { return StatLog.getFriendlySystemStat(SysProps.FileUlTotalCount, 0); },
|
2018-06-23 03:26:46 +00:00
|
|
|
SP : function systemByteUpload() {
|
2018-11-26 02:05:16 +00:00
|
|
|
const byteSize = StatLog.getSystemStatNum(SysProps.FileUlTotalBytes);
|
2022-06-05 20:04:25 +00:00
|
|
|
return formatByteSize(byteSize, true); // true=withAbbr
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
TF: function totalFilesOnSystem() {
|
2018-11-26 02:05:16 +00:00
|
|
|
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
2018-06-22 05:15:04 +00:00
|
|
|
return _.get(areaStats, 'totalFiles', 0).toLocaleString();
|
|
|
|
},
|
2022-06-05 20:04:25 +00:00
|
|
|
TB: function totalBytesOnSystem() {
|
|
|
|
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
|
|
|
const totalBytes = parseInt(_.get(areaStats, 'totalBytes', 0));
|
|
|
|
return formatByteSize(totalBytes, true); // true=withAbbr
|
2018-06-22 05:15:04 +00:00
|
|
|
},
|
2018-11-28 04:21:00 +00:00
|
|
|
PT : function messagesPostedToday() { // Obv/2
|
2020-11-22 19:25:19 +00:00
|
|
|
return StatLog.getFriendlySystemStat(SysProps.MessagesToday, 0);
|
2018-11-28 04:21:00 +00:00
|
|
|
},
|
|
|
|
TP : function totalMessagesOnSystem() { // Obv/2
|
2020-11-22 19:25:19 +00:00
|
|
|
return StatLog.getFriendlySystemStat(SysProps.MessageTotalCount, 0);
|
2018-11-28 04:21:00 +00:00
|
|
|
},
|
2020-11-26 22:53:21 +00:00
|
|
|
FT : function totalUploadsToday() { // Obv/2
|
|
|
|
return StatLog.getFriendlySystemStat(SysProps.FileUlTodayCount, 0);
|
|
|
|
},
|
|
|
|
FB : function totalUploadBytesToday() {
|
|
|
|
const byteSize = StatLog.getSystemStatNum(SysProps.FileUlTodayBytes);
|
|
|
|
return formatByteSize(byteSize, true); // true=withAbbr
|
|
|
|
},
|
|
|
|
DD : function totalDownloadsToday() { // iNiQUiTY
|
|
|
|
return StatLog.getFriendlySystemStat(SysProps.FileDlTodayCount, 0);
|
|
|
|
},
|
|
|
|
DB : function totalDownloadBytesToday() {
|
|
|
|
const byteSize = StatLog.getSystemStatNum(SysProps.FileDlTodayBytes);
|
|
|
|
return formatByteSize(byteSize, true); // true=withAbbr
|
2018-11-28 04:21:00 +00:00
|
|
|
},
|
2022-05-07 16:48:40 +00:00
|
|
|
NT : function totalNewUsersToday() { // Obv/2
|
|
|
|
return StatLog.getSystemStatNum(SysProps.NewUsersTodayCount);
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2018-06-23 03:26:46 +00:00
|
|
|
// :TODO: TZ - Average *system* post/call ratio (iNiQUiTY)
|
2020-11-10 04:32:34 +00:00
|
|
|
// :TODO: ?? - Total users on system
|
2018-06-22 05:15:04 +00:00
|
|
|
|
2022-05-02 01:58:00 +00:00
|
|
|
TU : function totalSystemUsers() {
|
|
|
|
return StatLog.getSystemStatNum(SysProps.TotalUserCount) || 1;
|
|
|
|
},
|
|
|
|
|
2020-11-27 02:51:00 +00:00
|
|
|
LC : function lastCallerUserName() { // Obv/2
|
|
|
|
const lastLogin = StatLog.getSystemStat(SysProps.LastLogin) || {};
|
|
|
|
return lastLogin.userName || 'N/A';
|
|
|
|
},
|
|
|
|
LD : function lastCallerDate(client) {
|
|
|
|
const lastLogin = StatLog.getSystemStat(SysProps.LastLogin) || {};
|
|
|
|
if (!lastLogin.timestamp) {
|
|
|
|
return 'N/A';
|
|
|
|
}
|
|
|
|
return lastLogin.timestamp.format(client.currentTheme.helpers.getDateFormat());
|
|
|
|
},
|
|
|
|
LT : function lastCallerTime(client) {
|
|
|
|
const lastLogin = StatLog.getSystemStat(SysProps.LastLogin) || {};
|
|
|
|
if (!lastLogin.timestamp) {
|
|
|
|
return 'N/A';
|
|
|
|
}
|
|
|
|
return lastLogin.timestamp.format(client.currentTheme.helpers.getTimeFormat());
|
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
|
|
|
|
//
|
2018-06-23 03:26:46 +00:00
|
|
|
// Special handling for XY
|
2018-06-22 05:15:04 +00:00
|
|
|
//
|
2022-06-05 20:04:25 +00:00
|
|
|
XY: function xyHack() {
|
|
|
|
return; /* nothing */
|
|
|
|
},
|
2018-09-15 02:34:39 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Various movement by N
|
|
|
|
//
|
2022-06-05 20:04:25 +00:00
|
|
|
CF: function cursorForwardBy(client, n = 1) {
|
|
|
|
return ANSI.forward(n);
|
|
|
|
},
|
|
|
|
CB: function cursorBackBy(client, n = 1) {
|
|
|
|
return ANSI.back(n);
|
|
|
|
},
|
|
|
|
CU: function cursorUpBy(client, n = 1) {
|
|
|
|
return ANSI.up(n);
|
|
|
|
},
|
|
|
|
CD: function cursorDownBy(client, n = 1) {
|
|
|
|
return ANSI.down(n);
|
|
|
|
},
|
2017-05-11 03:17:19 +00:00
|
|
|
};
|
|
|
|
|
2018-09-15 02:34:39 +00:00
|
|
|
function getPredefinedMCIValue(client, code, extra) {
|
2022-06-05 20:04:25 +00:00
|
|
|
if (!client || !code) {
|
2018-06-22 05:15:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-09-11 03:01:04 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
const generator = PREDEFINED_MCI_GENERATORS[code];
|
2017-05-11 03:17:19 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
if (generator) {
|
2018-06-22 05:15:04 +00:00
|
|
|
let value;
|
|
|
|
try {
|
2018-09-15 02:34:39 +00:00
|
|
|
value = generator(client, extra);
|
2018-06-22 05:15:04 +00:00
|
|
|
} catch(e) {
|
2022-06-10 22:08:22 +00:00
|
|
|
Log.error( { code : code, exception : e.message }, `Failed generating predefined MCI value (${code})` );
|
2018-06-22 05:15:04 +00:00
|
|
|
}
|
2017-05-11 03:17:19 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
return value;
|
|
|
|
}
|
2015-09-11 03:01:04 +00:00
|
|
|
}
|