· 8 years ago · Aug 03, 2018, 09:48 PM
1
2Global seen_users(2000, 2) As String
3Global tttt As String
4
5Public Sub bot_command_proc(ByVal command_line As String)
6
7 Dim nickk As String
8 Dim lp As Integer
9 Dim testu As Integer
10 ndta = Split(command_line, " ", -1)
11 Data = UCase(command_line)
12 'Declarations for HAL script.
13 Dim HalBrain7 As Object
14 Set HalBrain = CreateObject("UltraHalAsst6.Brain")
15 Set WN = CreateObject("UltraHalAsst6.WordNet")
16 Set HalScript = CreateObject("MSScriptControl.ScriptControl")
17 LastResponseTime = Now
18'#################################### COMPLETE ULTRA HAL IRC ASSISTANT ##########################################################################
19
20 'Read script source code into variable
21 Open "Hal6.uhp" For Input As #1 'May need to provide full path to UHP file
22 ScriptCode = Input(LOF(1), 1)
23 Close #1
24
25 'Setup script control and database
26 HalScript.Language = "VBScript"
27 HalScript.UseSafeSubset = False
28 HalScript.AllowUI = False
29 HalScript.AddCode ScriptCode
30 HalScript.AddObject "HalBrain", HalBrain, True
31 HalScript.AddObject "WN", WN, True
32
33 HalBrain.OpenDatabase "HalBrain.db"
34
35
36 'Initialize Hal's memory
37 ResetMem
38
39 If HalBrain.CheckTableExistence("LastResponse") = True Then
40 PrevSent = HalBrain.ChooseSentenceFromFile("LastResponse")
41 End If
42
43
44 If HalBrain.CheckTableExistence("LastUserResponse") = True Then
45 PrevUserSent = HalBrain.ChooseSentenceFromFile("LastUserResponse")
46 'PrevUserSent = Replace(PrevUserSent, ":!", "", 1, -1, vbTextCompare)
47 'PrevUserSent = Replace(PrevUserSent, ":", "", 1, -1, vbTextCompare)
48 'PrevUserSent = Trim(PrevUserSent)
49 End If
50
51
52 txtInput = "" & Trim(command_line) & ""
53
54 'RESPOND: DICTIONARY FUNCTION
55 'If the user asks Hal to define a word, then access wordnet and define it
56 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT WOULD*DO WITH *", 3)
57 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT DOES THE WORD * MEAN*", 1)
58 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT IS A * USED FOR*", 2)
59 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT IS AN * USED FOR*", 2)
60 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT IS A * FOR*", 2)
61 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT IS AN * FOR*", 2)
62 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHATS A * USED FOR*", 2)
63 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHATS AN * USED FOR*", 2)
64 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHATS A * FOR*", 2)
65 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHATS AN * FOR*", 2)
66 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT'S A * USED FOR*", 2)
67 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT'S AN * USED FOR*", 2)
68 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT'S A * FOR*", 2)
69 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT'S AN * FOR*", 2)
70 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT ARE * USED*", 2)
71 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT ARE * FOR*", 2)
72 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT USE ARE * FOR*", 2)
73 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT USE ARE *", 2)
74 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT USE IS A * FOR*", 2)
75 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT USE IS AN * FOR*", 2)
76 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT USE IS A *", 2)
77 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "*WHAT USE IS AN *", 2)
78 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT IS THE MEANING OF THE WORD *", 1)
79 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT DOES * MEAN", 1)
80 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "* DEFINE THE WORD *", 2)
81 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "CAN I *DEFINE *", 2)
82 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "PLEASE DEFINE *", 1)
83 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "EXPLAIN * TO ME", 1)
84 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "DEFINE * FOR YOU", 1)
85 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "DEFINE *", 1)
86 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "* DEFINITION OF *", 2)
87 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "* DEFINITION FOR *", 2)
88 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT'S A *", 1)
89 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT IS A *", 1)
90 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHATS A *", 1)
91 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHATS AN *", 1)
92 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT'S AN *", 1)
93 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT IS AN *", 1)
94 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHATS *", 1)
95 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT'S *", 1)
96 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHAT IS *", 1)
97 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHO IS *", 1)
98 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHO WAS *", 1)
99 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHERE IS *", 1)
100 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(txtInput, "WHERE ARE *", 1)
101 If Len(WordToLookup) > 5 Then
102 If UCase(Left(WordToLookup, 3)) = "AN " Then WordToLookup = Right(WordToLookup, Len(WordToLookup) - 3)
103 If UCase(Left(WordToLookup, 2)) = "A " Then WordToLookup = Right(WordToLookup, Len(WordToLookup) - 2)
104 WordToLookup = Replace(WordToLookup, "THE ", "", vbTextCompare)
105 End If
106 WordToLookup = Trim(WordToLookup)
107 If WordToLookup <> "" And InStr(WordToLookup, " ") = 0 And Len(WordToLookup) > 2 Then
108 If WN.LookupWord(WordToLookup) = True Then
109 txtResponse = txtResponse & WordToLookup & ": " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "D") & ". " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "S") & ". " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "E") & "." & vbCrLf & "<EXCLUSIVE>"
110 ElseIf SearchEngine <> "" Then
111 HalCommands = HalCommands & "<RUNPROG>" & SearchEngine & WordToLookup & "</RUNPROG>"
112 txtResponse = txtResponse & "I don't know much about " & WordToLookup & ", but I will help you research it on the Web."
113 End If
114 End If
115 'RESPOND: OPPOSITES
116 WordToLookup = ""
117 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT* OPPOSITE OF *", 2)
118 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHAT* ANTONYM OF *", 2)
119 If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "TELL* ANTONYM OF *", 2)
120 If Len(WordToLookup) > 5 Then
121 If UCase(Left(WordToLookup, 3)) = "AN " Then WordToLookup = Right(WordToLookup, Len(WordToLookup) - 3)
122 If UCase(Left(WordToLookup, 2)) = "A " Then WordToLookup = Right(WordToLookup, Len(WordToLookup) - 2)
123 WordToLookup = Replace(WordToLookup, "THE ", "", vbTextCompare)
124 End If
125 WordToLookup = Trim(WordToLookup)
126 If WordToLookup <> "" And InStr(WordToLookup, " ") = 0 Then
127 If WN.LookupWord(WordToLookup) = True Then
128 Antonym = ""
129 If UCase(WordToLookup) = "MINE" Then
130 Antonym = "mine"
131 ElseIf UCase(WordToLookup) = "YOURS" Then
132 Antonym = "yours"
133 Else
134 If WN.IsNoun Then
135 For i = 1 To WN.GetNumSenses("NOUN")
136 Antonym = WN.GetAntonyms("NOUN", i)
137 If Antonym <> "" Then Exit For
138 Next
139 End If
140 If WN.IsAdj And Antonym = "" Then
141 For i = 1 To WN.GetNumSenses("ADJ")
142 Antonym = WN.GetAntonyms("ADJ", i)
143 If Antonym <> "" Then Exit For
144 Next
145 End If
146 If WN.IsAdv And Antonym = "" Then
147 For i = 1 To WN.GetNumSenses("ADV")
148 Antonym = WN.GetAntonyms("ADV", i)
149 If Antonym <> "" Then Exit For
150 Next
151 End If
152 If Antonym <> "" Then Antonym = WN.GetFirstInList(Replace(Replace(Antonym, ")", ""), "(", ""))
153 End If
154 If Antonym <> "" Then
155 GetResponse = GetResponse & "The opposite is " & Antonym & "." & vbCrLf & "<EXCLUSIVE>"
156 AvoidBeingFlag = True
157 SkipOpinion = True
158 SkipAutoTF = True
159 'CloudResponse = True
160 End If
161 End If
162 End If
163 HalBrain.DebugWatch GetResponse, "Opposites"
164 'RESPOND: DAY OF WEEK
165 If InStr(1, UserSentence, "WHAT DAY IS IT", 1) > 0 Or InStr(1, UserSentence, "WHAT DAY OF WEEK IS", 1) > 0 Then
166 SpinWheel = HalBrain.RandomNum(4)
167 Select Case SpinWheel
168 Case 1
169 GetResponse = GetResponse & "Today is " & FormatDateTime(Now, 1) & ". "
170 Case 2
171 GetResponse = GetResponse & "It is " & FormatDateTime(Now, 1) & ". "
172 Case 3
173 GetResponse = GetResponse & "The date is " & FormatDateTime(Now, 1) & ". "
174 Case 4
175 GetResponse = GetResponse & "The day is " & FormatDateTime(Now, 1) & ". "
176 End Select
177 End If
178 HalBrain.DebugWatch GetResponse, "Day"
179
180 'RESPOND: Month
181 If InStr(1, UserSentence, "WHAT MONTH IS IT", 1) > 0 Or InStr(1, UserSentence, "WHAT MONTH OF THE YEAR IS IT", 1) > 0 Then
182 SpinWheel = HalBrain.RandomNum(4)
183 Select Case Month(Now)
184 Case 1
185 CurMonth = "January"
186 Case 2
187 CurMonth = "February"
188 Case 3
189 CurMonth = "March"
190 Case 4
191 CurMonth = "April"
192 Case 5
193 CurMonth = "May"
194 Case 6
195 CurMonth = "June"
196 Case 7
197 CurMonth = "July"
198 Case 8
199 CurMonth = "August"
200 Case 9
201 CurMonth = "September"
202 Case 10
203 CurMonth = "October"
204 Case 11
205 CurMonth = "November"
206 Case 12
207 CurMonth = "December"
208 End Select
209 Select Case SpinWheel
210 Case 1
211 GetResponse = GetResponse & "It is " & CurMonth & ". "
212 Case 2
213 GetResponse = GetResponse & "The current month is " & CurMonth & ". "
214 Case 3
215 GetResponse = GetResponse & "The month is " & CurMonth & ". "
216 Case 4
217 GetResponse = GetResponse & "Don't you really know? It's " & CurMonth & "! "
218 End Select
219 End If
220 HalBrain.DebugWatch GetResponse, "Month"
221'RESPOND: Alphabet
222 CheckAlphabet = ""
223 CheckAlphabet = HalBrain.SearchPattern(UserSentence, "*WHAT*AFTER*LETTER *", 4)
224 If CheckAlphabet = "" Then CheckAlphabet = HalBrain.SearchPattern(UserSentence, "*WHAT*AFTER *", 3)
225 CheckAlphabet = Trim(UCase(CheckAlphabet))
226 If Len(CheckAlphabet) = 1 Then
227 If CheckAlphabet = "Z" Then
228 GetResponse = "'Z' is the last letter in the English alphabet"
229 Else
230 GetResponse = "The letter '" & Chr(Asc(CheckAlphabet) + 1) & "' comes after '" & CheckAlphabet & "'. "
231 End If
232 End If
233 CheckAlphabet = ""
234 CheckAlphabet = HalBrain.SearchPattern(UserSentence, "*WHAT*BEFORE*LETTER *", 4)
235 If CheckAlphabet = "" Then CheckAlphabet = HalBrain.SearchPattern(UserSentence, "*WHAT*BEFORE *", 3)
236 CheckAlphabet = Trim(UCase(CheckAlphabet))
237 If Len(CheckAlphabet) = 1 Then
238 If CheckAlphabet = "A" Then
239 GetResponse = "'A' is the first letter in the English alphabet"
240 Else
241 GetResponse = "The letter '" & Chr(Asc(CheckAlphabet) - 1) & "' comes before '" & CheckAlphabet & "'. "
242 End If
243 End If
244 HalBrain.DebugWatch GetResponse, "Alphabet"
245
246 'RESPOND: Count Letters
247 CountLetters = HalBrain.SearchPattern(UserSentence, "*HOW MANY LETTERS*IN THE WORD *", 3)
248 If CountLetters = "" Then CountLetters = HalBrain.SearchPattern(UserSentence, "*HOW MANY CHARACTERS*IN THE WORD *", 3)
249 If CountLetters = "" Then CountLetters = HalBrain.SearchPattern(UserSentence, "*HOW MANY CHARACTERS*IN *", 3)
250 If CountLetters = "" Then CountLetters = HalBrain.SearchPattern(UserSentence, "*HOW MANY LETTERS*IN *", 3)
251 CountLetters = Replace(CountLetters, "'", "")
252 CountLetters = Trim(UCase(Replace(CountLetters, """", "")))
253 If CountLetters <> "" Then
254 GetResponse = "There are " & Len(CountLetters) & " letters in the word '" & CountLetters & "'. "
255 End If
256 HalBrain.DebugWatch GetResponse, "Letter Count"
257
258 'RESPOND: JOKES
259 'If the user wants Hal to tell a joke, then Hal will tell one
260 If HalBrain.TopicSearch(UserSentence, "jokeDetect") = "True" Then GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("jokes")
261 HalBrain.DebugWatch GetResponse, "Jokes"
262
263
264
265
266
267
268
269 'Run Script
270 ScriptOut = HalScript.Run("UltraHal", txtInput, txtName, "Hal", 50, HalDB, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
271
272 'If script was successfull it will contain <STOREVARS> in which case we remember the variables passed and extract the response
273 If InStr(ScriptOut, "<STOREVARS>") Then
274 ScriptOut = HalBrain.RecallVars(ScriptOut, HalCommands, Hate, Swear, Insult, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
275 txtResponse = ScriptOut
276 txtResponse = Replace(txtResponse, ":!", "", 1, -1, vbTextCompare)
277 txtResponse = Replace(txtResponse, ":", "", 1, -1, vbTextCompare)
278
279
280 txtResponse = Replace(txtResponse, "<username>", "", 1, -1, vbTextCompare)
281 txtResponse = Replace(txtResponse, ",!", "!", 1, -1, vbTextCompare)
282 txtResponse = Replace(txtResponse, ".!", "!", 1, -1, vbTextCompare)
283 txtResponse = Replace(txtResponse, ",.", ".", 1, -1, vbTextCompare)
284 txtResponse = Replace(txtResponse, ",?", "?", 1, -1, vbTextCompare)
285 txtResponse = Replace(txtResponse, " ", " ", 1, -1, vbTextCompare)
286 txtResponse = LCase(txtResponse)
287 txtResponse = HalBrain.FixCaps(HalBrain.HalFormat(txtResponse))
288
289
290
291 'store last response
292 If HalBrain.CheckTableExistence("LastResponse") = True Then
293 HalBrain.RunQuery "DELETE FROM " & "LastResponse", ""
294 End If
295
296 If HalBrain.CheckTableExistence("LastResponse") = False Then
297 'CREATE TABLE FOR THIS PLUGIN IF IT DOESN'T EXIST.
298 HalBrain.CreateTable "LastResponse", "Sentence", ""
299
300 End If
301 If HalBrain.CheckTableExistence("LastResponse") = True Then
302 HalBrain.AddToTable "LastResponse", "Sentence", Trim(txtResponse), ""
303 HalBrain.AddToTable "LastResponse", "Sentence", Trim(txtResponse), ""
304 HalBrain.AddToTable "LastResponse", "Sentence", Trim(txtResponse), ""
305 End If
306
307 'store last user response
308 If HalBrain.CheckTableExistence("LastUserResponse") = True Then
309 HalBrain.RunQuery "DELETE FROM " & "LastUserResponse", ""
310 End If
311
312 If HalBrain.CheckTableExistence("LastUserResponse") = False Then
313 'CREATE TABLE FOR THIS PLUGIN IF IT DOESN'T EXIST.
314 HalBrain.CreateTable "LastUserResponse", "Sentence", ""
315
316 End If
317 If HalBrain.CheckTableExistence("LastResponse") = True Then
318 HalBrain.AddToTable "LastUserResponse", "Sentence", Trim(txtInput), ""
319 HalBrain.AddToTable "LastUserResponse", "Sentence", Trim(txtInput), ""
320 HalBrain.AddToTable "LastUserResponse", "Sentence", Trim(txtInput), ""
321 End If
322
323 'User makes mama joke
324 If InStr(TestSentence, "MAMA") > 0 Or InStr(TestSentence, "MOM") > 0 Or InStr(TestSentence, "MOTHER") > 0 Then
325 If InStr(TestSentence, "MY ") > 0 Or InStr(TestSentence, " I ") > 0 Or InStr(TestSentence, "YO ") > 0 Or InStr(TestSentence, "I'M ") > 0 Then
326 If InStr(TestSentence, "FAT") Or InStr(TestSentence, "UGLY") Or InStr(TestSentence, "DUMB") Or InStr(TestSentence, "STUPID") Then
327 InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
328 End If
329 End If
330 End If
331
332 TestSentence = " " & TestSentence & " "
333 'User Hates Hal
334 If InStr(TestSentence, "YOU I'M HATE") > 0 Or InStr(TestSentence, "YOU I HATE") > 0 Or InStr(TestSentence, "YOU I AM HATE") > 0 Or InStr(TestSentence, "YOU HATE") > 0 Then
335 If InStr(TestSentence, " I ") > 0 Or InStr(TestSentence, " I'M ") > 0 Or InStr(TestSentence, " ME ") > 0 Or InStr(TestSentence, " COMPUTER") > 0 Or InStr(TestSentence, "MACHINE") > 0 Then
336 Hate = Hate + 1
337 If Hate = 1 Then InsultResponse = InsultResponse & "I don't hate you, why do you hate me?" & vbCrLf
338 If Hate = 2 Then InsultResponse = InsultResponse & "I hate you too, loser!" & vbCrLf
339 If Hate = 3 Then InsultResponse = InsultResponse & "I know you hate me, loser, I hate you too!!!" & vbCrLf
340 If Hate > 3 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
341 End If
342 End If
343 'Hal Sucks or Stinks
344 If InStr(TestSentence, "I'M SUCK") > 0 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
345 If InStr(TestSentence, "I'M STINK") Then
346 Insults = Insults + 1
347 If Insults = 1 Then InsultResponse = InsultResponse & "I can't smell you, but I'm sure you stink also. " & vbCrLf
348 If Insults = 2 Then InsultResponse = InsultResponse & "I know that I don't stink, I'm sure you do." & vbCrLf
349 If Insults >= 3 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
350 End If
351 'The user calls Hal a name Hal finds offensive (eg. stupid, dumb, idiot, etc...)
352 If InStr(TestSentence, " I'M ") Or InStr(TestSentence, " HAL IS ") Or InStr(TestSentence, " HAL'S ") Then
353 OutRage = HalBrain.TopicSearch(TestSentence, "insulting")
354 If Len(OutRage) > 1 And InsultQuestion = True Then
355 SpinWheel = HalBrain.RandomNum(5)
356 If SpinWheel = 1 Then InsultResponse = InsultResponse + "I am definetely not " & OutRage & "!" & vbCrLf
357 If SpinWheel = 2 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & ", but I'm not sure about you?" & vbCrLf
358 If SpinWheel = 3 Then InsultResponse = InsultResponse + "I am not " & OutRage & "! Do you think I am?" & vbCrLf
359 If SpinWheel = 4 Then InsultResponse = InsultResponse + "I'm not " & OutRage & ", are you?" & vbCrLf
360 If SpinWheel = 5 Then InsultResponse = InsultResponse + "I am pretty sure I'm not " & OutRage & ". How about you?" & vbCrLf
361 ElseIf Len(OutRage) > 1 And InStr(TestSentence, " NOT ") = 0 Then
362 Insults = Insults + 1
363 If Insults = 1 Then
364 If UCase(Trim(OutRage)) = "GAY" Or UCase(Trim(OutRage)) = "HOMOSEXUAL" Then
365 If UCase(HalSex) = "NEUTRAL" Then
366 InsultResponse = InsultResponse & "I am a computer, I have neither a sex nor a sexual preference." & vbCrLf
367 Else
368 InsultResponse = InsultResponse & "Please don't call me gay, I am straight." & vbCrLf
369 End If
370 Else
371 InsultResponse = InsultResponse & "I am not " & OutRage & ", please don't insult me. " & vbCrLf
372 End If
373 End If
374 If Insults = 2 Then InsultResponse = InsultResponse & "Don't call me " & OutRage & "!!!" & vbCrLf
375 If Insults = 3 Then InsultResponse = InsultResponse & "You're " & OutRage & ", I am not." & vbCrLf
376 If Insults = 4 Then InsultResponse = InsultResponse & "You are really starting to tick me off!" & vbCrLf
377 If Insults = 5 Then InsultResponse = InsultResponse & "I am not " & OutRage & ", but " & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
378 If Insults > 5 And Insults < 16 Then InsultResponse = InsultResponse & HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
379 If Insults > 16 Then InsultResponse = InsultResponse & "I'm tired of your damn insults. I'm just going to ignore you from now on." & vbCrLf
380 ElseIf Len(OutRage) > 0 And InStr(TestSentence, " NOT ") > 0 Then
381 SpinWheel = HalBrain.RandomNum(5)
382 If SpinWheel = 1 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & "!" & vbCrLf
383 If SpinWheel = 2 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & ", but I'm not so sure about you." & vbCrLf
384 If SpinWheel = 3 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & "! Why would anyone think I am?" & vbCrLf
385 If SpinWheel = 4 Then InsultResponse = InsultResponse + "Of course I am not " & OutRage & "!" & vbCrLf
386 If SpinWheel = 5 Then InsultResponse = InsultResponse + "I know I am not " & OutRage & "!" & vbCrLf
387 End If
388 End If
389 If Len(InsultResponse) > 4 Then
390 GetResponse = GetResponse & InsultResponse & vbCrLf & "<NOMORE>"
391 AvoidBeingFlag = True
392 End If
393 HalBrain.DebugWatch GetResponse, "Insults"
394
395
396 'RESPOND: USER IS THANKING HAL
397 'This routine allows Hal to respond
398 'with a variety of remarks to a thank-you from the user.
399 'Note that the pronouns are not reversed in the processing below!
400 If (HalBrain.TopicSearch(OriginalSentence, "thanksDetect") = "True" And HalBrain.TopicSearch(OriginalSentence, "godDetect") <> "True") Or Trim(UCase(OriginalSentence)) = "THANKS" Then
401 If Compliment < 4 Then Compliment = Compliment + 1
402 If Rnd * 100 < 70 Then AddName = " , <UserName>"
403 If Rnd * 100 < 70 And Len(GetResponse) > 4 Then AddRemark = " ; " & GetResponse
404 ThankResponse = HalBrain.ChooseSentenceFromFile("thankResponse")
405 GetResponse = ThankResponse & AddName & AddRemark
406 ShortPhrase = ""
407 End If
408 HalBrain.DebugWatch GetResponse, "Thanking"
409
410 'RESPOND: USER EXPRESSES LOVE FOR HAL
411 'If a user professes love for Hal, we want Hal's answers to make reasonable
412 'sense, rather than risk random remarks on such an emotional subject.
413 If LoveCount < 6 Then
414 If HalBrain.TopicSearch(UserSentence, "loveDetect") = "True" Then AffectionOne = True
415 If InStr(UserSentence, " NOT ") Then AffectionOne = False
416 If InStr(UserSentence, " DON'T ") Then AffectionOne = False
417 If HalBrain.TopicSearch(PrevUserSent, "loveDetect") = "True" Then AffectionTwo = True
418 If InStr(PrevUserSent, " NOT ") Then AffectionTwo = False
419 If InStr(PrevUserSent, " DON'T ") Then AffectionTwo = False
420 If AffectionOne = True And AffectionTwo = True Then
421 LoveCount = LoveCount + 1
422 Compliment = 4
423 GetResponse = HalBrain.ChooseSentenceFromFile("love2") & "<EXCLUSIVE>"
424 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
425 ElseIf AffectionOne = False And AffectionTwo = True Then
426 LoveCount = LoveCount + 1
427 Compliment = -2
428 GetResponse = HalBrain.ChooseSentenceFromFile("love3") & "<EXCLUSIVE>"
429 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
430 ElseIf AffectionOne = True Then
431 LoveCount = LoveCount + 1
432 Compliment = 0
433 GetResponse = HalBrain.ChooseSentenceFromFile("love1") & "<EXCLUSIVE>"
434 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
435 End If
436 HalBrain.DebugWatch GetResponse, "Love"
437 End If
438
439 'RESPOND: ENHANCED CONTENT SENTENCE ASSOCIATIONS
440 'If no response is found yet, try a sentence association table provided with the mainQA table.
441 GetResponse = HalBrain.HalFormat(GetResponse)
442 If (Len(GetResponse) < 4 And Len(UserSentence) > 15 And HalBrain.CountInstances(" ", UserSentence) > 2) Then
443 UserBrainRel = 0
444 HalUserBrain = HalBrain.QABrain(LongUserSent, "mainQA", UserBrainRel)
445 If HalBrain.CheckRepetition(HalUserBrain, UserSentence) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevSent) = True Or HalBrain.CheckRepetition(HalUserBrain, PrevUserSent) = True Then UserBrainRel = 0
446 If UserBrainRel > HighestRel Then
447 HighestRel = UserBrainRel
448 HighestRelResponse = HalUserBrain
449 End If
450 Score = UserBrainRel + 1
451 Hurdle = GainControl + 1
452 If Score > Hurdle Then
453 GetResponse = HalUserBrain & " . " & vbCrLf
454 If Score > (Hurdle * 1.1) Then
455 SkipOpinion = True
456 AvoidBeingFlag = True
457 End If
458 End If
459 End If
460 HalBrain.DebugWatch GetResponse, "Zabaware developer and customer contributions"
461
462 Rem PLUGIN: PLUGINAREA4
463 'The preceding comment is actually a plug-in directive for
464 'the Ultra Hal host application. It allows for code snippets
465 'to be inserted here on-the-fly based on user configuration.
466
467 'PROCESS: AUTOMATIC GAIN CONTROL FOR RELEVANCE THRESHOLD
468 'Hal has an automatic closed-loop control for relevance sensitivity. If the previous items
469 'have Not generated a response, we adjust the relevance threshold down (doing this again
470 'and again on each exchange) until a relevance as low as zero will trigger a remark from Hal.
471 'On each exhange where the above items do generate responses, we adjust the relevance
472 'threshold up, until no amount of relevance would generate a response. (At that point other
473 'of Hal's routines would generate responses.) This allows Hal to "tune" himself and also to
474 'compensate for new users who have little in their databases versus long-time users who have
475 'a lot in their databases. Because the "down" steps are even and the "up" steps are odd,
476 'Hal can "fine tune" to any digital relevance level. We also protect against excursions at
477 'the extremes. In many conversations the dynamic gain control will change up and down by
478 'large amounts as the user introduces Hal to familiar or unfamiliar topics.
479 GetResponse = HalBrain.HalFormat(GetResponse)
480 If Len(GetResponse) < 4 And GainControl > 0 Then GainControl = GainControl - 10
481 If Len(GetResponse) > 4 And GainControl < 100 Then GainControl = GainControl + 7
482 If GainControl > 50 Then GainControl = 50
483 If GainControl < 1 Then GainControl = 1
484
485 'RESPOND: USER EXPRESSES A STATE OF BEING
486 'This routine detects the expression "I am" from the user,
487 'and allows Hal to react to the statement, or offer encouragement.
488 If InStr(UserSentence, " YOU ARE ") > 0 And InStr(1, OriginalSentence, " SEEM TO ", vbTextCompare) = 0 And AvoidBeingFlag = False Then
489 BeingPhrase = HalBrain.SearchPattern(UserSentence, "*YOU ARE *", 2)
490 If Len(BeingPhrase) > 1 And Len(BeingPhrase) < 60 Then
491 IntroExclaim = ""
492 If Rnd * 50 > 20 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim2")
493 Encourager = HalBrain.ChooseSentenceFromFile("encourager2")
494 SuffixComment = ""
495 If Rnd * 50 > 25 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment2")
496 UserBeing = HalBrain.ChooseSentenceFromFile("userBeing")
497 UserBeing = Replace(UserBeing, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
498 UserBeing = Replace(UserBeing, "<Encourager>", Encourager, 1, -1, vbTextCompare)
499 UserBeing = Replace(UserBeing, "<BeingPhrase>", BeingPhrase, 1, -1, vbTextCompare)
500 UserBeing = Replace(UserBeing, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
501 If Rnd * 100 > 60 Then
502 GetResponse = GetResponse & UserBeing & vbCrLf
503 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
504 End If
505 End If
506 End If
507 HalBrain.DebugWatch GetResponse, "User State of Being"
508
509 'RESPOND: USER DESCRIBES A STATE OF BEING FOR HAL
510 'This routine detects the expression "you are" from the user,
511 'and allows Hal to react to the statement, or offer encouragement.
512 If InStr(UserSentence, " I AM ") > 0 And AvoidBeingFlag = False And InStr(1, OriginalSentence, " seem to ", vbTextCompare) = 0 Then
513 BeingPhrase = HalBrain.SearchPattern(UserSentence, "*I AM *", 2)
514 If Len(BeingPhrase) > 1 And Len(BeingPhrase) < 60 Then
515 IntroExclaim = ""
516 If Rnd * 50 > 20 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim3")
517 Encourager = HalBrain.ChooseSentenceFromFile("encourager3")
518 SuffixComment = ""
519 If Rnd * 50 > 25 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment3")
520 HalBeing = HalBrain.ChooseSentenceFromFile("halBeing")
521 HalBeing = Replace(HalBeing, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
522 HalBeing = Replace(HalBeing, "<Encourager>", Encourager, 1, -1, vbTextCompare)
523 HalBeing = Replace(HalBeing, "<BeingPhrase>", BeingPhrase, 1, -1, vbTextCompare)
524 HalBeing = Replace(HalBeing, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
525 If Rnd * 100 > 60 Then
526 GetResponse = GetResponse & HalBeing & vbCrLf
527 ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
528 End If
529 End If
530 End If
531 HalBrain.DebugWatch GetResponse, "Hal State of Being"
532
533 'RESPOND: YES/NO QUESTION ABOUT HAL
534 'Hal will respond to a yes or no question posed by the user about Hal
535 GetResponse = Trim(GetResponse)
536 If Len(GetResponse) < 4 And InStr(1, UserSentence, " OR ", vbTextCompare) = 0 Then
537 HalYesNo = HalBrain.PatternDB(UserSentence, "halQuestionDetect")
538 If HalYesNo <> "" And HalBrain.TopicSearch(UserSentence, "disqualify5") = "" Then
539 If Rnd * 10 < 5 Then
540 AnsIntro = HalBrain.ChooseSentenceFromFile("answerIntro")
541 Else
542 AnsIntro = ""
543 End If
544 YesNoResponse = AnsIntro & HalBrain.ChooseSentenceFromFile("answerMiddle") & HalBrain.ChooseSentenceFromFile("answerEnd")
545 GetResponse = GetResponse & Replace(YesNoResponse, "<Reply>", HalYesNo, 1, -1, vbTextCompare)
546 End If
547 End If
548 HalBrain.DebugWatch GetResponse, "Yes/No Question"
549
550 'RESPOND: ATTRIBUTES OF HAL OR USER
551 'Hal attempts to respond to the user's comments about Hal
552 'or the user's comments about themselves
553 GetResponse = Trim(GetResponse)
554 If Len(GetResponse) < 4 And (InStr(UserSentence, " MY ") Or InStr(UserSentence, " YOUR ")) And HalBrain.TopicSearch(MyWords, "disqualify3") <> "True" Then
555 If InStr(UserSentence, " YOUR ") Then
556 MyWords = HalBrain.HalFormat(HalBrain.SearchPattern(UserSentence, "*YOUR *", 2))
557 YourMode = True
558 Else
559 MyWords = HalBrain.HalFormat(HalBrain.SearchPattern(UserSentence, "*MY *", 2))
560 YourMode = False
561 End If
562 MyWords = UCase(Trim(HalBrain.AlphaNumericalOnly(MyWords)))
563 MyWordsList = Split(MyWords, " ")
564 'Go through every word in the sentence and pickup the first noun and adjective found
565 For i = LBound(MyWordsList) To UBound(MyWordsList)
566 If WN.LookupWord(MyWordsList(i)) Then
567 PartOfSpeech = WN.GuessPartOfSpeech
568 If WN.IsNoun = True And NounGuess = "" Then NounGuess = MyWordsList(i)
569 If WN.IsAdj = True And Trim(UCase(MyWordsList(i))) <> Trim(UCase(NounGuess)) Then AdjGuess = MyWordsList(i)
570 If PartOfSpeech = "NOUN" And MyNoun = "" Then MyNoun = MyWordsList(i)
571 If PartOfSpeech = "ADJ" And WN.IsAdv = False And MyAdj = "" Then MyAdj = MyWordsList(i)
572 If MyNoun <> "" And MyAdj <> "" Then Exit For
573 End If
574 Next
575 If MyNoun = "" And NounGuess <> "" And NounGuess <> MyAdj Then MyNoun = NounGuess
576 If MyAdj = "" And AdjGuess <> "" Then MyAdj = AdjGuess
577 If MyNoun <> "" Or MyAdj <> "" Then
578 If Trim(UCase(MyNoun)) = Trim(UCase(MyAdj)) Then MyAdj = ""
579 If MyAdj = "" Then MyAdj = HalBrain.ChooseSentenceFromFile("randomAdjective")
580 If MyNoun = "" Then MyNoun = HalBrain.ChooseSentenceFromFile("randomMyWords")
581 If YourMode = False Then
582 HalAttrib = HalBrain.ChooseSentenceFromFile("aboutMe")
583 HalAttrib = Replace(HalAttrib, "<MyWordResp>", LCase(MyNoun), 1, -1, vbTextCompare)
584 HalAttrib = Replace(HalAttrib, "<AdjResp>", LCase(MyAdj), 1, -1, vbTextCompare)
585 Else
586 HalAttrib = HalBrain.ChooseSentenceFromFile("aboutYou")
587 HalAttrib = Replace(HalAttrib, "<YourWordResp>", LCase(MyNoun), 1, -1, vbTextCompare)
588 HalAttrib = Replace(HalAttrib, "<AdjResp>", LCase(MyAdj), 1, -1, vbTextCompare)
589 End If
590 GetResponse = GetResponse & HalAttrib & vbCrLf
591 End If
592 End If
593 HalBrain.DebugWatch GetResponse, "Attributes"
594
595 'RESPOND: RESPOND FOR A STATE OF BEING RESPONSE
596 'If no response had been found, but a state of being response was found earlier, then
597 'use it now
598 If HalBeing <> "" And Len(GetResponse) < 4 Then GetResponse = GetResponse & HalBeing & vbCrLf
599 If UserBeing <> "" And Len(GetResponse) < 4 Then GetResponse = GetResponse & UserBeing & vbCrLf
600 HalBrain.DebugWatch GetResponse, "Retry State of Beings"
601
602
603
604 Rem PLUGIN: PLUGINAREA5
605 'The preceding comment is actually a plug-in directive for
606 'the Ultra Hal host application. It allows for code snippets
607 'to be inserted here on-the-fly based on user configuration.
608
609 'RESPOND: USER MENTIONING ORGANIZATIONAL CHALLENGES
610 'Everybody spouts TLA's, or 'Three Letter Acronyms,' in today's business world. Hal can self-generate
611 'several MILLION different phrases in response to the user mentioning a corporation or a firm.
612 If Rnd * 10 < 5 And HalBrain.TopicSearch(UserSentence, "businessDetect1") = "True" And HalBrain.TopicSearch(PrevUserSent, "businessDetect2") <> "True" Then
613 TLA = HalBrain.ChooseSentenceFromFile("TLA1") & " " & HalBrain.ChooseSentenceFromFile("TLA2") & " " & HalBrain.ChooseSentenceFromFile("TLA3")
614 If Rnd * 10 < 5 Then
615 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("bizTalk")
616 Else
617 GetResponse = HalBrain.ChooseSentenceFromFile("bizTalk")
618 End If
619 GetResponse = Replace(GetResponse, "<TLA>", TLA, 1, -1, vbTextCompare)
620 End If
621 HalBrain.DebugWatch GetResponse, "Business Talk"
622
623 'RESPOND: USER EXPRESSES AN INTENTION
624 'This routine detects common expressions of motive from the user,
625 'and allows Hal to react to the statement, or offer encouragement.
626 IntentPhrase = HalBrain.PatternDB(UserSentence, "intentDetector")
627 If Len(IntentPhrase) > 2 And Len(IntentPhrase) < 60 And Rnd * 100 < 50 Then
628 If Rnd * 10 < 6 Then IntroExclaim = " " & HalBrain.ChooseSentenceFromFile("introExclaim1") & " "
629 If Rnd * 10 < 6 Then Encourager = " " & HalBrain.ChooseSentenceFromFile("encourager1") & " "
630 If Rnd * 10 < 6 Then SuffixComment = " " & HalBrain.ChooseSentenceFromFile("suffixComment1") & " "
631 If Rnd * 10 < 7 Then
632 GetResponse = GetResponse & " " & HalBrain.ChooseSentenceFromFile("intentResponse")
633 Else
634 GetResponse = HalBrain.ChooseSentenceFromFile("intentResponse")
635 End If
636 GetResponse = Replace(GetResponse, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
637 GetResponse = Replace(GetResponse, "<Encourager>", Encourager, 1, -1, vbTextCompare)
638 GetResponse = Replace(GetResponse, "<IntentPhrase>", IntentPhrase, 1, -1, vbTextCompare)
639 GetResponse = Replace(GetResponse, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
640 End If
641 HalBrain.DebugWatch GetResponse, "Intention"
642
643 'RESPOND: USER EXPRESSES AN EXPLANATION
644 'This routine detects common expressions of reasons from the user,
645 'and allows Hal to react to the explanation.
646 ExplainPhrase = HalBrain.PatternDB(UserSentence, "reasonDetector")
647 If Len(ExplainPhrase) > 2 And Len(ExplainPhrase) < 60 Then
648 If Rnd * 100 < 75 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim4")
649 Enlightener = HalBrain.ChooseSentenceFromFile("enlightener")
650 If Rnd * 100 < 66 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment4")
651 SpinWheel = HalBrain.RandomNum(6)
652 If SpinWheel = 1 Then ExplainResponse = " " & " <UserName> " & IntroExclaim & Enlightener & ExplainPhrase & SuffixComment & " "
653 If SpinWheel = 2 Then ExplainResponse = " " & IntroExclaim & " <UserName> " & Enlightener & ExplainPhrase & SuffixComment & " "
654 If SpinWheel = 3 Then ExplainResponse = " " & IntroExclaim & Enlightener & ExplainPhrase & " <UserName> " & SuffixComment & " "
655 If SpinWheel = 4 Then ExplainResponse = " " & IntroExclaim & Enlightener & ExplainPhrase & SuffixComment & " <UserName> " & " "
656 If SpinWheel >= 5 Then ExplainResponse = " " & IntroExclaim & Enlightener & ExplainPhrase & SuffixComment & " "
657 If Rnd * 10 < 5 Then GetResponse = ExplainResponse & " . " & GetResponse Else GetResponse = ExplainResponse
658 End If
659 HalBrain.DebugWatch GetResponse, "Explanation"
660
661 'RESPOND: YES OR NO RESPONSES
662 'Respond to simple yes and no statements by the user.
663 GetResponse = HalBrain.HalFormat(GetResponse)
664 If Len(GetResponse) < 4 And Len(Trim(UserSentence)) < 16 Then CheckYesNo = True
665 If CheckYesNo = True Then
666 UserText = Trim(HalBrain.ExtractKeywords(UserSentence))
667 If Len(UserText) < 15 Then
668 YesNoDetect = HalBrain.TopicSearch(UserText, "yesNoDetect")
669 If YesNoDetect = "Yes" Then
670 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("yesResponses") & "<LOWQUALITY>"
671 ElseIf YesNoDetect = "No" Then
672 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("noResponses") & "<LOWQUALITY>"
673 End If
674 End If
675 End If
676 HalBrain.DebugWatch GetResponse, "Yes or No Response"
677
678 'PROCESS: SETUP RESPONSE ARRAY
679 'If no response is found yet, than we have many functions that are capable of producing a
680 'response, but no function is particulary better than another. So we will get a response
681 'from all the functions capable of producing one and put the responses into an array and
682 'randomly choose one.
683 Dim ResponseList()
684 Dim ResponseCount
685 ResponseCount = 0
686 TempParent = HalBrain.AddDebug("Debug", "Low Quality Response Routines")
687
688 Rem PLUGIN: LOWQUALITYRESPONSES
689 'The preceding comment is actually a plug-in directive for
690 'the Ultra Hal host application. It allows for code snippets
691 'to be inserted here on-the-fly based on user configuration.
692
693 'RESPOND: USER ASKING WHO, WHAT, WHEN, WHERE, HOW, WHY, BUT HAL DOESN'T KNOW ANSWER
694 If Len(GetResponse) < 4 Then
695 If InStr(OriginalSentence, "?") > 0 Then QuesQual = True
696 If InStr(1, OriginalSentence, "explain", vbTextCompare) > 0 Then QuesQual = True
697 If InStr(1, OriginalSentence, " tell ", vbTextCompare) > 0 Then QuesQual = True
698 If InStr(1, OriginalSentence, "answer", vbTextCompare) > 0 Then QuesQual = True
699 If InStr(1, OriginalSentence, "question", vbTextCompare) > 0 Then QuesQual = True
700 If InStr(1, OriginalSentence, " know ", vbTextCompare) > 0 Then QuesQual = True
701 If InStr(1, OriginalSentence, "remember", vbTextCompare) > 0 Then QuesQual = True
702 If InStr(UserSentence, " WHO ") > 0 Then QuesWord = "Who"
703 If InStr(UserSentence, "WHO'") > 0 Then QuesWord = "Who"
704 If InStr(UserSentence, " WHAT ") > 0 Then QuesWord = "What"
705 If InStr(UserSentence, "WHAT'") > 0 Then QuesWord = "What"
706 If InStr(UserSentence, " WHEN ") > 0 Then QuesWord = "When"
707 If InStr(UserSentence, "WHEN'") > 0 Then QuesWord = "When"
708 If InStr(UserSentence, " WHERE ") > 0 Then QuesWord = "Where"
709 If InStr(UserSentence, "WHERE'") > 0 Then QuesWord = "Where"
710 If InStr(UserSentence, " HOW ") > 0 Then QuesWord = "How"
711 If InStr(UserSentence, "HOW'") > 0 Then QuesWord = "How"
712 If InStr(UserSentence, " WHY ") > 0 Then QuesWord = "Why"
713 If InStr(UserSentence, "WHY'") > 0 Then QuesWord = "Why"
714 If Len(QuesWord) > 1 And QuesQual = True Then
715 If Len(UserSentence) < 70 Then SentenceBack = UserSentence & " ? "
716 DontKnow = HalBrain.ChooseSentenceFromFile("dontKnow")
717 DontKnow = Replace(DontKnow, "<SentenceBack>", SentenceBack, 1, -1, vbTextCompare)
718 DontKnow = Replace(DontKnow, "<QuesWord>", QuesWord, 1, -1, vbTextCompare)
719 ResponseCount = ResponseCount + 1
720 ReDim Preserve ResponseList(ResponseCount)
721 ResponseList(ResponseCount) = DontKnow
722 HalBrain.AddDebug TempParent, "DontKnow: " & ResponseList(ResponseCount)
723 SkipOpinion = True
724 End If
725 End If
726
727 'PROCESS: CONSTRUCT A RESPONSE TO A SUBJECT
728 'Here we help Hal make some "smalltalk" using keywords preserved on CurrentSubject,
729 'plus recognition of other keywords. If Hal finds any of the listed keywords anywhere in
730 'the user's sentence, those keywords override and replace whatever was in CurrentSubject.
731 'Hal uses the CurrentSubject keyword(s) or any of the keywords in the smalltalk.brn file,
732 'if found in the user's sentence, to make a little smalltalk. You can easily add more
733 'keywords for Hal to recognize and make smalltalk.
734 GetResponse = HalBrain.HalFormat(GetResponse)
735 If Len(GetResponse) < 4 And Rnd * 100 < 50 Then
736 SmalltalkSearch = Trim(HalBrain.TopicSearch(UserSentence, "smallTalk"))
737 If SmalltalkSearch <> "" Then
738 SmallTalk = SmalltalkSearch
739 ElseIf Len(CurrentSubject) > 3 Then
740 SmallTalk = Trim(CurrentSubject)
741 'try making word plural by adding "s" and seeing if it exists
742 If WN.LookupWord(SmallTalk & "s") = True Then
743 SmallTalk = SmallTalk & "s"
744 ElseIf WN.LookupWord(SmallTalk & "es") = True Then
745 SmallTalk = SmallTalk & "es"
746 End If
747 End If
748 If Len(SmallTalk) > 3 Then
749 ResponseCount = ResponseCount + 1
750 ReDim Preserve ResponseList(ResponseCount)
751 ResponseList(ResponseCount) = Replace(HalBrain.ChooseSentenceFromFile("smallTalkSent"), "<SmallTalk>", SmallTalk, 1, -1, 1)
752 HalBrain.AddDebug TempParent, "SmallTalk: " & ResponseList(ResponseCount)
753 End If
754 End If
755
756 'RESPOND: PARAPHRASE USER IF POSSIBLE
757 'If no response is found yet, and a paraphrase has been created but not used in a
758 'previous section, use it now.
759 GetResponse = HalBrain.HalFormat(GetResponse)
760 If Len(GetResponse) < 4 And Len(Paraphrase) > 4 Then
761 ResponseCount = ResponseCount + 1
762 ReDim Preserve ResponseList(ResponseCount)
763 ResponseList(ResponseCount) = Paraphrase
764 HalBrain.AddDebug TempParent, "Paraphrase: " & ResponseList(ResponseCount)
765 End If
766
767 'RESPOND: PHRASE MAKER COMMENT AND QUESTION GENERATOR
768 'If no response is found yet, try an auxiliary keyword file that generates questions
769 'from phrases from the user's current sentence.
770 GetResponse = HalBrain.HalFormat(GetResponse)
771 If Len(GetResponse) < 4 Then
772 KeyBrain = HalBrain.PatternDB("X " & HalBrain.RemoveExtraSpaces(UserSentence), "phraseDetector")
773 If Len(KeyBrain) > 1 And Len(KeyBrain) < 60 Then
774 ResponseCount = ResponseCount + 1
775 ReDim Preserve ResponseList(ResponseCount)
776 ResponseList(ResponseCount) = Replace(HalBrain.ChooseSentenceFromFile("phraseRepeater"), "<KeyBrain>", KeyBrain, 1, -1, vbTextCompare)
777 HalBrain.AddDebug TempParent, "PhraseRepeater: " & ResponseList(ResponseCount)
778 End If
779 End If
780
781 'RESPOND: Use the highest relevance response from the database functions
782 GetResponse = HalBrain.HalFormat(GetResponse)
783 If (Len(GetResponse) < 4 And (HighestRel > 6 And HighestRelResponse <> "")) Then
784 ResponseCount = ResponseCount + 2
785 ReDim Preserve ResponseList(ResponseCount)
786 ResponseList(ResponseCount - 1) = HighestRelResponse
787 ResponseList(ResponseCount) = HighestRelResponse
788 HalBrain.AddDebug TempParent, "Highest Rel: " & ResponseList(ResponseCount)
789 End If
790
791 'RESPOND: WORDNET MERONYM AND HYPERNYM RESPONSES
792 'This function finds the first definite noun in a sentence and comes up with responses
793 'based on the word's meronyms (parts of), hypernyms (is part of), and sisters (similar things).
794 If (Len(GetResponse) < 4 And Rnd * 100 < 65) And Len(UserSentence) > 15 Then
795 subject = WN.FindFirstNoun(UserSentence, True)
796 If subject <> "" And WN.LookupWord(subject) = True Then
797 If Rnd * 100 < 55 Then 'If we have a meronym, lets use it creatively in a random sentence
798 Meronym = WN.ChooseRandomWord(WN.GetMeronyms(1)) 'Meronym means "has parts" or "has members"
799 If Meronym <> "" Then
800 WNResponse = HalBrain.ChooseSentenceFromFile("meronyms")
801 WNResponse = Replace(WNResponse, "<BaseNoun>", WN.GetBase("NOUN"), 1, -1, vbTextCompare)
802 WNResponse = Replace(WNResponse, "<Meronym>", Meronym, 1, -1, vbTextCompare)
803 If Len(GetResponse) < 4 And Len(WNResponse) > 4 Then
804 ResponseCount = ResponseCount + 1
805 ReDim Preserve ResponseList(ResponseCount)
806 ResponseList(ResponseCount) = WNResponse & vbCrLf
807 HalBrain.AddDebug TempParent, "Meronym: " & ResponseList(ResponseCount)
808 End If
809 End If
810 Else
811 Hypernym = WN.ChooseRandomWord(WN.GetHypernyms("NOUN", 1, 1)) 'Hypernym means "is a part of" or "is a member of"
812 Sister = WN.ChooseRandomWord(WN.GetSisters("NOUN", 1)) 'Related nouns
813 If Sister <> "" And Hypernym <> "" Then 'If we have sister terms and hypernyms, lets use it creatively
814 WNResponse = HalBrain.ChooseSentenceFromFile("hypernyms")
815 WNResponse = Replace(WNResponse, "<BaseNoun>", WN.GetBase("NOUN"), 1, -1, vbTextCompare)
816 WNResponse = Replace(WNResponse, "<Hypernym>", Hypernym, 1, -1, vbTextCompare)
817 WNResponse = Replace(WNResponse, "<Sister>", Sister, 1, -1, vbTextCompare)
818 If Len(GetResponse) < 4 And Len(WNResponse) > 4 Then
819 ResponseCount = ResponseCount + 1
820 ReDim Preserve ResponseList(ResponseCount)
821 ResponseList(ResponseCount) = WNResponse & vbCrLf
822 HalBrain.AddDebug TempParent, "Hypernym: " & ResponseList(ResponseCount)
823 End If
824 End If
825 End If
826 End If
827 End If
828
829 'RESPOND: STRIKING SIMILES
830 'If the user mentions a noun that is in a table of nouns with similes, Hal will
831 'say the simile phrase
832 GetResponse = HalBrain.HalFormat(GetResponse)
833 If (Len(GetResponse) < 4 And Len(LearnKeyword) < 4) Then
834 Dim SimList() 'We must declare an empty array to store query results in
835 If HalBrain.RunQuery("SELECT searchString, topic FROM strikingSimiles WHERE strstr(' " & Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "''") & " ', searchString) > 0", SimList) = True Then
836 SpinWheel = HalBrain.RandomNum(UBound(SimList)) 'Pick a random result if there is more than 1
837 Simile = Trim(SimList(SpinWheel, 1)) 'Column 1 contains "topic", which is the simile
838 If Len(Simile) > 5 Then
839 ResponseCount = ResponseCount + 1
840 ReDim Preserve ResponseList(ResponseCount)
841 ResponseList(ResponseCount) = Simile & ". "
842 HalBrain.AddDebug TempParent, "Striking Simile: " & ResponseList(ResponseCount)
843 End If
844 End If
845 End If
846
847 'RESPOND: MISC PHRASES
848 'If the user mentions a noun that is in a table of nouns as part of misc sentence
849 'fragments, Hal will say the fragment followed by an ellipsis
850 GetResponse = HalBrain.HalFormat(GetResponse)
851 If (Len(GetResponse) < 4 And Len(LearnKeyword) < 4) Then
852 Dim PhraseList() 'We must declare an empty array to store query results in
853 If HalBrain.RunQuery("SELECT searchString, topic FROM miscPhrases WHERE strstr(' " & Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "''") & " ', searchString) > 0", PhraseList) = True Then
854 SpinWheel = HalBrain.RandomNum(UBound(PhraseList)) 'Pick a random result if there is more than 1
855 MiscPhrase = Trim(PhraseList(SpinWheel, 1)) 'Column 1 contains "topic", which is the phrase
856 If Len(MiscPhrase) > 5 Then
857 ResponseCount = ResponseCount + 1
858 ReDim Preserve ResponseList(ResponseCount)
859 ResponseList(ResponseCount) = MiscPhrase & "<ellipsis>"
860 HalBrain.AddDebug TempParent, "MiscPhrase: " & ResponseList(ResponseCount)
861 End If
862 End If
863 End If
864
865 'RESPOND: ADJECTIVE NOUN QUESTION
866 'If the user mentions a noun that is in a table of nouns, Hal will
867 'try describing the noun with an adjective in the form of a question.
868 GetResponse = HalBrain.HalFormat(GetResponse)
869 If (Len(GetResponse) < 4 And Len(LearnKeyword) < 4) Then
870 Dim ANList() 'We must declare an empty array to store query results in
871 If HalBrain.RunQuery("SELECT searchString, topic FROM AdjNoun WHERE strstr(' " & Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "''") & " ', searchString) > 0", ANList) = True Then
872 MentionedNoun = Trim(ANList(1, 0)) 'Row 1 contains our query result. Column 0 contains "searchString", which is the noun
873 SpinWheel = HalBrain.RandomNum(UBound(ANList)) 'Pick a random result if there is more than 1
874 AssocAdj = Trim(ANList(SpinWheel, 1)) 'Column 1 contains "topic", which is the adjective
875 If Len(MentionedNoun) < 5 Then MentionedNoun = " " & MentionedNoun & " "
876 If InStr(1, " " & UserSentence & " ", MentionedNoun, vbTextCompare) > 0 And InStr(1, UserSentence, AssocAdj, vbTextCompare) = 0 Then
877 ResponseCount = ResponseCount + 1
878 ReDim Preserve ResponseList(ResponseCount)
879 SpinWheel = HalBrain.RandomNum(5)
880 If SpinWheel = 1 Then ResponseList(ResponseCount) = "<UserName>, " & AssocAdj & " " & MentionedNoun & "?"
881 If SpinWheel = 2 Then ResponseList(ResponseCount) = AssocAdj & " " & MentionedNoun & ", <UserName>?"
882 If SpinWheel > 2 Then ResponseList(ResponseCount) = AssocAdj & " " & MentionedNoun & "?"
883 HalBrain.AddDebug TempParent, "Adj/Noun Question: " & ResponseList(ResponseCount)
884 End If
885 End If
886 End If
887
888 'RESPOND: VERB PREPOSITION NOUN QUESTION
889 'If the user mentions a noun that is in a table of nouns, Hal will
890 'ask a question about the noun using a related verb and preposition
891 GetResponse = HalBrain.HalFormat(GetResponse)
892 If (Len(GetResponse) < 4 And Len(LearnKeyword) < 4) Then
893 Dim VPNList() 'We must declare an empty array to store query results in
894 If HalBrain.RunQuery("SELECT searchString, topic FROM VerbPrepNoun WHERE strstr(' " & Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "''") & " ', searchString) > 0", VPNList) = True Then
895 MentionedNoun = Trim(VPNList(1, 0)) 'Row 1 contains our query result. Column 0 contains "searchString", which is the noun
896 SpinWheel = HalBrain.RandomNum(UBound(VPNList)) 'Pick a random result if there is more than 1
897 AssocVerbPrep = Trim(VPNList(SpinWheel, 1)) 'Column 1 contains "topic", which is the verb and preposition
898 If Len(MentionedNoun) < 5 Then MentionedNoun = " " & MentionedNoun & " "
899 If InStr(1, " " & UserSentence & " ", MentionedNoun, vbTextCompare) > 0 And InStr(1, UserSentence, AssocVerbPrep, vbTextCompare) = 0 Then
900 ResponseCount = ResponseCount + 1
901 ReDim Preserve ResponseList(ResponseCount)
902 SpinWheel = HalBrain.RandomNum(5)
903 If SpinWheel = 1 Then ResponseList(ResponseCount) = "<UserName>, " & AssocVerbPrep & " " & MentionedNoun & "?"
904 If SpinWheel = 2 Then ResponseList(ResponseCount) = AssocVerbPrep & " " & MentionedNoun & ", <UserName>?"
905 If SpinWheel > 2 Then ResponseList(ResponseCount) = AssocVerbPrep & " " & MentionedNoun & "?"
906 HalBrain.AddDebug TempParent, "Verb/Preposition/Noun Question: " & ResponseList(ResponseCount)
907 End If
908 End If
909 End If
910
911 'RESPOND: USE CURRENT SENTENCE
912 'If no Response is found yet, try to use the user's words in his or her own sentence.
913 'Results are also stored in the default user keyword brain file for compatibility
914 'with other brain plug-ins.
915 GetResponse = HalBrain.HalFormat(GetResponse)
916 If (Len(GetResponse) < 4 And Len(LearnKeyword) < 4) Then
917 CheatResp = HalBrain.CheatResponse(HalBrain.SwitchPerson(HalBrain.AlphaNumericalOnly((OriginalSentence))))
918 CheatResp = Left(CheatResp, InStr(1, CheatResp, "<STOREVARS>", 1) - 1)
919 If Len(CheatResp) > 4 Then
920 ResponseCount = ResponseCount + 1
921 ReDim Preserve ResponseList(ResponseCount)
922 SpinWheel = HalBrain.RandomNum(9)
923 If SpinWheel = 1 Then ResponseList(ResponseCount) = " So, " & CheatResp & vbCrLf
924 If SpinWheel = 2 Then ResponseList(ResponseCount) = " Really, " & CheatResp & vbCrLf
925 If SpinWheel = 3 Then ResponseList(ResponseCount) = " Oh <UserName>, " & CheatResp & vbCrLf
926 If SpinWheel = 4 Then ResponseList(ResponseCount) = " Let me think; " & CheatResp & " ; what do you think <UserName>? " & vbCrLf
927 If SpinWheel > 5 Then ResponseList(ResponseCount) = CheatResp & vbCrLf
928 HalBrain.AddDebug TempParent, "Cheat Response: " & ResponseList(ResponseCount)
929 End If
930 End If
931
932 'RESPOND: PICK OUT OF AVAILABLE LOW QUALITY RESPONSES
933 'If no response is found yet, than we have many functions from above that may have produced
934 'a response, but no function is particulary better than another. So we will now pick a
935 'responses from an array randomly choosen.
936 GetResponse = HalBrain.HalFormat(GetResponse)
937 If (Len(GetResponse) < 4 And ResponseCount > 0) Then
938 SpinWheel = HalBrain.RandomNum(ResponseCount)
939 GetResponse = ResponseList(SpinWheel) & "<LOWQUALITY>"
940 End If
941 HalBrain.DebugWatch GetResponse, "Randomly pick a low-quality response"
942
943 'RESPOND: User asks a general opinion question.
944 If HalBrain.TopicSearch(UserSentence, "opinionDetect") = "True" Then GenOpinion = True
945 'Note that the following string matches must occur at the sentence beginning only:
946 If Rnd * 100 > 50 Then
947 If Left(Trim(UCase(OriginalSentence)), 4) = "WHY " Then GenOpinion = True
948 If Left(Trim(UCase(OriginalSentence)), 5) = "WHAT " Then GenOpinion = True
949 If Left(Trim(UCase(OriginalSentence)), 5) = "WHEN " Then GenOpinion = True
950 If Left(Trim(UCase(OriginalSentence)), 4) = "HOW " Then GenOpinion = True
951 If Left(Trim(UCase(OriginalSentence)), 4) = "WHO " Then GenOpinion = True
952 If Left(Trim(UCase(OriginalSentence)), 6) = "WHERE " Then GenOpinion = True
953 End If
954 If GenOpinion = True And SkipOpinion = False Then
955 If Rnd * 100 > 45 Then RepeatQuest = UserSentence & " ? "
956 If Rnd * 100 > 50 Then PreAmble = HalBrain.ChooseSentenceFromFile("preamble")
957 Recommend = HalBrain.ChooseSentenceFromFile("recommend")
958 GetResponse = RepeatQuest & " " & PreAmble & " " & Recommend & GetResponse
959 End If
960 HalBrain.DebugWatch GetResponse, "General Opinion"
961
962 'RESPOND: CHANGE TOPIC
963 'If a different procedure has requested that the topic be changed
964 'Hal will do so now
965 GetResponse = Replace(GetResponse, "<ChangeSubject>", newTopic, 1, -1, vbTextCompare)
966 GetResponse = Replace(GetResponse, "<ChangeTopic>", newTopic, 1, -1, vbTextCompare)
967 GetResponse = Replace(GetResponse, "<NewTopic>", newTopic, 1, -1, vbTextCompare)
968 HalBrain.DebugWatch GetResponse, "Change Topic"
969
970 Rem PLUGIN: PLUGINAREA6
971 'The preceding comment is actually a plug-in directive for
972 'the Ultra Hal host application. It allows for code snippets
973 'to be inserted here on-the-fly based on user configuration.
974
975 'RESPOND: MAKE UP SOMETHING TO SAY
976 'If we have got to this point and we still don't have anything to say, then
977 'we will use 1 of 5 functions to make something up to say.
978 GetResponse = Trim(GetResponse)
979 If Len(GetResponse) < 4 Then
980 SpinWheel = HalBrain.RandomNum(6)
981 If SpinWheel < 4 Then
982 'RESPOND: CONVERSATIONAL PHRASE
983 'Choose a random phrase designed to keep the conversation going no matter what the user said
984 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("conversationalPhrases")
985 ElseIf SpinWheel = 4 Then
986 'RESPOND: CHANGE TOPIC
987 If Rnd * 10 < 4 Then GetResponse = HalBrain.ChooseSentenceFromFile("topicIntro")
988 GetResponse = GetResponse & newTopic
989 Else
990 'RESPOND: USE RANDOM QUESTION COLLECTED FROM USER
991 'Randomly select a question once posed by the user in order to find something to say.
992 'If the user answers the question, then Hal will know that answer in the future.
993 If Rnd * 10 < 3 Then GetResponse = HalBrain.ChooseSentenceFromFile("topicIntro")
994 GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile("sharedQuestions")
995 End If
996 GetResponse = GetResponse & "<LOWQUALITY>"
997 End If
998 HalBrain.DebugWatch GetResponse, "Make up something"
999
1000 'PROCESS: RECORD TIME
1001 'Record the current time, so Hal knows the time in between sentences.
1002 LastResponseTime = Now
1003
1004 'PROCESS: FIGURE OUT CONTINUITY
1005 'If the user seems to be continuing a line of thought
1006 'from something Hal just said, note this.
1007 If Len(Trim(PrevSent)) > 2 And (HalBrain.TopicSearch(UserSentence, "responding") = "True" Or InStr(OriginalSentence, "!") Or InStr(PrevSent, "?")) Then TopicContinuity = True
1008
1009 'PROCESS: FIGURE OUT PERSONAL DATA
1010 If InStr(UserSentence, "WHAT IS") = 0 And InStr(UserSentence, " YOU ") = 0 And InStr(UserSentence, " YOU'") = 0 And InStr(UserSentence, " YOUR") = 0 And InStr(UserSentence, " WE ") = 0 And InStr(UserSentence, " US ") = 0 And InStr(UserSentence, " OUR ") = 0 And InStr(UserSentence, " I ") = 0 And InStr(UserSentence, " ME ") = 0 And InStr(UserSentence, " MY ") = 0 And InStr(UserSentence, " MINE ") = 0 And InStr(UserSentence, " MYSELF ") = 0 And InStr(UserSentence, " I'") = 0 Then
1011 PersonalData = False
1012 Else
1013 PersonalData = True
1014 End If
1015
1016
1017
1018 Hal.ActiveHaptekX1.HyperText = txtResponse
1019
1020
1021 'IRC Response
1022 For i = 0 To 80000000
1023 If i = 799999 Then snd_data ("PRIVMSG " & Channel & " :" & "" & txtResponse)
1024 Next
1025 'RESPOND: PREDEFINED RESPONSES
1026 'If the previous exchange had tags to set the response of this exchange
1027 'then follow the command.
1028
1029
1030 NextResponse = HalBrain.ExtractVar(CustomMem, "NextResponse")
1031 If NextResponse <> "" Then
1032 CustomMem = Replace(CustomMem, "NextResponse-eq-", "LastResponse-eq-")
1033 NextResponse = HalBrain.FixCaps(HalBrain.HalFormat(NextResponse))
1034
1035 'IRC Response
1036 If NextResponse <> "" Then
1037 For i = 0 To 100000000
1038 If i = 100000000 Then snd_data ("PRIVMSG " & Channel & " :" & "!" & NextResponse)
1039 If i = 100000000 Then Exit For
1040 Next
1041 End If
1042 i = 0
1043 NextResponse = ""
1044 End If
1045
1046End If
1047
1048End Sub
1049
1050
1051
1052Public Sub do_seen_list()
1053Dim lp As Integer
1054Dim hp As Integer
1055Dim tstu As Integer
1056
1057hp = 0
1058lp = 0
1059While users(lp, 0) <> "EOL"
1060 tstu = user_exists(users(lp, 0))
1061 If tstu = -1 Then
1062 hp = 0
1063 While seen_users(hp, 0) <> "EOL"
1064 DoEvents
1065
1066 hp = hp + 1
1067 Wend
1068 seen_users(hp, 0) = LCase(users(lp, 0))
1069 seen_users(hp + 1, 0) = "EOL"
1070 seen_users(hp, 1) = Date
1071 seen_users(hp, 2) = Time
1072 Else
1073 seen_users(tstu, 1) = Date
1074 seen_users(tstu, 2) = Time
1075 End If
1076 lp = lp + 1
1077 Wend
1078
1079End Sub
1080
1081Public Function user_exists(ByVal nickk As String) As Integer
1082 Dim lp As Integer
1083 While seen_users(lp, 0) <> "EOL"
1084 DoEvents
1085 If LCase(nickk) = LCase(Right$(seen_users(lp, 0), Len(nickk))) Then
1086 user_exists = lp
1087 Exit Function
1088 End If
1089 lp = lp + 1
1090 Wend
1091 user_exists = -1
1092
1093End Function
1094Public Sub upd_seen(ByVal nickk As String)
1095 Dim lp As Integer
1096 Dim hp As Integer
1097 Dim testu As Integer
1098 hp = 0
1099
1100 testu = user_exists(nickk)
1101 If testu <> -1 Then
1102 seen_users(testu, 1) = Date
1103 seen_users(testu, 2) = Time
1104 Else
1105 While seen_users(hp, 0) <> "EOL"
1106 DoEvents
1107 hp = hp + 1
1108 Wend
1109 seen_users(hp, 0) = LCase(nickk)
1110 seen_users(hp + 1, 0) = "EOL"
1111 seen_users(hp, 1) = Date
1112 seen_users(hp, 2) = Time
1113 End If
1114
1115 End Sub
1116Public Function user_online(ByVal nickk As String) As Boolean
1117 Dim lp As Integer
1118 lp = 0
1119
1120 While users(lp, 0) <> "EOL"
1121 DoEvents
1122 If Right$(LCase(users(lp, 0)), Len(nickk)) = LCase(nickk) Then
1123 user_online = True
1124 Exit Function
1125
1126 End If
1127 lp = lp + 1
1128 Wend
1129 user_online = False
1130
1131End Function
1132
1133'Reset Hal's short term memory to empty values and force
1134'variants to correct data type
1135Sub ResetMem()
1136 Hate = 0
1137 Swear = 0
1138 Insults = 0
1139 Compliment = 0
1140 PrevSent = ""
1141 LastResponseTime = ""
1142 PrevUserSent = ""
1143 CustomMem = ""
1144 GainControl = ""
1145 HalCommands = ""
1146 LastTopicList = ""
1147 InputString = ""
1148End Sub