Commits (1)
  • Rob Swindell's avatar
    Move "MSGS" string command logic to its own file · f18132b3
    Rob Swindell authored
    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.
    f18132b3
......@@ -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);