├── .eslintrc ├── .gitignore ├── README.md ├── main.js ├── package.json └── questions.js /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true 4 | }, 5 | "rules": { 6 | "strict": 0, 7 | "no-process-exit": 0 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # InteractiveForwardBot 2 | Ask questions in a sequential order with lots of funs included! 3 | 4 | To begin, start with ```npm install``` 5 | 6 | Then, ```npm start``` 7 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | var q = require("./questions.js"), 2 | readline = require("readline"), 3 | sleep = require("sleep"); 4 | var rl = readline.createInterface({ 5 | input: process.stdin, 6 | output: process.stdout 7 | }), 8 | i = 0, 9 | shouldgo = true, 10 | qstn = q.questions[i]; 11 | 12 | console.log(qstn.q); 13 | rl.question(); 14 | rl.on("line", function(line) { 15 | shouldgo = true; 16 | var shouldProcessNo = true; 17 | line = line.trim().toLowerCase(); 18 | var linked = false; 19 | 20 | //profanity check - let's say bye to the fucknuts 21 | linked = q.profanity.filter(function(n) { 22 | return line.indexOf(n) !== -1; 23 | }); 24 | 25 | //this user is definitely a fucknut, say goodbye 26 | if (linked.length > 0) { 27 | var randomAnsIndex = Math.floor(Math.random() * q.profanityexit.length); 28 | sleep.sleep(1); 29 | console.log(q.profanityexit[randomAnsIndex]); 30 | process.exit(); 31 | } 32 | 33 | //first check if the answer matches any link 34 | if (qstn.link) { 35 | linked = false; 36 | linked = qstn.link.filter(function(n) { 37 | return line.indexOf(n) !== -1; 38 | }); 39 | if (linked.length > 0) { 40 | if (qstn.linkans) { 41 | console.log(qstn.linkans); 42 | shouldProcessNo = false; 43 | } 44 | sleep.sleep(1); 45 | } 46 | 47 | } 48 | 49 | //ok so if there was no match with a linked ans, maybe it's a negative reply? 50 | if (qstn.no && shouldProcessNo) { 51 | linked = false; 52 | linked = qstn.no.filter(function(n) { 53 | return line.indexOf(n) !== -1; 54 | }); 55 | if (linked.length > 0) { 56 | if (qstn.noq) { 57 | qstn = qstn.noq; 58 | sleep.sleep(1); 59 | shouldgo = false; //link this noq question with the standard question loop 60 | } else if (qstn.linkans) { 61 | console.log(qstn.linkans); 62 | process.exit(); 63 | } else 64 | process.exit(); 65 | } 66 | } 67 | 68 | //noq was not linked. so let's go as usually 69 | if (shouldgo === true) { 70 | i++; 71 | if (i > q.questions.length) { 72 | process.exit(); 73 | } 74 | qstn = q.questions[i]; 75 | } 76 | 77 | if (qstn) { 78 | sleep.usleep(250000); //breath for a quarter second 79 | console.log(qstn.q); 80 | 81 | //if this a dead end, say good bye 82 | if (!qstn.no && !qstn.link) { 83 | process.exit(); 84 | } 85 | } else { 86 | //no more questions, phew! 87 | process.exit(); 88 | } 89 | }); 90 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "interactive-forward-bot", 3 | "license": "MIT", 4 | "repository": { 5 | "type": "git", 6 | "url": "git+ssh://git@github.com/hasinhayder/InteractiveForwardBot.git" 7 | }, 8 | "description": "Interactive Forward Bot. Ask questions in a sequential order with lots of funs included!", 9 | "author": { 10 | "name": "Hasin Hayder", 11 | "email": "hasin@leevio.com" 12 | }, 13 | "dependencies": { 14 | "sleep": "*" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/hasinhayder/InteractiveForwardBot/issues" 18 | }, 19 | "homepage": "https://github.com/hasinhayder/InteractiveForwardBot#readme", 20 | "version": "1.0.0", 21 | "main": "main.js", 22 | "devDependencies": {}, 23 | "scripts": { 24 | "test": "echo What are you trying to test?", 25 | "start": "node main.js" 26 | }, 27 | "keywords": [ 28 | "ifb", 29 | "bot", 30 | "interactive", 31 | "questions" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /questions.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | profanity: ["fuck", "quit", "damn you", "don't be stupid", "you're silly", "screw you", "wtf"], 3 | profanityexit: ["Oh oops! Let's talk another time", "That's not nice! There's no talking to you.", "STFU & Go To Sleep", "Screw You! This conversation is over.", "What? What on earth...", "Dang! I think I was nice to you"], 4 | questions: [{ 5 | q: "Hey, How are you?", 6 | link: ["how", "not bad", "you"], 7 | linkans: "I am fine too, thanks!", 8 | no: ["no", "not good", "bad"], 9 | noq: { 10 | q: "Opps! Well, then take a break and let's talk another time" 11 | } 12 | }, { 13 | q: "Nice! So how is the weather?", 14 | link: ["how"], 15 | linkans: "Hmm, weather is nice around here. Mild and breezy!", 16 | no: ["bad"], 17 | noq: { 18 | q: "Looks like it's only me who's having some funtime with weather. Are you okay?", 19 | link: ["sure", "yes", "ha"], 20 | linkans: "It seems that you're in a good mood, ha?", 21 | no: ["nah", "meh", "maybe", "no"], 22 | noq: { 23 | q: "In that case I think we should talk another time. Do you still want to continue?", 24 | link: ["yes", "sure", "why not"], 25 | linkans: "Perfect. Let's move on!", 26 | no: ["no", "nah"], 27 | noq: { 28 | q: "Alright bye!" 29 | } 30 | } 31 | } 32 | }, { 33 | q: "Okay. So I'd like to ask a few questions to understand whether this will be a good fit for you. Are you ok with that?", 34 | link: ["yes"], 35 | linkans: "Perfect! Let's proceed.", 36 | no: ["no", "not", "maybe", "seriously"], 37 | noq: { 38 | q: "I think we should talk another time, What do you think?", 39 | no: ["yes", "ok", "sure", "perfect"], 40 | noq: { 41 | q: "Perfect! Take a deep breath and good bye" 42 | } 43 | } 44 | }, { 45 | q: "Are you in front of a computer? Because you need to write some code :)", 46 | no: ["mobile", "no", "not", "negative"], 47 | noq: { 48 | q: "Ok then, please knock me back when you're in front of a computer" 49 | }, 50 | link: ["yes", "ofc", "of course", "sure", "ok", "correct", "affirmative"], 51 | linkans: "You know what, it's kinda late here. So let's talk tomorrow! Have a good day. Bye Bye" 52 | }] 53 | }; 54 | --------------------------------------------------------------------------------