Skip to content
Snippets Groups Projects
Commit d496c9d6 authored by rswindell's avatar rswindell
Browse files

Updates to the (T)elegram option:

- cosmetic fixes (extra CRLFs removed)
- save/use the last 10 telegram recipients (using the getstr() history feature)
parent c71fd62a
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,10 @@ while(bbs.online && !(console.aborted)) { ...@@ -65,7 +65,10 @@ while(bbs.online && !(console.aborted)) {
case 'T': /* Telegram */ case 'T': /* Telegram */
{ {
writeln("Telegram"); writeln("Telegram");
writeln(); var SentHistoryLength = 10;
var userprops = load({}, "userprops.js");
var props_section = "telegram sent";
var to_list = userprops.get(props_section, "to", []);
var shown = 0; var shown = 0;
var nodelist_options = bbs.mods.nodelist_options; var nodelist_options = bbs.mods.nodelist_options;
if(!nodelist_options) if(!nodelist_options)
...@@ -83,8 +86,10 @@ while(bbs.online && !(console.aborted)) { ...@@ -83,8 +86,10 @@ while(bbs.online && !(console.aborted)) {
continue; continue;
if(node.useron == user.number) if(node.useron == user.number)
continue; continue;
if(!shown) if(!shown) {
writeln();
write(bbs.text(NodeLstHdr)); write(bbs.text(NodeLstHdr));
}
writeln(format(nodelist_options.format, n + 1 writeln(format(nodelist_options.format, n + 1
,presence.node_status(node, user.is_sysop, nodelist_options))); ,presence.node_status(node, user.is_sysop, nodelist_options)));
users[n] = node.useron; users[n] = node.useron;
...@@ -97,21 +102,28 @@ while(bbs.online && !(console.aborted)) { ...@@ -97,21 +102,28 @@ while(bbs.online && !(console.aborted)) {
continue; continue;
if(web_user.do_not_disturb) if(web_user.do_not_disturb)
continue; continue;
if(!shown) if(!shown) {
writeln();
write(bbs.text(NodeLstHdr)); write(bbs.text(NodeLstHdr));
}
writeln(format(nodelist_options.format, n + w + 1 writeln(format(nodelist_options.format, n + w + 1
,presence.web_user_status(web_user, nodelist_options.web_browsing, nodelist_options))); ,presence.web_user_status(web_user, nodelist_options.web_browsing, nodelist_options)));
shown++; shown++;
users[n + w] = web_user.usernum; users[n + w] = web_user.usernum;
} }
console.mnemonics(bbs.text(NodeToPrivateChat)); console.mnemonics(bbs.text(NodeToPrivateChat));
var str = console.getstr(LEN_ALIAS, K_LINE); var str = console.getstr(to_list[0], LEN_ALIAS, K_LINE|K_EDIT, to_list.slice(1));
if(!str) if(!str)
break; break;
var node_num = parseInt(str, 10); var node_num = parseInt(str, 10);
var user_num; var user_num;
if(node_num > 0 && users[node_num - 1] != undefined) if(node_num > 0) {
if(users[node_num - 1] == undefined) {
write(format(bbs.text(NodeNIsNotInUse), node_num));
break;
}
user_num = users[node_num - 1]; user_num = users[node_num - 1];
}
else if(str.charAt(0) == '#') else if(str.charAt(0) == '#')
user_num = parseInt(str.slice(1), 10); user_num = parseInt(str.slice(1), 10);
else if(str.charAt(0) == '\'') else if(str.charAt(0) == '\'')
...@@ -120,12 +132,13 @@ while(bbs.online && !(console.aborted)) { ...@@ -120,12 +132,13 @@ while(bbs.online && !(console.aborted)) {
user_num = system.matchuser(str, /* sysop-alias */true); user_num = system.matchuser(str, /* sysop-alias */true);
if(!user_num || system.username(user_num) == '') { if(!user_num || system.username(user_num) == '') {
user_num = bbs.finduser(str); user_num = bbs.finduser(str);
if(!user_num ) { if(!user_num) {
alert(bbs.text(UnknownUser)); write(bbs.text(UnknownUser));
break; break;
} }
} }
write(format(bbs.text(SendingTelegramToUser), system.username(user_num), user_num)); var user_name = system.username(user_num);
write(format(bbs.text(SendingTelegramToUser), user_name, user_num));
var msg = []; var msg = [];
while(msg.length < 5) { while(msg.length < 5) {
write("\1n: \1h"); write("\1n: \1h");
...@@ -137,9 +150,19 @@ while(bbs.online && !(console.aborted)) { ...@@ -137,9 +150,19 @@ while(bbs.online && !(console.aborted)) {
if(!msg.length || console.aborted) if(!msg.length || console.aborted)
break; break;
var telegram = format(bbs.text(TelegramFmt), user.alias, system.timestr()); var telegram = format(bbs.text(TelegramFmt), user.alias, system.timestr());
telegram += ' ' + msg.join('\r\n '); telegram += ' ' + msg.join('\r\n ') + '\r\n';
if(system.put_telegram(user_num, telegram)) if(system.put_telegram(user_num, telegram)) {
var to_idx = to_list.indexOf(user_name);
if(to_idx >= 0)
to_list.splice(to_idx, 1);
to_list.unshift(user_name);
if(to_list.length > SentHistoryLength)
to_list.length = SentHistoryLength;
userprops.set(props_section, "to", to_list);
userprops.set(props_section, "localtime", new Date().toString());
write(format(bbs.text(MsgSentToUser), "Telegram", system.username(user_num), user_num)); write(format(bbs.text(MsgSentToUser), "Telegram", system.username(user_num), user_num));
}
else else
alert("Failure sending telegram"); alert("Failure sending telegram");
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment