Untitled

From Unique Hog, 11 Years ago, written in C, viewed 770 times.
URL https://paste.godclan.hu/view/db88Jb8j Embed
Download Paste or View Raw
  1. function runStringIRC(commandstring) {
  2.         local errMsg = null;
  3.         try {
  4.                 local script = compilestring.pcall(this, "return " + commandstring);
  5.                 local result = script.pcall(this);
  6.                 if (result == null) return "Command executed!";
  7.                 //if (typeof result == "string") result = "\"" + result + "\"";
  8.                 return "Command result: " + result + " [" + (typeof result) + "]";
  9.         }
  10.         catch(e) {
  11.                 errMsg = e;
  12.         }
  13.         try {
  14.                 local script = compilestring.pcall(this, commandstring);
  15.                 local result = script.pcall(this);
  16.                 if (result == null) return "Command executed!";
  17.                 //if (typeof result == "string") result = "\"" + result + "\"";
  18.                 return "Command result: " + result + " [" + (typeof result) + "]";
  19.         }
  20.         catch(e) {
  21.                 if (errMsg != null) return "Error: " + errMsg;
  22.                 return "Error: " + e;
  23.         }
  24.     /*if (results[0]) return "Error: " + results[2];
  25.     local resultsString = null, first = true;
  26.         for(local i=1;i<results.len();i+=1) {
  27.         if (first) {
  28.             first = false;
  29.             resultsString = "";
  30.                 }
  31.                 else resultsString += ", ";
  32.         local result = results[i]
  33.         //local resultType = type(result)
  34.         /*if resultType == "string" then resultsString = resultsString..(("%q"):format(result):gsub("[\a\b\f\t\v\n]", {["\a"]="\\a", ["\b"]="\\b", ["\f"]="\\f", ["\t"]="\\t", ["\v"]="\\v"}):gsub("\\\n", "\\n"))
  35.                 else *//*resultsString += tostring(result) end
  36.     }
  37.     if (!resultsString) return "Command executed!";
  38.     return "Command results: " + resultsString;*/
  39. }

Reply to "Untitled"

Here you can reply to the paste above