====== Menus and the main menu ======
===== Custom menus (menus.toml and menus/*.rhai) =====
==== Menus as data (menus.toml) ====
Menus can be kept as data in ''%%menus.toml%%'' in the BBS folder and edited with the **Menu Editor** (Operator section, [[ironbarkbbs:sysop_tools|section 18]]) or the web admin's **Menus** page; the file is made the first time either saves. ''%%ironbark init%%'' puts a full example in ''%%menus.example.toml%%'': a main menu with Messages and Games sub-menus.
[[menu]]
code = "main"
title = "Main Menu"
# screen = "menu/mymain" # a screen instead of the drawn box
# prompt = "\u0001n\u0001h\u0001y@TLEFT@ > "
# hotkeys = true # false: type a key word, then Enter
# access = "!GUEST"
[[menu.item]]
key = "G"
description = "Games"
action = "menu:games"
[[menu.item]]
key = "*"
description = "Operator programs"
action = "doorsection:OPERATOR"
access = "SYSOP"
hidden = true # works, but isn't drawn
[[menu]]
code = "games"
title = "Games"
[[menu.item]]
key = "A"
description = "All door games"
action = "doorsection:GAMES"
[[menu.item]]
key = "Q"
description = "Back"
action = "back"
A menu has a ''%%code%%'', a ''%%title%%'', an optional ''%%screen%%'' (shown in place of the drawn menu), a ''%%prompt%%'' (Ctrl-A colour codes and @-codes; empty = a standard one with the title and time left), ''%%hotkeys%%'' (true: one key picks; false: the caller types the key, up to 8 letters, and Enter) and an ''%%access%%'' string. Without a screen the menu is drawn from its items: a box of "key │ description" in the BBS's colours, in two columns when there are many. Items have a ''%%key%%'', a ''%%description%%'', an ''%%action%%'', an ''%%access%%'' string (callers who don't meet it don't see the item and can't use it) and ''%%hidden%%''. Keys that aren't on the menu are ignored; ''%%?%%'' or Enter draws the menu again. Expert-mode callers get only the prompt.
Actions: ''%%menu:CODE%%'' (a sub-menu; a Rhai menu ''%%menus/CODE.rhai%%'' when there is no such menu in menus.toml), ''%%back%%'' (the menu before), ''%%doors%%'' (the door sections), ''%%doorsection:CODE%%'', ''%%door:CODE%%'', ''%%screen:NAME%%'' (show a screen, then Hit a key), ''%%logoff%%'' (asks first), ''%%script:NAME%%'' (a Rhai menu), and the commands Rhai menus' ''%%run()%%'' takes: ''%%newscan%%'', ''%%scan%%'', ''%%read%%'', ''%%list%%'', ''%%post%%'', ''%%email%%'', ''%%findtext%%'', ''%%scantoyou%%'', ''%%areas%%'', ''%%groups%%'', ''%%files%%'', ''%%qwk%%'', ''%%who%%'', ''%%chat%%'', ''%%groupchat%%'' (or ''%%groupchat:ROOM%%''), ''%%pagesysop%%'', ''%%nodemsg%%'', ''%%oneliners%%'', ''%%bulletins%%'', ''%%gazette%%'', ''%%lastcallers%%'', ''%%automsg%%'', ''%%polls%%'', ''%%userconfig%%'', ''%%userlist%%'', ''%%info%%'', ''%%textfiles%%'', ''%%sysop%%''. Menus nest to any depth; ''%%back%%'' in the first menu goes back to where the caller came from (on the main menu it just draws it again). Opening a menu that is already open goes back to it.
**The main menu**: set ''%%main_menu = "main"%%'' under ''%%[bbs]%%'' in ironbark.toml (or press M on a menu in the Menu Editor, or Make main menu on the web page) and that menu replaces the built-in one from the next logon. Leave it empty (the default) for the built-in Synchronet-style main menu. If the menu is missing or the caller can't use it (its ''%%access%%''), they get the built-in one. Give a replacement main menu a way to the sysop programs (like the hidden ''%%*%%'' item above), since the built-in ''%%!%%'' and ''%%X%%'' keys are not there.
Saving (in either editor) checks the menus first: every action must be one of the above, menus, doors, sections and scripts named must exist, keys must be unique in a menu (one character when the menu uses hot keys), codes are letters, digits, - and _, and access strings must work; the main menu must exist. Anything wrong is listed and nothing is written. Otherwise the old file is copied to ''%%data/config-backup/menus.toml.DATE-TIME%%''. ''%%ironbark check%%'' and Configuration make the same checks, so removing a door that a menu runs is refused until the menu is changed. Callers get changes the next time a menu is drawn.
==== Menus in Rhai (menus/*.rhai) ====
Menus can be written in Rhai, a small scripting language. ''%%menus/main.rhai%%'' replaces the built-in main menu. A menu runs other menus with ''%%run("menu:NAME")%%'', and a door can run one with ''%%kind = "builtin"%%'', ''%%builtin = "script:NAME"%%''.
loop {
cls();
show("menu/games"); // screens/menu/games.ans
print("\r\n\x01n\x01cYour choice: \x01h\x01w");
let k = getkey();
if k == "L" { run("door:LORD"); }
else if k == "N" { run("newscan"); }
else if k == "Q" { break; }
else if k == "O" { run("logoff"); break; }
}
Functions: ''%%show(name)%%'', ''%%print(text)%%'', ''%%println(text)%%'', ''%%cls()%%'', ''%%pause()%%'', ''%%getkey()%%'' (returns "A", "ENTER", "ESC", "UP" ...), ''%%getstr(max)%%'', ''%%password(max)%%'', ''%%yes_no(q, default)%%'', ''%%user("alias"|"level"|"location"|"calls"|"node"|"minutes_left")%%'', ''%%is_sysop()%%'', ''%%log(text)%%'', ''%%run(command)%%''.
Commands for ''%%run%%'': ''%%newscan%%'', ''%%scan%%'', ''%%read%%'', ''%%list%%'', ''%%post%%'', ''%%email%%'', ''%%findtext%%'', ''%%scantoyou%%'', ''%%areas%%'', ''%%groups%%'', ''%%files%%'', ''%%doors%%'', ''%%door:CODE%%'', ''%%qwk%%'', ''%%who%%'', ''%%chat%%'', ''%%nodemsg%%'', ''%%oneliners%%'', ''%%bulletins%%'', ''%%gazette%%'', ''%%lastcallers%%'', ''%%automsg%%'', ''%%polls%%'', ''%%userconfig%%'', ''%%userlist%%'', ''%%info%%'', ''%%textfiles%%'', ''%%sysop%%'', ''%%menu:NAME%%'' (a menu from menus.toml when there is one, else menus/NAME.rhai), ''%%logoff%%''.
===== The main menu =====
(A menu of your own from menus.toml can replace it: ''%%[bbs] main_menu%%'', [[ironbarkbbs:menus|section 12]].) The built-in main menu uses Synchronet's keys, so a Synchronet ''%%menu/main%%'' screen fits it: N new scan, J jump to new area, E e-mail, R read, L list, P post, A auto-message, S scan for mail to you, F find text, Q QWK, ''%%*%%'' list areas, ''%%/*%%'' list groups, ''%%{ }%%'' previous/next area, ''%%[ ]%%'' previous/next group, ''%%#%%'' pick an area, T files, G text files, C chat, X doors, D settings, U user list, I information, O or /O log off, /L who's online, V polls, /A your avatar, ! sysop menu, Ctrl-U who's online, Ctrl-P message another node.
**Chat** (C): J group chat (rooms; ''%%/W%%'' who's here, ''%%/ME%%'' an action, ''%%/J ROOM%%'' another room, ''%%/Q%%'' quit), P private chat with another caller, S page the sysop, A answer a request, M a one-line message to a node. Private chat is split-screen on ANSI terminals. Paging tells any sysop who is on a node, and shows on the web admin's Chat page, where the sysop can answer and chat from a browser (and set themselves available or not; callers with exemption C can page any time).
**Polls** (V): callers vote once (or pick several when the poll allows it) and see the results. Who can start a poll is ''%%[bbs] poll_access%%'' (default ''%%"!GUEST"%%''). Add ''%%"polls"%%'' to ''%%logon%%'' to offer unanswered polls at logon.
**Avatars** (/A): 10x6 character pictures chosen from the collections in ''%%text/avatars%%'' or ''%%screens/avatars%%'' (Synchronet's ''%%.bin%%'' collections work as they are). They show beside the message header on ANSI screens. Imported users keep their Synchronet avatars.
**Sysop menu** (!): U edit a user (level, minutes, flags, exemptions, restrictions, credits, expiry, birth date, note, password, delete), L log, W who, K hang up a node, B message to all nodes, N run the networks now, V approve held messages, O the Operator section ([[ironbarkbbs:sysop_tools|section 18]]), S spy on a node, C node control (lock, down, up), I quiet mode, P inactive users ([[ironbarkbbs:sysop_tools|section 19]]), F find text in every message area (mail too; read a hit, then D delete or M move it), M bulk mail (below). On ANSI terminals of 80 x 24 or more, U opens the full-screen User Editor.
**Bulk mail** (M, or the web admin's Messages page), like Synchronet's BULKMAIL: private mail from you to every user meeting an access string ([[ironbarkbbs:security|section 17]]), e.g. ''%%LEVEL 50%%'', ''%%FLAG B%%'', ''%%LEVEL 60 AND NOT FLAG X%%'', or to everyone when it is left empty. It says how many users match before you write; deleted users, guests and you are skipped. Each send is noted in the log.
----
//From the Ironbark Sysop Guide, which is also in every download as ''SYSOP-GUIDE.txt''.//