Skip to content
Snippets Groups Projects
Commit 81344d0e authored by echicken's avatar echicken
Browse files

Add user's latest oneliner to the frame after posting; filter out some poop.

parent 8942c635
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,7 @@ var initFrames = function() {
LIGHTGRAY,
frame
);
onelinersFrame.v_scroll = true;
inputAliasFrame = new Frame(
onelinersFrame.x,
......@@ -141,6 +142,9 @@ var init = function() {
}
var putOneliner = function(oneliner) {
oneliner.oneliner = strip_exascii(oneliner.oneliner);
if(oneliner.oneliner.length < 1)
return;
onelinersFrame.putmsg(
format(
"\1n\1w%s\1n\1c@\1h\1b%s\1h\1k: \1n\1w%s\r\n",
......@@ -206,7 +210,9 @@ var main = function() {
userInput = userInput.replace(/\\1/g, ascii(1));
if(console.strlen(userInput) < 1)
continue;
postOneliner(user.alias, userInput);
var o = postOneliner(user.alias, userInput);
if(o)
putOneliner(o);
}
continue;
}
......
......@@ -10,7 +10,7 @@ var initSettings = function(path) {
var postOneliner = function(alias, userInput) {
try {
oneliners.post(alias, userInput);
return oneliners.post(alias, userInput);
} catch(err) {
log(LOG_ERR, "JSON client error: " + err);
exit();
......@@ -40,13 +40,17 @@ var Oneliners = function(server, port, callback) {
);
while(lines.length > 0) {
var line = lines.shift();
if(typeof line == "undefined") // Probably a deleted oneliner
continue;
if( typeof line.time != "number" ||
typeof line.client != "string" ||
typeof line.alias != "string" ||
typeof line.systemName != "string" ||
typeof line.systemHost != "string" ||
typeof line.qwkid != "string" || line.qwkid.length > 8 ||
typeof line.oneliner != "string"
typeof line.oneliner != "string" ||
typeof strip_ctrl(line.oneliner) == "undefined" ||
strip_ctrl(line.oneliner).length < 1
) {
continue;
}
......@@ -56,6 +60,9 @@ var Oneliners = function(server, port, callback) {
}
this.post = function(alias, oneliner) {
var o = strip_ctrl(oneliner.oneliner);
if(typeof o == "undefined")
return false;
var obj = {
'time' : time(),
'client' : (typeof client != "undefined") ? client.ip_address : system.inet_addr,
......@@ -71,6 +78,7 @@ var Oneliners = function(server, port, callback) {
obj,
2
);
return obj;
}
this.cycle = function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment