Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
3,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var computerchoice = Math.random();
  2. var banned = ["MrBean", "brotchen", 'snake2', "Kainui", 'snake', "Chaos"];
  3. var HackChat = require('./hackchat.js');
  4. var chat = new HackChat();
  5. var nicks = [];
  6. var afks = [];
  7. var activenicks = [];
  8. var greetings = ["hey", "hello", "sup", "greet", "how"];
  9. var admins = ["Bloodsipper", "sean_don", 'ijs', "Serials"];
  10. var goodwords = ["good", "like", "love", "awesome", "wonderful", "useful", "good", 'great', 'best', 'smart'];
  11. var badwords = ['turkey', 'fuck', 'worthless', 'shit', 'weed', 'ass', 'trap', 'crap', 'wtf', 'asshat', 'dick', 'idiot', 'stupid', 'problem', 'gay', 'cadomite', "broken", "bad", "asshole", "sucks", 'dead', 'useless', 'shitty', 'crappy', 'fucking', 'mofo', 'motherfucker', 'motherfucking', 'idiot', 'idiotic', 'douche', 'douchebag'];
  12. var channelName = 'programming'; //usually programming, lounge, games, botDev or private.
  13. var botName = 'Stammy'; //former hackbot, stambot
  14. var channel = chat.join(channelName, botName);
  15. var funfacts = ["While Idi Amin was the leader of Uganda, hundreds of thousands of people died or had their lives destroyed just because their leader was paranoid. Idi Amin, after the tanzanian invasion, escaped towards Libya and died in Saudi Arabia by heart attack in 2003. No one ever punished him.",
  16.            "The effects of crippling depression can include a persistent but overwhelming pain in the chest and the urge to kill oneself.",
  17.            "In 1986, a single man was stranded on an island when the container ship he was captaining sunk. While alone, he became so depressed that he tied rocks to his feet and jumped into the ocean to drown himself. "
  18.            , "In concentration camps, Jews were tortured by cutting off their scrotum and jamming it down their throat. This effectively cut off their air supply until they died of suffocation.",
  19.            "Some child workers in Asia work so hard that their fingers are ground down to bloody stumps.",
  20.            "One of the best ways to commit suicide is by train. The train conductor has no control over whether or no you die, but the blame is ultimately placed on him and he has to live the rest of his life in guilt knowing that he killed a man.",
  21.            "During the potato famine in Ireland, people were so hungry that they were forced to eat their own children alive. The children would kick and scream, but in the end their flesh helped their parents live on.",
  22.            "Right now, there are children in Ethiopia who will never eat in the entirety of their short lives. They live with an undying pain in their abdomen from the horrible hunger.",
  23.            "While in the gas cambers, Jews experienced a crippling pain in their chest. This pain could go on for hours. Because of this, many innocent Jews committed suicide before they could be killed by their Nazi rulers.",
  24.            "In the last 5 years, ISIS has killed thousands of innocent, unsuspecting civilians. These poor people are taken from their homes and family and tortured for days on end until their death.",
  25.            "Recently, two 10-year-olds took a baby from its parents with no reason. Thy tortured it badly: They took its penis off, they sticked batteries in its ass and nose and other creepy stuff. In the end, they threw it to the trail rails and it was killed. The one 10-year-old committed suicide and the other one will soon get out of jail.",
  26.            "Recently, in Greece, some Albanian moron choked his 4-year-old daughter, cut her into pieces and cooked them. Then he threw them randomly in different place in Athens. At least he got caught."]; //funfact command.
  27. function out(text) { //too bored to write channel.sendMessage().
  28.   channel.sendMessage(text)
  29. } var counter = 0;
  30. chat.on("chat", function(session, nick, text) {
  31.   nickie = nick.toLowerCase();
  32.   if (nick != botName && banned.indexOf(nick) == -1 && nickie.indexOf("bot") == -1) {
  33.     nicks.push(nick);
  34.     if(activenicks.indexOf(nick) == -1) {
  35.       activenicks.push(nick);
  36.     }
  37.     counter += 1;
  38.     var texti = text.toLowerCase();
  39.     if(texti.indexOf("@") != -1){
  40.       for(var afkchecking = 0; afkchecking <= text.length; afkchecking++){
  41.         if(text.indexOf(afks[afkchecking]) != -1 && text.indexOf(afks[afkchecking]) == text.indexOf("@") + 1) {
  42.           out("@" + afks[afkcheking] + " is AFK!");
  43.           break;
  44.         }
  45.       }
  46.     }
  47.     if(afks.indexOf(nick) != -1) {
  48.       out("wb @" + nick);
  49.       for(var afkcheck = 0; afkcheck <= afks.length; afkcheck++){
  50.         if(afks[afkcheck] == nick) {
  51.           afks.splice(afkcheck, 1);
  52.           break;
  53.         }
  54.       }
  55.     } if(texti.indexOf('stammy') != -1) {
  56.       for(var stammy = 0; stammy <= texti.length; stammy++) {
  57.         if(texti.indexOf(badwords[stammy]) != -1) {
  58.           if(texti.indexOf('not') != -1) {
  59.             out("Thanks! :D");
  60.             break;
  61.           } else {
  62.             banned.push(nick);
  63.             out(nick + " was successfully banned.");
  64.             break;
  65.           }
  66.         } else if(texti.indexOf(goodwords[stammy]) != -1) {
  67.           if(texti.indexOf('not') != -1){
  68.             banned.push(nick);
  69.             out(nick + " was successfully banned.");
  70.             break;
  71.           } else {
  72.             out("Thanks! :D");
  73.             break;
  74.           }
  75.         } else if(texti.indexOf(greetings[stammy]) != -1) {
  76.           out("Hi! :D");
  77.         }
  78.       }
  79.     }
  80.     if(texti.indexOf('afk') != -1 && nick != "Stammy") {
  81.       afks.push(nick);
  82.       out("User @" + nick + " is now AFK!");
  83.     }
  84.     if (text[0] == " ") {
  85.       var cmd = texti.substr(1).split(" ")[0];
  86.       switch(cmd) {
  87.         case 'modrmv':
  88.           remv = [];
  89.           if(nick == "ijs") {
  90.             for(var rmv = 8; rmv <= text.length; rmv++){
  91.               remv.push(text[rmv]);
  92.             } remv = remv.join("");
  93.             remv = remv.trim();
  94.             for(var remove = 0; remove <= admins.length; remove++) {
  95.               if(admins[remove] === remv) {
  96.                 admins.splice(remove, 1);
  97.                 out("@ijs user @" + remv + " is successfully removed from your mods.");
  98.                 break;
  99.               }
  100.             }
  101.           }
  102.           break;
  103.         case 'modadd':
  104.           add = [];
  105.           if(admins.indexOf(nick) != -1){
  106.             for(var addie = 8; addie <= text.length; addie++){
  107.               add.push(text[addie]);
  108.             } add = add.join("");
  109.             add = add.trim();
  110.             admins.push(add);
  111.             out("@" + nick + " user @" + add + " was successfully added as a mod.");
  112.           }
  113.           break;
  114.         case 'webdev':
  115.           out("http://exactitudesolutions.com It's great, they've helped me multiple times");
  116.           break;
  117.         case 'tiny':
  118.           var tiny = ["$", "\\", "t", "i", "n", "y", " "];
  119.           for(var tin = 6; tin <= text.length; tin++) {
  120.             text[tin] == " " ? tiny.push(" \\ ") : tiny.push(text[tin]);
  121.           } tiny.push(' $');
  122.           tiny = tiny.join("");
  123.           out(tiny);
  124.           break;
  125.         case 'speak':
  126.           spehits = [];
  127.           times = 0;
  128.           for(var spe = 7; spe <= text.length; spe++){
  129.             spehits.push(text[spe]);
  130.           } spehits = spehits.join("");
  131.           spehits = spehits.trim();
  132.           if(spehits.length === 0){
  133.             for(var specheck = 0; specheck <= nicks.length; specheck++){
  134.               if(nicks[specheck] === nick) {
  135.                 times += 1;
  136.               }
  137.             } out("Since I joined the last time, " + nick + ' has spoken ' + times + " times.");
  138.           } else {
  139.             for(var sp = 0; sp <= nicks.length; sp++){
  140.               if(nicks[sp] === spehits) {
  141.                 times += 1;
  142.               }
  143.             } out("Since I joined the last time, " + spehits + " has spoken " + times + " times.");
  144.           }
  145.           break;
  146.         case 'ban':
  147.           nbanned = [];
  148.           for(var ban = 5; ban <= text.length; ban++){
  149.             nbanned.push(text[ban]);
  150.           } nbanned = nbanned.join("");
  151.           nbanned = nbanned.trim();
  152.           if(admins.indexOf(nbanned) != -1 && nick != "ijs") {
  153.             nbanned = nick;
  154.           }
  155.           if(admins.indexOf(nick) != -1 && nbanned.length != 0){
  156.             banned.push(nbanned);
  157.             out("@" + nick + " user @" + nbanned + " was successfully banned.");
  158.           } else if(admins.indexOf(nick) == -1){
  159.             out("@" + nick + " you don't have the right to use this command");
  160.           } else if(admins.indexOf(nick) != -1 && nbanned.length == 0) {
  161.             out("Pick someone to ban you noob!");
  162.           }
  163.           break;
  164.         case 'unban':
  165.           ubanned = [];
  166.           for(var unban = 7; unban <= text.length; unban++){
  167.             ubanned.push(text[unban]);
  168.           } ubanned = ubanned.join("");
  169.           ubanned = ubanned.trim();
  170.           if(admins.indexOf(nick) != -1 && ubanned.length != 0){
  171.             for(var uny = 0; uny <= banned.length; uny++){
  172.               if(banned[uny] == ubanned) {
  173.                 banned.splice(uny, 1);
  174.                 out("@" + nick + ' user @' + ubanned + " was successfully unbanned.");
  175.                 break;
  176.               }
  177.             }
  178.           } else if(admins.indexOf(nick) == -1){
  179.             out("@" + nick + ' you don\'t have permission to use this command');
  180.           } else if(admins.indexOf(nick) != -1 && ubanned.length == 0) {
  181.             out("Pick someone to unban you noob!");
  182.           }
  183.           break;
  184.         case 'formathelp':
  185.           out("What do you need help with? Download the ISO of your OS, burn it in a DVD with CDBurnerXP or through Windows itself (or any other programm available on Linux) or simply make a USB using UNetbootin or Rufus. Then change the boot order from within a boot menu or your BIOS and delete the old Windows or Linux partition and reistall the OS. Easy peasy.");
  186.           break;
  187.         case 'upper':
  188.           var upper = [];
  189.           for(var up = 7; up <= text.length; up += 1) {
  190.             upper.push(text[up]);
  191.           } upper = upper.join("");
  192.           upper = upper.toUpperCase();
  193.           out(upper);
  194.           break;
  195.         case 'lower':
  196.           var lower = [];
  197.           for(var low = 7; low <= text.length; low++) {
  198.             lower.push(text[low]);
  199.           } lower = lower.join("");
  200.           lower = lower.toLowerCase();
  201.           out(lower);
  202.           break;
  203.         case 'reverse':
  204.           var reversehits = [];
  205.           for(var j7 = 9; j7 <= text.length; j7++) {
  206.             reversehits.push(text[j7]);
  207.           } reversehits = reversehits.reverse();
  208.           reversehits = reversehits.join("");
  209.           out("@" + nick + " Output: " + reversehits);
  210.           break;
  211.         case 'kill':
  212.           var kills = [];
  213.           for(var j6 = 6; j6 <= text.length; j6++) {
  214.             kills.push(text[j6]);
  215.           }
  216.           kills = kills.join("");
  217.           out(nick + " hangs " + kills + ", cuts them into pieces and cooks them.");
  218.           break;
  219.         case 'random':
  220.           out(Math.random().toString(36).substr(2));
  221.           break;
  222.         case 'messages':
  223.           out(counter);
  224.           break;
  225.         case 'out':
  226.           if(nick == "ijs") {
  227.             out(Math.random().toString(70).substr(2));
  228.           } else {
  229.             out('hahahhahaha nope');
  230.           }
  231.           break;
  232.         case 'speakwho':
  233.           out(activenicks.length + " people have spoken since I joined. " + activenicks);
  234.           break;  
  235.         case 'gtfo':
  236.           out("Be more gentle.");
  237.           break;
  238.         case 'toasty':
  239.           switch(nick) {
  240.             case "ToastyStoemp":
  241.             case "ToastyStoempy":
  242.               out("Hey Toasty! :D");
  243.               break;
  244.             case 'stamsarger':
  245.               out("Toasty actually banned you for being a dumpass, stam, lol. (nil's idea)");
  246.               break;
  247.             case 'leonardo':
  248.               out("Isn't toasty awesome, leonardo?");
  249.               break;
  250.             case 'bacon':
  251.               out("Bacon, everybody knows you two do $ your \\ things.$");
  252.               break;
  253.             case "M4GNV5":
  254.               out("Magnus, you're going well with Toasy, right?");
  255.               break;
  256.             case 'Bloodsipper':
  257.             case "LuckyBlood":
  258.               out("Bloodsipper is gonna kill TOASTY TOO?!?!?!?!?!?!");
  259.               break;
  260.             default:
  261.               out("Toasty is awesome!");
  262.               break;
  263.           }
  264.           break;
  265.         case 'vortico':
  266.           if(nick == "vortico") {
  267.             out("Hey vortico! :D");
  268.           } else {
  269.             out("You aren't vortico -_-");
  270.           }
  271.           break;
  272.         case 'bloodsipper':
  273.         case 'Bloodsipper':
  274.         case 'BLOODSIPPER':
  275.         case 'bloody':
  276.         case 'BLOODY':
  277.         case 'Bloody':
  278.         case 'Blood':
  279.         case 'BLOOD':
  280.         case 'blood':
  281.           out("$BLOODSIPPER$ $IS$ $GONNA$ $FUCKING$ $KILL$ $US$ $ALL$ (and he's badass)");
  282.           break;
  283.         case 'terms':
  284.           out('If you use this bot, you accept these terms. I have the right to ban you whenever I want, even if you have not done anything wrong. Also, if you use the spam command multiple times, you are responsible for what happens next. \nEven though you probably haven\'t read the terms because I am a douche, I can always accuse of breaking the terms (even though you haven\'t) and ban you.');
  285.           break;
  286.         case 'theworldshardestgame':
  287.           out('I can\'t even get past the 6th stage >< http://www.addictinggames.com/action-games/theworldshardestgame.jsp');
  288.           break;
  289.         case 'echo':
  290.           var echo = [];
  291.           for(var j = 6; j <= text.length; j++){
  292.             echo.push(text[j]);
  293.           }
  294.           echo = echo.join("");
  295.           if(nick != "Kainui") {
  296.           if(echo.length <= 160) {
  297.             out(echo);
  298.           } else {
  299.             out("Can't execute: You have entered " + echo.length + " characters, so you got past the limit.");
  300.           }
  301.           }
  302.           break;
  303.         case 'pie':
  304.           if(nick != "why") {
  305.           var pies = [];
  306.           for(var j12 = 5; j12 <= text.length; j12++){
  307.             pies.push(text[j12]);
  308.           } pies = pies.join("");
  309.           out("@" + nick + " throws pie right in @" + pies + '\'s face.');
  310.           }
  311.           break;
  312.         case 'screw':
  313.           var screwhits = [];
  314.           for(var j2 = 7; j2 <= text.length; j2++){
  315.             screwhits.push(text[j2]);
  316.           }
  317.           screwhits = screwhits.join("");
  318.           screwhits = screwhits.toUpperCase();
  319.           if(screwhits.length === 0){
  320.             out('Pick a name to screw.');
  321.           } else {
  322.               out('SCREW YOU, ' + screwhits + "! YOU'RE AN ASSHOLE!");
  323.           }
  324.           break;
  325.         case 'shutup':
  326.           out("I hope that you die. $You$ shut up, sick bastard.")
  327.           break;
  328.         case 'rock':
  329.           if(computerchoice <= 0.5) {
  330.             out("Paper. Paper wins!")
  331.           } else {
  332.             out("Scissors. Rock wins!")
  333.           }
  334.           break;
  335.         case 'paper':
  336.           if(computerchoice <= 0.5) {
  337.             out("Rock. Paper wins!")
  338.           } else {
  339.             out("Scissors. Scissors wins!")
  340.           }
  341.           break;
  342.         case 'scissors':
  343.           if(computerchoice <= 0.5) {
  344.             out("Rock. Rock wins!")
  345.           } else {
  346.             out("Paper. Scissors wins!")
  347.           }
  348.           break;
  349.         case 'bloody\'scode':
  350.           out('It\'s fucked up, dude. It\'s really fucked up.');
  351.           break;
  352.         case 'drake':
  353.           out("Drake is worse than JB.");
  354.           break;
  355.         case 'quote':
  356.           var raquote = Math.random();
  357.           if(raquote <= 0.20) {
  358.             out("Because who doesn't love watching animes being violated? -Stamsarger, 2015.");
  359.           } else if(raquote <= 0.40){
  360.             out("Linux sucks more dick than Obama. -Stamsarger, 2015.");
  361.           } else if(raquote <= 0.60){
  362.             out("wen now wim winna wim no wim na wim a nigga up like sheen got hon zon ko. -Iggy Azalea, 2015.")
  363.           } else if(raquote <= 0.80){
  364.             out("Patience is the mother of failure. -Stamsarger, 2015.");
  365.           } else {
  366.             out("lol windows is nothing but a boot virus....Sums it up. -MSI, 2015.");
  367.           }
  368.           break;
  369.         case 'help':
  370.         case 'h':
  371.           out("$ \\large \\color{blue}{Yeah, \\ you \\ do \\ need \\ help. \\ There \\ is \\ the \\ commands \\ command, \\ moron.}$")
  372.           break;
  373.         case 'commands': //some morons cant understand what I mean with "Add a space (' ') before:". Fucking idiots...
  374.           out("$Stammy, \\ a \\ fast \\ and \\ reliable \\ hack.chat \\ bot \\ by \\ stamsarger.$\nAdd a space ( ) before: messages, speakwho, afk, speak, webdev, formathelp, tiny, lower, upper, pie, length, random, reverse, quote, kill, vortico, echo, toasty, theworldshardestgame, screw, jscommand, funfact, bloodsipper, yolo, siri, stamsarger, learntocode, anonymous, source, fuck, bang, french, greek, rockpaperandscissors, cookie, bacon, afk, spam, about, help, commands, rock, paper, scissors, shutup, hello.")
  375.           break;
  376.         case 'about':
  377.           out('I\'m stamsarger\'s cruel bot. I\'m still under development.')
  378.           break;
  379.         case 'afk':
  380.           out(nick + " is AFK");
  381.           break;
  382.         case 'length':
  383.           var lengthy = [];
  384.           for(var j8 = 8; j8 <= text.length; j8++){
  385.             lengthy.push(text[j8]);
  386.           } lengthy = lengthy.join('');
  387.           out("@" + nick + "'s text has a length of " + lengthy.length + " characters.");
  388.           break;
  389.         case 'cookie':
  390.           var towhom = [];
  391.           for(var j3 = 8; j3 <= text.length; j3++){
  392.             towhom.push(text[j3]);
  393.           }
  394.           towhom = towhom.join("");
  395.           if(towhom == nick) {
  396.             out('Invalid.')
  397.           } else if(towhom == "leonardo"){
  398.             out('NO COOKIES FOR YOU, BIATCH!');
  399.           } else if(towhom == "Stammy"){
  400.             out("Wow, no one ever thinks of me! Thanks " + nick + ", you're awesome!");
  401.           }
  402.           else {
  403.             out(nick + ' gives ' + towhom + ' some cookies.');
  404.           }
  405.           break;
  406.         case 'bacon': //I mean the food, not the user bacon.
  407.           var towhom2 = [];
  408.           for(var j4 = 7; j4 <= text.length; j4++){
  409.             towhom2.push(text[j4]);
  410.           }
  411.           towhom2 = towhom2.join("");
  412.           if(towhom2 == "bacon") {
  413.             out("Tons of bacon fall on the user bacon, waiting happily to be eaten.");
  414.           }
  415.           else {
  416.             out(nick + " slaps " + towhom2 + " with bacon.");
  417.           }
  418.           break;
  419.         case 'rockpaperandscissors': //totally useless command
  420.           out("What do you choose? rock,  paper,  scissors.");
  421.           break;
  422.         case ' ':
  423.           break;
  424.         case 'greek':
  425.           out("Γεια. Πάμε ?gr.") // means "Hello. Lez go to ?gr."
  426.           break;
  427.         case 'french': //means "I don't think there are many French here, but you can go to ?fr."
  428.           out("Je crois qu'il n'y a pas beaucoup de Francais ici, mais tu peux aller a ?fr.")
  429.           break;
  430.         case 'fuck':
  431.           out("I like it when you are miserable.");
  432.           break;
  433.         case 'bang': //reaallllyyyyy.
  434.           out('Congrats, dude! You finally banged a woman. Nothing to be ashamed of.')
  435.           break;
  436.         case 'source': //even though this is open source.
  437.           out('Open-source apps are idiotic crap.')
  438.           break;
  439.         case 'anonymous': //some new guy might even fall for that shit.
  440.           out('We are anonymous. \nWe are legion. \nWe do not forgive, we do not forget. \nExpect us.');
  441.           break;
  442.         case 'learntocode': //yo.
  443.           out("Try http://codecademy.com and http://udemy.com. They're both awesome. For a text editor, I recommend using Sublime Text 2, Programmer's Notepad (if your main language is English) or Atom. The best JavaScript browser is Microsoft Edge, alternatively you can use Chrome. They handle JS the best.")
  444.           break;
  445.         case 'stamsarger': //:p
  446.           switch(nick) {
  447.             case 'stamsarger':
  448.             case 'stamsarg':
  449.               out("Hey creator.");
  450.               break;
  451.             default:
  452.               out('HEEEEEYYYYYY STAAAAAAMMMMMMM I NEED YAAAAAA');
  453.               break;
  454.           }
  455.           break;
  456.         case 'siri':
  457.           /*
  458.           var textlower = text.toLowerCase();
  459.           var sirihits = [];
  460.           for(var siri = 0; siri <= text.length; siri++) {
  461.             switch(text[siri]){
  462.               case 'h':
  463.                 for(var sirihelp = siri; sirihelp <= (text.length - siri); sirihelp++){
  464.                   sirihits.push(text[sirihelp]);
  465.                   if(sirihits.length === "help".length) {
  466.                     break;
  467.                   }
  468.                 }
  469.                 break;
  470.               case 'c':
  471.                 for(var siricommands = siri; siricommands <= (text.length - siri); siricommands++){
  472.                   sirihits.push(text[siricommands]);
  473.                   if(sirihits.length === "commands".length) {
  474.                     break;
  475.                   }
  476.                 }
  477.                 break;
  478.               case '':
  479.  
  480.                 break;
  481.             }
  482.           }
  483.           sirihits = sirihits.join("");
  484.           switch(sirihits) {
  485.             case '':
  486.               out("Fuck you, either I can't find the command or you use this wrong.");
  487.               break;
  488.           } */
  489.           out("Still being developed.")
  490.           break;
  491.         case 'yolo':
  492.           out('$Y$ou $O$nly $L$ive $O$nce');
  493.           break;
  494.         case 'funfact': //thanks to Jax for writting them all apart from the last one, which is mine.
  495.           var choosefact = Math.random() * 12;
  496.             if(choosefact <= 1) {
  497.               out(funfacts[0])
  498.             } else if(choosefact <= 2) {
  499.               out(funfacts[1])
  500.             } else if(choosefact <= 3) {
  501.               out(funfacts[2])
  502.             } else if(choosefact <= 4) {
  503.               out(funfacts[3])
  504.             } else if(choosefact <= 5) {
  505.               out(funfacts[4])
  506.             } else if(choosefact <= 6) {
  507.               out(funfacts[5])
  508.             } else if(choosefact <= 7) {
  509.               out(funfacts[6])
  510.             } else if(choosefact <= 8) {
  511.               out(funfacts[7])
  512.             } else if(choosefact <= 9) {
  513.               out(funfacts[8])
  514.             } else if(choosefact <= 10) {
  515.               out(funfacts[9])
  516.             } else if(choosefact <= 11) {
  517.               out(funfacts[10])
  518.             } else {
  519.               out(funfacts[11])
  520.             }
  521.           break;
  522.         case 'jscommand': //this kinda makes me js expert, doesn't it?
  523.           var jschoose = Math.random();
  524.           if(jschoose <= 0.25) {
  525.             jschoose = 1;
  526.             jschoose = Math.random();
  527.             if(jschoose <= 0.33){
  528.               out('Notifying commands. A nice JavaScript command is alert(). It asks the user whether they want to do something, or it notifies them.');
  529.             } else if(jschoose <= 0.66){
  530.               out('Notifying commands. A nice JavaScript command is prompt(). It asks the user something, and it expects an answer. Depending on the answer, some other alert()s and prompt()s will show up.');
  531.  
  532.             } else {
  533.               out('Notifying commands. A nice JavaScript command is confirm(). It is the same as alert().');
  534.             }
  535.           } else if(jschoose <= 0.5){
  536.             jschoose = 1;
  537.             jschoose = Math.random();
  538.             if(jschoose <= 0.5){
  539.               out('Keywords. A nice JavaScript keyword is function. It declares functions, so that you won\'t need to write the same code again. It works like this: ');
  540.               out('function example(parameter1, parameter2) { //do this }')
  541.             } else{
  542.               out('Keywords. A nice JavaScript keyword is var. It declares variables that store a value. It could be anything from the data types.')
  543.             }
  544.           } else if(jschoose <= 0.75){
  545.             jschoose = 1;
  546.             jschoose = Math.random();
  547.             if(jschoose <= 0.33){
  548.               out('Loops. While loops are really powerful. They can do whatever for loops do with another syntax. Furthermore, they\'re awesome if you wanna loop and you dunno when to stop. while(condition) { // do this }. Be careful! The condition must change in the while loop or else you\'ll get an infinite loop.')
  549.             } else if(jschoose <= 0.66){
  550.               out('Loops. Do/while loops are the same as while loops, however they make sure these things happen before the loop starts. do { //stuff } while(condition)');
  551.  
  552.             } else {
  553.               out('Loops. For loops are much more powerful and flexible than the other loops. Their syntax is harder to learn. You can also nest for loops. for(var i = 0; i <= 8; i += 1) { document.write("sup")} will output "sup" eight times.')
  554.             }
  555.           } else {
  556.             jschoose = 1;
  557.             jschoose = Math.random();
  558.             if(jschoose <= 0.33) {
  559.               out('Conditionals. ?: are called ternary. They are short if statements. E.g.: var isItTrue = 10 > 100 ? "yes" : "no" document.write(isItTrue) outputs \'no\'.')
  560.             } else if(jschoose <= 0.66) {
  561.               out('Conditionals. Switch statements are da best if you have a lot of conditions and you don\'t wanna write so much. They are good for variables asking for input. eg: var a = prompt("What\'s your favorite room?") switch(a) { case "bedroom": //do this break; case "kitchen": alert("Mine too!") break; default: alert("Awesome!")}')
  562.             } else {
  563.               out('Conditionals. This is the master: If/else if/else statements are the most powerful and used conditionals. For instance: if(condition) { // do this } else if(2nd condition) { // stuff } else { // otherwise, do this }')
  564.             }
  565.           }
  566.           break;
  567.       }
  568.     }
  569.   } else {
  570.     console.log(nick + ": " + text);
  571.     nicks.push(nick);
  572.     counter++;
  573.   }
  574. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement