Advertisement
riking

faithinhumanity.gs

Oct 6th, 2012
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function resetFIH() {
  2.   ScriptProperties.setProperty("fih", tostring(0))
  3. }
  4. function getFIH() {
  5.   Logger.log(ScriptProperties.getProperty("fih"));
  6. }
  7.  
  8. function disable() { ScriptProperties.setProperty("disabled", "yes"); }
  9. function enable() { ScriptProperties.setProperty("disabled", "no"); }
  10.  
  11.  
  12. /*
  13. function debugstuff() {
  14.   var str = ScriptProperties.getProperty("last_post");
  15.   Logger.log(str);
  16.   var obj = JSON.parse(str);
  17.   Logger.log(obj);
  18.   var result;
  19.   for (var key in obj) {
  20.     if (obj.hasOwnProperty(key)) {
  21.       result = key;
  22.       break;
  23.     }
  24.   }
  25.   Logger.log(result);
  26.   var change = 0;
  27.   Logger.log(result==="  ");
  28.   Logger.log(result=="  ");
  29.   Logger.log(result==" ");
  30.   if (result === "  ") { //stripped plusses
  31.     change = 1;
  32.   }
  33.   else if (result === "--") {
  34.     change = -1;
  35.   }
  36.   else if (parseInt(result)) {
  37.     change = parseInt(result);
  38.   }
  39.   Logger.log(change);
  40.   if (change != 0)
  41.   {
  42.     Logger.log("!=0");
  43.   }
  44. }*/
  45.  
  46. function doGet() {
  47.   return ContentService.createTextOutput(ScriptProperties.getProperty("fih"));
  48. }
  49.  
  50. function doPost(data) {
  51.   if (ScriptProperties.getProperty("disabled") === "yes")
  52.     return ContentService.createTextOutput("this command has been temporarily disabled");
  53.   var param = data.parameter;
  54.   var str;
  55.   for (var key in param) {
  56.     if (param.hasOwnProperty(key)) {
  57.       str = key;
  58.       break;
  59.     }
  60.   }
  61.   ScriptProperties.setProperty("last_post",str);
  62.   var change = 0;
  63.   if (str === "**") { //stripped plusses
  64.     change = 1;
  65.   }
  66.   else if (str === "--") {
  67.     change = -1;
  68.   }
  69.   else if (parseInt(str)) {
  70.     change = parseInt(str);
  71.   }
  72.  
  73.   if (change != 0)
  74.   {
  75.     var current = parseInt(ScriptProperties.getProperty("fih"));
  76.     current += change;
  77.     ScriptProperties.setProperty("fih", current.toString());
  78.   }
  79.   return doGet();
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement