str_cmds.js 20.79 KiB
// str_cmds.js
// Global String Command Module for Synchronet
// $Id$
// @format.tab-size 4, @format.use-tabs true
// This is NOT a command shell, DO NOT add to SCFG->Command Shells
// This module is loaded from command shells with the load() function
// It contains mostly sysop commands (i.e. ;ERR)
// The command string must be the first argument string
// when this module is loaded.
load("sbbsdefs.js");
load("nodedefs.js");
load("text.js");
if(argc>0)
str_cmds(argv.join(" ")); // use command-line arguments if supplied
else if(bbs.command_str && bbs.command_str != '')
str_cmds(bbs.command_str); // otherwise, use command shell 'str' var, if supported (v3.13b)
// For testing...
//str_cmds(console.getstr("",60));
function str_cmds(str)
{
var file; // File
var word; // First word of args
var i; // Temp integer
var j; // Temp integer
var k; // Temp integer
var l; // Temp integer
var m; // Temp integer
var a; // Temp array
var s; // Temp string
// Remove any trailing spaces
str=truncsp(str);
// Upper-Case first word
str=str.replace(/^\s*([^\s]*)/,
function(st, p, oset, s) {
word=p.toUpperCase();
return(word);
}
);
log(str);
if(str=="HELP")
write("\r\nAvailable STR commands (prefix with a semi-colon)\r\n\r\n");
if(user.compare_ars("SYSOP")) {
// Change node action to "sysop activities"
bbs.node_action=NODE_SYSP;
//sync
// ######################## SYSOP Functions ##############################
if(str=="HELP") {
writeln("ERR\tDisplay currrent error log and opptionally delete it as well as");
writeln("\toptionally clearing all nodes error counters.");
}
if(str=="ERR") {
if(file_exists(system.logs_dir+"error.log")) {
write(bbs.text(ErrorLogHdr));
console.printfile(system.logs_dir+"error.log");