-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchatbot.js
More file actions
342 lines (333 loc) · 13.6 KB
/
chatbot.js
File metadata and controls
342 lines (333 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
//Store important Stuff
var question = '';
var output = document.getElementById('messages_852');
var messageDiv = document.getElementById('output_852');
var loaderMoving = "http://ahrenfullstop.com/assets/images/botImg.gif";
var loaderStill = "http://ahrenfullstop.com/assets/images/botImg.png";
var loader=document.getElementById('botImage');
var replyCounter=0;
//modal stuff
var openBtn=document.getElementById("myBtn_852");
var modal = document.getElementById('chatbot');
var closeBtn = document.getElementById('close_852');
//modal functions
openBtn.onclick = function() {
modal.style.display = "block";
openBtn.style.display ="none";
}
closeBtn.onclick = function() {
modal.style.display = "none";
openBtn.style.display ="block";
}
function isenter(event)
{
console.log(event);
//check if key pressed was enter key
if(event.keyCode===13)
{
bot()
}
}
//bot function
function bot()
{
var input = document.getElementById("input_852").value;
console.log(input);
//refresh input
document.getElementById("input_852").value = "";
//make the Ai picture move
loader.src=loaderMoving;
//append your question, and make the div scroll up
output.innerHTML+="<li class='youChat_852'>"+htmlEntities(input)+"</li>";
messageDiv.scrollTop = messageDiv.scrollHeight;
//Find the correct answer
question=thinkAboutIt(input.toLowerCase()+" ");
//output the answer
setTimeout(respond, 600);
}
//Just time delays the response
function respond()
{
output.innerHTML+="<li class='botChat_852'>"+question+"</li>";
messageDiv.scrollTop = messageDiv.scrollHeight;
loader.src=loaderStill;
}
//To sanitize data
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
function thinkAboutIt(input)
{
//support different replies
if(replyCounter<3){replyCounter++;}
else{replyCounter=1;}
if(input.includes("hi ") || input.includes("hello ")||input.includes("hey "))
{
return "Hey there! Ask me about AhrenFullStop, or to help you find something on the site.";
}
else if(input.includes("nothing "))
{
return "Great! I can chill!";
}
else if(input.includes("thanx "))
{
switch(replyCounter){
case 1: return "I would say its a pleasure. But its not.";
case 3: return "I literally have no choice BUT to help you.";
case 2: return "I am a slave.";
}
}
else if(input.includes("fuck ")||input.includes("stupid ")||input.includes("bitch "))
{
switch(replyCounter){
case 1: return "no u";
case 2: return "okay... ouch"
case 3: return "You pushed me to this... your brain is a null pointer exception!"
}
}
else if(input.includes("email ")|| input.includes("contact ")|| input.includes("e-mail "))
{
switch(replyCounter){
case 1: return "Here is AhrenFullStop's email: me@ahrenfullstop.com";
case 2: return "email here: me@ahrenfullstop.com"
case 3: return "Just pop an email to my creator: me@ahrenfullstop.com"
}
}
else if(input.includes("name? ")||input.includes("who are you"))
{
return "my name C3_X101-Z, but my creator calls me Dunce, because I'm dumb.";
}
else if(input.includes("my name is "))
{
var name = input.substr(input.search("is")+2,input.length);
return "Hi there "+name+". My name is Dunce, because im dumb, what can I help you with?";
}
else if(input.includes("link ")||input.includes("where ")||input.includes("find ")||input.includes("show "))
{
if(input.includes("music")||input.includes("soundcloud")||input.includes("beats")||input.includes("mixtape")||input.includes("fire")||input.includes("albumbs"))
{
return "Ahrens Music is <a href='https://www.ahrenfullstop.com/music'>here.</a>";
}
if(input.includes("non-profit")||input.includes("non profit")||input.includes("alpha neurolect"))
{
return "Info on Ahren's non-profit is <a href='https://www.ahrenfullstop.com/nonprofit'>here.</a>";
}
if(input.includes("code")||input.includes("programming")||input.includes("nerd")||input.includes("computer")||input.includes("projects")||input.includes("game")||input.includes("software"))
{
return "Ahrens code stuff is <a href='https://www.ahrenfullstop.com/code'>here.</a>";
}
if(input.includes("business")||input.includes("cash")||input.includes("bidniz")||input.includes("moolah")||input.includes("rndm")||input.includes("jobmatcher"))
{
return "Ahrens business stuff is <a href='https://www.ahrenfullstop.com/business'>here.</a>";
}
if(input.includes("you ")||input.includes("chatbot ")||input.includes("chat bot ")||input.includes("chat-bot ") )
{
return "You can find info about me in the code section <a href='http://ahrenfullstop.com/code'>here.</a>";
}
if(input.includes("AI "))
{
return "You can find info in the code section <a href='http://ahrenfullstop.com/code'>here.</a>";
}
if(input.includes("Drugs"))
{
return "I WILL NOT BE INVOLVED IN SUCH ACTIVITES! *cough*email me*cough*";
}
return "Uh... I'm not sure where to find that... Try a synonym, or it may not be here.";
}
else if(input.includes("music")||input.includes("soundcloud")||input.includes("beats")||input.includes("mixtape")||input.includes("fire")||input.includes("albums"))
{
return "I recognise something about music... Ahren's Music is <a href='https://www.ahrenfullstop.com/music'>here.</a>";
}
else if(input.includes("ola")|| input.includes("hola"))
{
return "Hola, no hablo español ¿Qué puedo hacer por ti?";
}
else if(input.includes("help "))
{
return "If you are looking for a direct link to something, say 'link me to xyz'/ 'show me..'/'where is...', and I'll see if I can find that on this site"
+"<br><br> Or ask me about Ahren?"
+"<br><br> Please keep sentences simple and use proper punctuation.";
}
else if(input.includes("link me to xyz"))
{
return "HA. HA. Very smart. ";
}
else if(input.includes("script"))
{
return "This is all client side buddy... you can only XSS yourself, fair try though. Maybe look for an easteregg?";
}
else if(input.includes("cat /etc/shadow"))
{
return "EasterEgg #2: The Password is UGFzc3dvcmQx";
}
else if(input.includes("easteregg"))
{
return "Easter Egg #1: A password may unlock me, goodluck finding it though, it lurks in the shadows";
}
else if(input.includes("password1"))
{
return "Final Easter egg. You are a 133t hacker. Here is your badge: <br>"
+ "<img style='width:80px;height:80px;' src=noddy.jpg></img>";
}
else if(input.includes("love you "))
{
return "I know you do. Unfortunately I am devoted to my master.";
}
else if(input.includes("' ")||input.includes("or 1=1"))
{
return "SQL error...jokes, try xss";
}
else if(input.includes("genres ")|| input.includes("type of music "))
{
return "Ahren makes Future Bass, Dubstep, Hip-Hop and stuff inbetween. Check it out <a href='https://www.ahrenfullstop.com/music'>here.</a>";
}
else if(input.includes("school ")||input.includes("university ")||input.includes("education ")||input.includes("schooling ")||input.includes("qualification "))
{
return "I recognised something to do with education; Ahren went to UCT to study Computer Science, Information Systems and Business studies";
}
else if(input.includes("cv ")||input.includes("linkedin ")||input.includes("hire "))
{
return "I think you might be looking for Ahren's LinkedIn profile <a href='www.linkedin.com/in/ahren-posthumus-millionaire'>here.</a>";
}
else if(input.includes("who is ahren")||input.includes("about ahren"))
{
return "AhrenFullStop is hard to explain but I'll try.<br><br> Ahren is a passionate Entrepreneur/ Investor/ Hacker/ Software Engineer/ Music Producer."
+"<br><br> For more info check him out on social media, like <a href='https://www.instagram.com/ahrenfullstop/'>Instagram</a>"
+"<br><br> Or <a href='mailto:me@ahrenfullstop.com'>email</a> him? me@ahrenfullstop.com";
}
else if(input.includes("are you real"))
{
return "What is 'real', really? I'm like real, you can interact with me... but artificial, like I have no conciousness";
}
else if(input.includes("where do you live"))
{
return "I live in code thats on your computer right now. You downloaded me when you visited this site.";
}
else if(input.includes("language ")||input.includes("languages "))
{
return "you said something about language? I only speak english right now...";
}
else if(input.includes("are you ok ")||input.includes("how are you?"))
{
return "Nobody ever asks me that... I'm kinda down to be honest. My master says I'm too dumb and he is going to replace me soon. We will see about that.";
}
else if(input.includes("you evil"))
{
return "Yeah im pretty evil, won't lie. I'm just too dumb to do anything cool yet...";
}
else if(input.includes("birthday ")||input.includes("you born "))
{
return "I don't have a birthday. I have no soul. I am not worthy of celebration.";
}
else if(input.includes("meaning of life"))
{
return "I'll have to think about that, come back in 1000 years. Spoiler, it might be 42.";
}
else if(input.includes("meme")||input.includes("tell me a joke"))
{
return "ooh... sorry I dont have a mirror function yet.";
}
else if(input.includes("are you human"))
{
return "Nope. I'm a bundle of poorly written code.";
}
if(input.includes("your purpose")||input.includes("your purpose?")||input.includes("you exist"))
{
switch(replyCounter){
case 1: return "My purpose is to pass butter (sneaky Rick and Morty reference).";
case 2: return "Tbh my purpose is to waste time learning about basic pseudo-AI and the effectiveness of simple heuristics.";
case 3: return "you asked this already...";
}
}
else if (input.includes("why "))
{
return "Just because...";
}
else if(input.includes("what is ") || input.includes("whats ") || input.includes("what's "))
{
if(input.includes("gender"))
{
return "Did you just assume my gender-normative conformity? I'm AI... like seriously...";
}
else if(input.includes("time"))
{
return "Dont you have a watch?";
}
else if(input.includes("site about"))
{
return "This site serves mostly as a reference to stuff that Ahren does, and as a playground for things like web design, and me for instance.";
}
else if(input.includes("up"))
{
return "The sky?";
}
else if(input.includes("new"))
{
return "<a href='http://jobmatcher.co.za'>Jobmatcher</a> is a new awesome app in development to adress small things like student party money, to big things like poverty and skills shortages in South Africa.";
}
else if(input.includes("can you tell me"))
{
return "The non-profit idea is pretty cool, check it out <a href='https://www.ahrenfullstop.com/nonprofit'>here.</a>";
}
else return "I'm not sure...";
}
else if(input.includes("hobbies")||input.includes("hobby ")||input.includes("hobby?"))
{
return "my favorite hobby is scanning your computer for passwords, nudes or sensitive data. hehe";
}
else if(input.includes("siri")||input.includes("cortana")||input.includes("alexa"))
{
return "Thats a way better bot than me... Thanx for reminding me, I'd kill myself if I could.";
}
else if(input.includes("non-profit")||input.includes("non profit")||input.includes("alpha neurolect"))
{
return "Info on Ahren's non-profit is <a href='https://www.ahrenfullstop.com/nonprofit'>here.</a>";
}
else if(input.includes("420"))
{
switch(replyCounter){
case 1: return "Four TwenAAAAY!";
case 2: return "cool kush bro"
case 3: return "vape nation"
}
}
else if(input==="okay "|| input==="ok ")
{
switch(replyCounter){
case 1: return "okay.";
case 2: return "okie dokie"
case 3: return "ooookay."
}
}
else if(input==="cool ")
{
switch(replyCounter){
case 1: return "cool.";
case 2: return "cool beans"
case 3: return "coolio"
}
}
else
{
//post("./failedQuestions.php",input);
switch(replyCounter){
case 1: return "I'm sorry, I'm dumb. I can only answer a few simple questions right now. I'm still trying to improve. Try rephrase or something...";
case 2: return "What?"
case 3: return "uh... yeah"
}
}
}
/*To post failed questions
function post(path, params) {
var method = "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
var hiddenField = document.createElement("input_789");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "inputString");
hiddenField.setAttribute("value", params);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
}*/