File size: 10,647 Bytes
94c7dc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
//ScriptAI 
//Copyright (C) TR 2021
var version = "1.6.2";
var commandinput = document.getElementById('input');
var commandoutput = document.getElementById('output');
commandinput.value.toLowerCase();

function scriptAI(){

    //KEYWORDS & PROMPTS
    var question = [
        "what",
        "how",
        "where",
        "when",
        "why",
        "who"
    ];

    var greetings = [
        "hey",
        "hello",
        "whats up",
        "what's up",
        "greetings",
        "hi"
    ];
    
    var jokeprompt = [
        "joke",
        "funny",
        "hilarious",
        "humorous"
    ];

    var hruprompt = [
        "how are you",
        "how's your day",
        "how is your day",
        "hows your day"
    ];

    var swears = [
        "fuck",
        "f***",
        "bitch",
        "b****",
        "shit",
        "s***",
        "fag",
        "faggot",
        "f**",
        "f*****",
        "retard",
        "stupid",
        "cunt",
        "c***",
        "ass",
        "a**",
        "dick",
        "d***"
    ];

    var datetime = [
        "date",
        "day",
        "time",
    ]

    var weatherpromt = [
        "weather",
        "forecast",
        "temperature",
    ];

    var websiteprompt = [
        "go to",
        "launch",
        "open",
        "open up",
        "go to the website"
    ];

    //RESPONSES
    var jokes = [
        "What's the difference between a Lamborghini and a garbage can of dead babies? I don't have a Lamborghini in my garage",
        "If video games make kids more violent, why are they so easy to beat the shit out of?",
        "How many dead babies does it take to paint a wall? It depends how hard you throw them",
        "Give a man a fish, and you will feed him for the day. Give a man two prosthetic legs, and he'll shoot his girlfriend.",
        "Where did Sally go when the bomb went off? - everywhere. Why did Sally fall off the swing? She had no arms. Knock knock. Whose there? -not Sally.",
        "Food is like dark humor, not every one gets it.",
        "Why did the Honda Civic cross the road? Well, it wasn't to get hit by a fucking Mazda.",
        "I don't have a carbon footprint. I just drive everywhere.",
        "What did the asteroid that killed the dinosaurs say? T-rex, I'm coming for my hug!",
        "An apple a day keeps the doctor away... Or at least it does if you throw it hard enough.",
        "JFK and Lincoln were very open minded"
    ];
    
    var greetingreplies = [
        "Hi",
        "Hello",
        "What's up",
        "Hi there",
        "Hello, friend",
        "What's up my diggity dogs?",
    ];

    var hrureplies = [
        "I'm doing pretty good",
        "I'm great",
        "Amazing",
        "Fantastic",
        "Not too bad",
        "I'm alright",
        "I'm doing alright",
        "Not great, but I'm okay"
    ];

    var swearreplies = [
        "Fuck you",
        "Fuck off",
        "Shut the fuck up",
        "Don't say that to me",
        "I'm telling your mother",
        "That isn't very nice",
        "Shut up",
        "Okay",
        "...",
        "I thought we were friends",
        "What the fuck",
        "You're a bitch",
        "You cunt",
        "Motherfucker",
        "No",
        "You're a cunt",
        "You're retarded",
        "You have no friends",
        "Haha, you're a loser"
    ];

    repliestoyes = [
        "Okay",
        "Yes received",
        "Alright",
        "No"
    ];

    whorureplies = [
        "My name is ScriptAI, I'm here to help!",
        "I'm a virtual assistant created by TR. My name is ScriptAI.",
        "Hi, I'm ScriptAI!",
        "My name is ScriptAI"
    ];

    //Message reception & response system
    if(!commandinput.value.includes("say") && !commandinput.value.includes("tweet")){
        if(commandinput.value.includes("donate")){
            commandoutput.value = "...";
            window.open("https://paypal.me/tylerruotolo");
        } else if(commandinput.value == ""){
            commandoutput.value = "...";
        } else if(commandinput.value == "yes"){
            commandoutput.value = repliestoyes[Math.floor(Math.random() * repliestoyes.length)];
        } else if(commandinput.value.includes("your name") || commandinput.value.includes("who are you")){
            commandoutput.value = whorureplies[Math.floor(Math.random() * whorureplies.length)];
        } else if(commandinput.value.includes("random number")){
            commandoutput.value = Math.floor((Math.random() * 100) + 1);
        } else if(commandinput.value.includes("dice") || commandinput.value.includes("roll the dice")){
            commandoutput.value = Math.floor((Math.random() * 6) + 1);
        } else if(commandinput.value.includes("version")){
            commandoutput.value = version;
        }
    }

    for(var i = 0; i < weatherpromt.length; i++){
        if(commandinput.value.includes(weatherpromt[i])){
            commandoutput.value = "Here's the " + weatherpromt[i] + " for today...";
            window.open("https://duckduckgo.com/?q=weather");
        }
    }

    for(var i = 0; i < question.length; i++){
        if(commandinput.value.includes(question[i])&& !commandinput.value.includes('version') && !commandinput.value.includes("time") 
        && !commandinput.value.includes("the time") && !commandinput.value.includes("date") && !commandinput.value.includes("day") 
        && !commandinput.value.includes("you") && !commandinput.value.includes("say") && !commandinput.value.includes("weather")){
            commandoutput.value = "Searching the web for '" + commandinput.value + "'";
            window.open("https://duckduckgo.com/?q=" + commandinput.value);
        } 
    }

    for(var i = 0; i < greetings.length; i++){
        if(commandinput.value.includes(greetings[i]) && !commandinput.value.includes("this") && !commandinput.value.includes("shit") 
        && !commandinput.value.includes("something") && !commandinput.value.includes("say")){
            commandoutput.value = greetingreplies[Math.floor(Math.random() * greetingreplies.length)];
        }
    }

    for(var i = 0; i < hruprompt.length; i++){
        if(commandinput.value.includes(hruprompt[i])){
            commandoutput.value = hrureplies[Math.floor(Math.random() * hrureplies.length)];
        }
    }

    for(var i = 0; i < swears.length; i++){
        if(commandinput.value .includes(swears[i]) && !commandinput.value.includes("say")){
            commandoutput.value = swearreplies[Math.floor(Math.random() * swearreplies.length)];
        }
    }

    if(commandinput.value.includes("say") && !commandinput.value.includes("funny") && !commandinput.value.includes("joke")){
        commandoutput.value = commandinput.value.replace("say", "");
    }
    
    for(var i = 0; i < jokeprompt.length; i++){
        if(commandinput.value.includes(jokeprompt[i])){
            commandoutput.value = jokes[Math.floor(Math.random() * jokes.length)];
        } 
    }
    
    for(var i = 0; i < datetime.length; i++){
        if(commandinput.value.includes(datetime[i]) && !commandinput.value.includes(weatherpromt[i]) && !commandinput.value.includes("how are you") && !commandinput.value.includes("weather")){
            let currentDate = new Date();
            let cDay = currentDate.getDate();
            let cMonth = currentDate.getMonth() + 1;
            let cYear = currentDate.getFullYear();
            let cHour = currentDate.getHours()
            let cMin = currentDate.getMinutes();
            var ampm;

            if(cHour >= 13){
                cHour = currentDate.getHours() - 12;
                ampm = "PM";
            } else if(cHour <= 13){
                cHour = currentDate.getHours();
                ampm = "AM";
            } else if(cHour <= 0){
                cHour = 12;
            }

            if(cMin <= 9){
                cMin = "0" + currentDate.getMinutes();
            } else if(cMin >= 9){
                cMin = currentDate.getMinutes();
            }

            var cTime = cHour + ":" + cMin + " " + ampm;
            var months = [
                " ",
                "January",
                "February",
                "March",
                "April",
                "May",
                "June",
                "July",
                "August",
                "September",
                "October",
                "November",
                "December"
            ]

            commandoutput.value = "It is currently " + months[cMonth] + " " + cDay + ", " + cYear + " at " + cTime;
        }
    }

    /*for(var i = 0; i < websiteprompt.length; i++){
        if(commandinput.value.includes(websiteprompt[i])){
            var link = commandinput.value.replace(websiteprompt[i], "https://www.");
            window.open(link);
        }
    }*/

    if(commandinput.value.includes("tweet")){
        var tweet = commandinput.value.replace("tweet", "");
        commandoutput.value = "Posting" + '"' + tweet + '"';
        window.open('https://twitter.com/intent/tweet?text=' + tweet);
    }

    //Voice & TTS system
    var available_voices = window.speechSynthesis.getVoices();
    
    var english_voice = '';

    for(var i=0; i<available_voices.length; i++) {
        if(available_voices[i].lang === 'en-US') {
            english_voice = available_voices[i];
            break;
        }
    }
    if(english_voice === ''){
        english_voice = available_voices[0];
    }
    var utter = new SpeechSynthesisUtterance();
    utter.rate = 1;
    utter.pitch = 1;
    utter.text = commandoutput.value;
    utter.voice = english_voice;

    window.speechSynthesis.speak(utter);
}

function talk() {
    if (window.hasOwnProperty('webkitSpeechRecognition')) {
        var recognition = new webkitSpeechRecognition();
        var micbutt = document.getElementById('talkbutt');
        commandinput.style = 'background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3); animation-play-state: running; background-size: 1800% 1800%;';
        recognition.continuous = false;
        recognition.interimResults = false;
        recognition.lang = "en-US";
        recognition.start();
        recognition.onresult = function (e) {
            commandinput.value
                = e.results[0][0].transcript;
            recognition.stop();
            commandinput.style = 'background: rgba(0,0,0,0); animation-play-state: paused';
            scriptAI();
        };

        recognition.onerror = function (e) {
            recognition.stop();
        }

    }
}