Skip to content
Snippets Groups Projects
Commit f18132b3 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Move "MSGS" string command logic to its own file

This makes the view instant message logic more easily accessible from other
places (e.g. menus or whatever).

Add (V)iew command the private message (^P) prompt while we're at it.
Users don't normally discover ;string commands on their own.
parent 84669d56
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -24,12 +24,12 @@ while(bbs.online && !(console.aborted)) {
}
bbs.nodesync();
console.print("\1n\r\n\xfe \1b\1h\Private \1n\xfe ");
console.mnemonics("~Telegram, ~Message, ~Chat, ~InterBBS, or ~Quit: ");
console.mnemonics("~Telegram, ~Message, ~Chat, ~InterBBS, ~View, or ~Quit: ");
bbs.sys_status&=~SS_ABORT;
var ch;
while(bbs.online && !console.aborted) { /* Watch for incoming messages */
ch=console.inkey(/* mode: */K_UPPER, /* timeout: */1000);
if(ch && "TMCIQ\r".indexOf(ch)>=0)
if(ch && "TMCIQV\r".indexOf(ch)>=0)
break;
console.line_counter = 0;
......@@ -167,6 +167,9 @@ while(bbs.online && !(console.aborted)) {
writeln();
load({}, 'sbbsimsg.js');
break;
case 'V':
load({}, 'viewimsgs.js');
break;
default:
console.print("Quit\r\n");
exit();
......
......@@ -846,43 +846,7 @@ function str_cmds(str)
writeln("MSGS\tRedisplay instant messages (notifications and telegrams).");
}
if(word == "MSGS") {
var num = -1;
loop:
while (bbs.online && !console.aborted) {
var msg = system.data_dir + "msgs/" + format("%04u", user.number) + ".last.msg";
if(num >= 0)
msg = system.data_dir + "msgs/" + format("%04u", user.number) + ".last." + num + ".msg";
console.clear();
if(!file_exists(msg))
break;
var timestamp = system.timestr(file_date(msg));
print("\1n\1cInstant messages displayed \1h" + timestamp);
console.printfile(msg, P_NOATCODES);
console.mnemonics("\r\n~Quit, ~Recent, ~Prev, or [~Next]: ");
prmpt:
switch(console.getkeys("\b-+[]\x02\x1e\x0a\x1d\x06RPN\rQ")) {
case 'R':
case KEY_HOME:
num = -1;
break;
case 'P':
case '\b':
case '-':
case '[':
case KEY_UP:
case KEY_LEFT:
if(num >=0)
num--;
else
console.beep();
break;
case 'Q':
break loop;
default:
num++;
break;
}
}
load({}, 'viewimsgs.js');
}
}
......
// Redisplay instant messages (telegrams and notifications)
require("sbbsdefs.js", 'P_NOATCODES');
require("key_defs.js", 'KEY_HOME');
var num = -1;
var displayed = 0;
loop:
while (bbs.online && !console.aborted) {
var msg = system.data_dir + "msgs/" + format("%04u", user.number) + ".last.msg";
if(num >= 0)
msg = system.data_dir + "msgs/" + format("%04u", user.number) + ".last." + num + ".msg";
console.clear();
if(!file_exists(msg))
break;
var timestamp = system.timestr(file_date(msg));
print("\1n\1cInstant messages displayed \1h" + timestamp);
console.printfile(msg, P_NOATCODES);
++displayed;
console.mnemonics("\r\n~Quit, ~Recent, ~Prev, or [~Next]: ");
prmpt:
switch(console.getkeys("\b-+[]\x02\x1e\x0a\x1d\x06RPN\rQ")) {
case 'R':
case KEY_HOME:
num = -1;
break;
case 'P':
case '\b':
case '-':
case '[':
case KEY_UP:
case KEY_LEFT:
if(num >=0)
num--;
else
console.beep();
break;
case 'Q':
break loop;
default:
num++;
break;
}
}
if(!displayed)
writeln("Sorry, no messages.");
exit(displayed);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment