Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 0c938466 authored by echicken's avatar echicken 🐔

Don't assign bbs methods to properties of another object.

Wrap calls to bbs methods in a function, use that as property.
Formatting changes so that if I ever work on this again in the
future it will look slightly less horrible.
Changes were made for ragnarok; if you're not him, you probably
shouldn't use this.
parent 904da5a7
// Mapping of menuedit/menushell 'commands' to built-in or helper functions
var inBBS = function() {
return (typeof js.global.bbs == "undefined") ? false : true;
}
var inBBS = js.global.bbs !== undefined;
load("sbbsdefs.js");
if(inBBS)
load("menu-command-helpers.js");
if (inBBS) load("menu-command-helpers.js");
var menuFile = system.data_dir + "menus.json";
// We can recategorize stuff later if needed
var Commands = {
'User' : {},
'System' : {},
'Messages' : {},
'Externals' : {}, // Placeholder, don't populate
'Files' : {},
'Menus' : {} // Placeholder, don't populate
User: {},
System: {},
Messages: {},
Externals: {}, // Placeholder, don't populate
Files: {},
Menus: {}, // Placeholder, don't populate
};
function _wrap(fn) {
return function() {
fn();
}
}
function getMenus() {
if (!file_exists(menuFile)) return;
var f = new File(menuFile);
f.open("r");
Commands.Menus = JSON.parse(f.read());
f.close();
}
/* Pattern:
Commands[area][command] = {
'Description' : "This is what this does."
Description: "This is what this does."
}
if(inBBS()) // Not being loaded from jsexec
if (inBBS) { // Not being loaded from jsexec
Commands[area][command].Action = some.method;
}
(If Action doesn't rely on the 'bbs' or 'console' objects, the inBBS()
check can be skipped.)
......@@ -39,312 +51,266 @@ var Commands = {
// User & user-activity related functions
Commands.User.Config = {
'Description' : "Enter the user settings configuration menu"
Description: "Enter the user settings configuration menu"
};
if(inBBS())
Commands.User.Config.Action = bbs.user_config;
if (inBBS) {
Commands.User.Config.Action = _wrap(bbs.user_config);
Commands.User.Find.Action = findUser;
Commands.User.Info.Action = _wrap(bbs.user_info);
Commands.User.List.Action = _wrap(bbs.list_users);
Commands.User.ListNodes.Action = _wrap(bbs.list_nodes);
Commands.User.ListNodesActive.Action = _wrap(bbs.whos_online);
Commands.User.Logons.Action = _wrap(bbs.list_logons);
Commands.User.SelectShell.Action = _wrap(bbs.select_shell);
Commands.User.SelectEditor.Action = _wrap(bbs.select_editor);
}
Commands.User.Find = {
'Description' : "Find user by username/number"
Description: "Find user by username/number"
};
if(inBBS())
Commands.User.Find.Action = findUser;
Commands.User.Info = {
'Description' : "Display current user information"
Description: "Display current user information"
};
if(inBBS())
Commands.User.Info.Action = bbs.user_info;
Commands.User.List = {
'Description' : "List users"
Description: "List users"
}
if(inBBS())
Commands.User.List.Action = bbs.list_users;
Commands.User.ListNodes = {
'Description' : "List all node activity"
Description: "List all node activity"
}
if(inBBS())
Commands.User.ListNodes.Action = bbs.list_nodes;
Commands.User.ListNodesActive = {
'Description' : "List all active nodes"
Description: "List all active nodes"
}
if(inBBS())
Commands.User.ListNodesActive.Action = bbs.whos_online;
Commands.User.Logons = {
'Description' : "Display the recent-logon list"
Description: "Display the recent-logon list"
}
if(inBBS())
Commands.User.Logons.Action = bbs.list_logons;
Commands.User.SelectShell = {
'Description' : "Select a command shell"
Description: "Select a command shell"
}
if(inBBS())
Commands.User.SelectShell.Action = bbs.select_shell;
Commands.User.SelectEditor = {
'Description' : "Select an external message editor"
Description: "Select an external message editor"
}
if(inBBS())
Commands.User.SelectEditor.Action = bbs.select_editor;
// System areas & functions that don't fit elsewhere
if (inBBS) {
Commands.System.Chat.Action = function() { bbs.exec("?chat_sec.js"); }
Commands.System.ExternalPrograms.Action = _wrap(bbs.xtrn_sec);
Commands.System.Info.Action = _wrap(bbs.sys_info);
Commands.System.LogOff.Action = _wrap(bbs.logoff);
Commands.System.LogOffFast.Action = _wrap(bbs.logout);
Commands.System.NodeChat.Action = _wrap(bbs.multinode_chat);
Commands.System.NodeChatPrivate.Action = _wrap(bbs.private_chat);
Commands.System.NodeMessage.Action = _wrap(bbs.private_message);
Commands.System.NodeStats.Action = _wrap(bbs.node_stats);
Commands.System.PageSysop.Action = _wrap(bbs.page_sysop);
Commands.System.PageGuru.Action = _wrap(bbs.page_guru);
Commands.System.Stats.Action = _wrap(bbs.sys_stats);
Commands.System.TextSection.Action = _wrap(bbs.text_sec);
Commands.System.TimeBank.Action = _wrap(bbs.time_bank);
Commands.System.Version.Action = _wrap(bbs.ver);
}
Commands.System.Chat = {
'Description' : "Enter the chat section"
Description: "Enter the chat section"
}
if(inBBS())
Commands.System.Chat.Action = function() { bbs.exec("?chat_sec.js"); }
Commands.System.ExternalPrograms = {
'Description' : "External Programs section"
Description: "External Programs section"
}
if(inBBS())
Commands.System.ExternalPrograms.Action = bbs.xtrn_sec;
Commands.System.Info = {
'Description' : "Display system information"
Description: "Display system information"
}
if(inBBS())
Commands.System.Info.Action = bbs.sys_info;
Commands.System.LogOff = {
'Description' : "Log off"
Description: "Log off"
}
if(inBBS())
Commands.System.LogOff.Action = bbs.logoff;
Commands.System.LogOffFast = {
'Description' : "Log off, fast"
Description: "Log off, fast"
}
if(inBBS())
Commands.System.LogOffFast.Action = bbs.logout;
Commands.System.NodeChat = {
'Description' : "Enter multi-node chat"
Description: "Enter multi-node chat"
}
if(inBBS())
Commands.System.NodeChat.Action = bbs.multinode_chat;
Commands.System.NodeChatPrivate = {
'Description' : "Enter private inter-node chat"
Description: "Enter private inter-node chat"
}
if(inBBS())
Commands.System.NodeChatPrivate.Action = bbs.private_chat;
Commands.System.NodeMessage = {
'Description' : "Inter-node private message prompt"
Description: "Inter-node private message prompt"
}
if(inBBS())
Commands.System.NodeMessage.Action = bbs.private_message;
Commands.System.NodeStats = {
'Description' : "Display node statistics"
Description: "Display node statistics"
}
if(inBBS())
Commands.System.NodeStats.Action = bbs.node_stats;
Commands.System.PageSysop = {
'Description' : "Page the sysop for chat"
Description: "Page the sysop for chat"
}
if(inBBS())
Commands.System.PageSysop.Action = bbs.page_sysop;
Commands.System.PageGuru = {
'Description' : "Page the annoying guru for chat"
Description: "Page the annoying guru for chat"
}
if(inBBS())
Commands.System.PageGuru.Action = bbs.page_guru;
Commands.System.Stats = {
'Description' : "Display system statistics"
Description: "Display system statistics"
}
if(inBBS())
Commands.System.Stats.Action = bbs.sys_stats;
Commands.System.TextSection = {
'Description' : "Text files section"
Description: "Text files section"
}
if(inBBS())
Commands.System.TextSection.Action = bbs.text_sec;
Commands.System.TimeBank = {
'Description' : "Time Bank"
Description: "Time Bank"
}
if(inBBS())
Commands.System.TimeBank.Action = bbs.time_bank;
Commands.System.Version = {
'Description' : "Display software version information"
Description: "Display software version information"
}
if(inBBS())
Commands.System.Version.Action = bbs.ver;
// Message area related functions
if (inBBS) {
Commands.Messages.BulkMail.Action = _wrap(bbs.bulk_mail);
Commands.Messages.Find.Action = findMessages;
Commands.Messages.Post.Action = _wrap(bbs.post_msg);
Commands.Messages.MailRead.Action = _wrap(bbs.read_mail);
Commands.Messages.QWKSection.Action = _wrap(bbs.qwk_sec);
Commands.Messages.Read.Action = _wrap(bbs.scan_msgs);
Commands.Messages.Scan.Action = scanSubs;
Commands.Messages.ScanConfig.Action = _wrap(bbs.cfg_msg_scan);
Commands.Messages.ScanPointers.Action = _wrap(bbs.cfg_msg_ptrs);
Commands.Messages.ScanPointersReinit.Action = _wrap(bbs.reinit_msg_ptrs);
Commands.Messages.SelectGroup.Action = selectMessageGroup;
Commands.Messages.SelectArea.Action = selectMessageArea;
Commands.Messages.SelectGroupAndArea.Action = selectGroupAndArea;
Commands.Messages.SendMail.Action = sendMail;
Commands.Messages.SendNetMail.Action = sendNetMail;
Commands.Messages.SubInfo.Action = _wrap(bbs.sub_info);
}
Commands.Messages.BulkMail = {
'Description' : "Send bulk private mail"
Description: "Send bulk private mail"
}
if(inBBS())
Commands.Messages.BulkMail.Action = bbs.bulk_mail;
Commands.Messages.Find = {
'Description' : "Search message groups/areas/subs"
Description: "Search message groups/areas/subs"
}
if(inBBS())
Commands.Messages.Find.Action = findMessages;
Commands.Messages.Post = {
'Description' : "Post a message in the current area"
Description: "Post a message in the current area"
}
if(inBBS())
Commands.Messages.Post.Action = bbs.post_msg;
Commands.Messages.MailRead = {
'Description' : "Read private mail / email"
Description: "Read private mail / email"
}
if(inBBS())
Commands.Messages.MailRead.Action = bbs.read_mail;
Commands.Messages.QWKSection = {
'Description' : "Enter the QWK transfer/configuration section"
Description: "Enter the QWK transfer/configuration section"
}
if(inBBS())
Commands.Messages.QWKSection.Action = bbs.qwk_sec;
Commands.Messages.Read = {
'Description' : "Read messages in the current area"
Description: "Read messages in the current area"
}
if(inBBS())
Commands.Messages.Read.Action = bbs.scan_msgs;
Commands.Messages.Scan = {
'Description' : "Scan for new messages"
Description: "Scan for new messages"
}
if(inBBS())
Commands.Messages.Scan.Action = scanSubs;
Commands.Messages.ScanConfig = {
'Description' : "New message scan configuration"
Description: "New message scan configuration"
}
if(inBBS())
Commands.Messages.ScanConfig.Action = bbs.cfg_msg_scan;
Commands.Messages.ScanPointers = {
'Description' : "Configure message scan pointer values"
Description: "Configure message scan pointer values"
}
if(inBBS())
Commands.Messages.ScanPointers.Action = bbs.cfg_msg_ptrs;
Commands.Messages.ScanPointersReinit = {
'Description' : "Re-initialize new message scan pointer values"
Description: "Re-initialize new message scan pointer values"
}
if(inBBS())
Commands.Messages.ScanPointersReinit.Action = bbs.reinit_msg_ptrs;
Commands.Messages.SelectGroup = {
'Description' : "Select a message group"
Description: "Select a message group"
}
if(inBBS())
Commands.Messages.SelectGroup.Action = selectMessageGroup;
Commands.Messages.SelectArea = {
'Description' : "Select a message area"
Description: "Select a message area"
}
if(inBBS())
Commands.Messages.SelectArea.Action = selectMessageArea;
Commands.Messages.SelectGroupAndArea = {
'Description' : "Select a message group and area"
Description: "Select a message group and area"
}
if(inBBS())
Commands.Messages.SelectGroupAndArea.Action = selectGroupAndArea;
Commands.Messages.SendMail = {
'Description' : "Send local private mail"
Description: "Send local private mail"
}
if(inBBS())
Commands.Messages.SendMail.Action = sendMail;
Commands.Messages.SendNetMail = {
'Description' : "Send netmail/email"
Description: "Send netmail/email"
}
if(inBBS())
Commands.Messages.SendNetMail.Action = sendNetMail;
Commands.Messages.SubInfo = {
'Description' : "Display message sub-board information"
Description: "Display message sub-board information"
}
if(inBBS())
Commands.Messages.SubInfo.Action = bbs.sub_info;
// File area related functions
if (inBBS) {
Commands.Files.BatchMenu.Action = _wrap(bbs.batch_menu);
Commands.Files.BatchDownload.Action = _wrap(bbs.batch_download);
Commands.Files.DirInfo.Action = _wrap(bbs.dir_info);
Commands.Files.List.Action = _wrap(bbs.list_files);
Commands.Files.ListExtended.Action = _wrap(bbs.list_file_info);
Commands.Files.Scan.Action = _wrap(bbs.scan_dirs);
Commands.Files.TempXfer.Action = _wrap(bbs.temp_xfer);
Commands.Files.Upload.Action = _wrap(bbs.upload_file);
Commands.Files.XferPolicy.Action = _wrap(bbs.xfer_policy);
}
Commands.Files.BatchMenu = {
'Description' : "Enter the batch file transfer menu"
Description: "Enter the batch file transfer menu"
}
if(inBBS())
Commands.Files.BatchMenu.Action = bbs.batch_menu;
Commands.Files.BatchDownload = {
'Description' : "Start a batch download"
Description: "Start a batch download"
}
if(inBBS())
Commands.Files.BatchDownload.Action = bbs.batch_download;
Commands.Files.DirInfo = {
'Description' : "Display file directory information"
Description: "Display file directory information"
}
if(inBBS())
Commands.Files.DirInfo.Action = bbs.dir_info;
Commands.Files.List = {
'Description' : "List all files in the current directory"
Description: "List all files in the current directory"
}
if(inBBS())
Commands.Files.List.Action = bbs.list_files;
Commands.Files.ListExtended = {
'Description' : "List all files in current directory (extended info)"
Description: "List all files in current directory (extended info)"
}
if(inBBS())
Commands.Files.ListExtended.Action = bbs.list_file_info;
Commands.Files.Scan = {
'Description' : "Scan directories for files"
Description: "Scan directories for files"
}
if(inBBS())
Commands.Files.Scan.Action = bbs.scan_dirs;
Commands.Files.TempXfer = {
'Description' : "Enter the temporary file transfer menu"
Description: "Enter the temporary file transfer menu"
}
if(inBBS())
Commands.Files.TempXfer.Action = bbs.temp_xfer;
Commands.Files.Upload = {
'Description' : "Upload a file to the current directory"
Description: "Upload a file to the current directory"
}
if(inBBS())
Commands.Files.Upload.Action = bbs.upload_file;
Commands.Files.XferPolicy = {
'Description' : "Display the file transfer policy"
}
if(inBBS())
Commands.Files.XferPolicy.Action = bbs.xfer_policy;
var getMenus = function() {
if(!file_exists(menuFile))
return;
var f = new File(menuFile);
f.open("r");
Commands.Menus = JSON.parse(f.read());
f.close();
Description: "Display the file transfer policy"
}
getMenus();
\ No newline at end of file
  • it's broken now

    Node 1 !JavaScript /sbbs/exec/load/menu-commands.js line 59: TypeError: Commands.User.Find is undefined

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment