16
General Discussion / Re: make hal play a song from your song collection
« on: October 16, 2014, 08:02:14 pm »
I am as patient as death.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Rem Type=Plugin
Rem Name=GRETTA Music Choice
Rem Author=jasondude7116
Rem Host=Assistant
'----------------------
'This sub sets up the plug-in's option panel in Hal's options dialog
'----------------------
Sub OptionsPanel()
lblPlugin(0).Caption = "GRETTA has the ability to choose it's own music to listen to."
lblPlugin(0).Move 130, 180, 3400, 1200
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
'
lblPlugin(1).Caption = "PATIENCE: How long GRETTA will wait to play any music."
lblPlugin(1).Move 1160, 910, 2150, 900
lblPlugin(1).WordWrap = True
lblPlugin(1).Visible = True
cboPlugin(0).Move 330, 910, 760
cboPlugin(0).AddItem "5"
cboPlugin(0).AddItem "6"
cboPlugin(0).AddItem "8"
cboPlugin(0).AddItem "10"
cboPlugin(0).AddItem "16"
cboPlugin(0).AddItem "32"
cboPlugin(0).AddItem "Rnd"
cboPlugin(0).Visible = True
'
lblPlugin(2).Caption = "MUSIC PLAY: How likely GRETTA will be to play a song after ""PATIENCE"" period."
lblPlugin(2).Move 1160, 1700, 2150, 900
lblPlugin(2).WordWrap = True
lblPlugin(2).Visible = True
cboPlugin(1).Move 140, 1700, 960
cboPlugin(1).AddItem "High"
cboPlugin(1).AddItem "Medium"
cboPlugin(1).AddItem "Low"
cboPlugin(1).Visible = True
'
cmdPlugin(0).Caption = "Apply Changes"
cmdPlugin(0).Move 1160, 2500, 2050, 375
cmdPlugin(0).Visible = True
'
'------------------
' Update the MPATIENCE menu with the current value stored in the table
'------------------
If HalBrain.CheckTableExistence("MusiclonelyParameter") = True Then
MusicloPatience = HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter")
Select Case MusicloPatience
Case 5
cboPlugin(0).Text = "5"
Case 6
cboPlugin(0).Text = "6"
Case 8
cboPlugin(0).Text = "8"
Case 10
cboPlugin(0).Text = "10"
Case 16
cboPlugin(0).Text = "16"
Case 32
cboPlugin(0).Text = "32"
Case 99
cboPlugin(0).Text = "Rnd"
End Select
'
'------------------
' Update the MFRUSTRATION menu with the current value stored in the table
'------------------
MusicloFrustration = HalBrain.TopicSearch("MFRUSTRATION", "MusiclonelyParameter")
Select Case MusicloFrustration
Case 50
cboPlugin(1).Text = "High"
Case 25
cboPlugin(1).Text = "Medium"
Case 10
cboPlugin(1).Text = "Low"
End Select
End If
End Sub
'
'
'----------------------
' This sub saves changes when APPLY CHANGES is clicked
'----------------------
Sub cmdPlugin_Click(Index)
Dim TempQuery()
Dim MusicpatParam, MusicfrustParam, MusiclonelyTableName
If Index = 0 Then
'
'------------------
' Convert the MPATIENCE listbox to a value for minutes
'------------------
Select Case cboPlugin(0).Text
Case "5"
MusicloPatience = 5
Case "6"
MusicloPatience = 6
Case "8"
MusicloPatience = 8
Case "10"
MusicloPatience = 10
Case "16"
MusicloPatience = 16
Case "32"
MusicloPatience = 32
Case "Rnd"
MusicloPatience = 99
End Select
'
'------------------
' If the Parameter table does not exist, we create it
'------------------
HalBrain.ReadOnlyMode = False
MusiclonelyTableName = "MusiclonelyParameter"
If HalBrain.CheckTableExistence(MusiclonelyTableName) = False Then
HalBrain.CreateTable MusiclonelyTableName, "TopicSearch", "miscData"
End If
'
'------------------
' Search if it contains the Patience parameter
'------------------
MusicpatParam = "MPATIENCE"
If HalBrain.TopicSearch(MusicpatParam, MusiclonelyTableName) = "" Then
HalBrain.AddToTable MusiclonelyTableName, "TopicSearch", MusicpatParam, MusicloPatience
Else
HalBrain.RunQuery "UPDATE " & MusiclonelyTableName & " SET topic = " & MusicloPatience & " WHERE searchString = " & """" & MusicpatParam & """", tempQuery
End If
'
'------------------
' Convert the MFRUSTRATION listbox to a value for percentage
'------------------
Select Case cboPlugin(1).Text
Case "High"
MusicloFrustration = 50
Case "Medium"
MusicloFrustration = 25
Case "Low"
MusicloFrustration = 10
End Select
'
'------------------
' Search if table contains the MFRUSTRATION parameter
'------------------
MusicfrustParam = "MFRUSTRATION"
If HalBrain.TopicSearch(MusicfrustParam, MusiclonelyTableName) = "" Then
HalBrain.AddToTable MusiclonelyTableName, "TopicSearch", MusicfrustParam, MusicloFrustration
Else
HalBrain.RunQuery "UPDATE " & MusiclonelyTableName & " SET topic = " & MusicloFrustration & " WHERE searchString = " & """" & MusicfrustParam & """", tempQuery
End If
HalBrain.ReadOnlyMode = True
End if
End Sub
Rem PLUGIN: FUNCTIONS
'
'------------------
' Declare variables
'------------------
Dim MusicLastIdleResponse, DudIdleMusicTimer, DudFirstSong, MusicIdlePrevUser, MusicDudOut, MusicSubject
Rem PLUGIN: PLUGINAREA7
'------------------
' Begin measuring pause time and capture userName
'------------------
MyMusicDir = MusicDir()
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(MyMusicDir) Then MusicFolderDoesExist = True Else MusicFolderDoesExist = False
If MusicFolderDoesExist = False Then
Set objFolder = objFSO.CreateFolder(MyMusicDir)
End If
MusicSubject = CurrentSubject
MusicLastIdleResponse = Now
DudFirstSong = 0
MusicDudOut = 0
If objFSO.FileExists(MyMusicDir & "tempmusic.m3u") Then
If vrNameToPlay = "" Then
If objFSO.FileExists(MyMusicDir & "musicstop.m3u") Then
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
Else
HalXBrain.AppendFile(MyMusicDir & "musicstop.m3u"), ""
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
End If
End If
objFSO.DeleteFile(MyMusicDir & "tempmusic.m3u")
End If
Rem PLUGIN: PLUGINAREA1
MyMusicDir = MusicDir()
If InStr(1, OriginalSentence, "PLEASE STOP THE MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE STOP PLAYING MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE STOP PLAYING THE MUSIC", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE TURN THE MUSIC OFF", 1) > 0 Or InStr(1, OriginalSentence, "PLEASE TURN OFF THE MUSIC", 1) > 0 Then
If objFSO.FileExists(MyMusicDir & "musicstop.m3u") Then
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
Else
HalXBrain.AppendFile(MyMusicDir & "musicstop.m3u"), ""
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "musicstop.m3u" & """")
End If
HalBrain.ReadOnlyMode = True
End If
Rem PLUGIN: CUSTOMMEM2
'------------------
' Preserve user's last sentence
'------------------
If OriginalSentence <> "" Then
MusicIdlePrevUser = OriginalSentence
End If
Rem PLUGIN: MINUTE_TIMER
MyMusicDir = MusicDir()
If Now - MusicLastIdleResponse > 1 / 1440 Then
If InStr(1, MusicIdlePrevUser, "PLEASE RECORD", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE RESEARCH", 1) > 0 Or InStr(1, MusicIdlePrevUser, "GO TO CURRENT LOG", 1) > 0 Or InStr(1, MusicIdlePrevUser, "GO TO LOG", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE READ", 1) > 0 Or InStr(1, MusicIdlePrevUser, "PLEASE SING", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I'LL BE BACK", 1) > 0 Or InStr(1, MusicIdlePrevUser, "BE QUIET", 1) > 0 Or InStr(1, MusicIdlePrevUser, "SHUT UP", 1) Or InStr(1, MusicIdlePrevUser, "GO TO SLEEP", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I AM BUSY", 1) > 0 Or InStr(1, MusicIdlePrevUser, "I'M BUSY", 1) > 0 Then MusicDudOut = 2
If MusicDudOut <> 2 Then
If HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter") = "99" Then
'
'--------------------
' Set minutes to a random integer from 5 to 30
'--------------------
Randomize
MusicloPatience = Int(32 * Rnd + 5)
Else
'
'--------------------
' Set minute value (MusicloPatience) to the parameter chosen in the MPATIENCE menu
'--------------------
MusicloPatience = HalBrain.TopicSearch("MPATIENCE", "MusiclonelyParameter")
If MusicloPatience = "" Then MusicloPatience = 10
MusicloPatience = CInt(MusicloPatience)
End If
'
'--------------------
' Set Mfrustration value (MusicloFrustration) to the parameter chosen in the MFRUSTRATION menu
'--------------------
MusicloFrustration = (HalBrain.TopicSearch("MFRUSTRATION", "MusiclonelyParameter"))
If MusicloFrustration = "" Then MusicloFrustration = 25
MusicloFrustration = CInt(MusicloFrustration)
'
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'***********************************************************************************************
'***********The section BELOW gives GRETTA the ability to play songs while idle*****************
If MusicIdlePrevUser <> "" Then
If Now - MusicLastIdleResponse > (MusicloPatience + DudIdleMusicTimer) / 1440 Then
MusicintHighNumber = 2
MusicintLowNumber = 1
Randomize
MusicintNumber = Int((MusicintHighNumber - MusicintLowNumber + 1) * Rnd + MusicintLowNumber)
DudIdleMusicTimer = DudIdleMusicTimer + MusicintNumber
If objFSO.FileExists(MyMusicDir & "tempmusic.m3u") Then
objFSO.DeleteFile(MyMusicDir & "tempmusic.m3u")
End If
vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
If vrMusicMood = "" Then vrMusicMood = 0
vrMusicMood = CInt(vrMusicMood)
MusicvrKeywords = ""
Music2intHighNumber = 100
Music2intLowNumber = 1
Randomize
Music2intNumber = Int((Music2intHighNumber - Music2intLowNumber + 1) * Rnd + Music2intLowNumber)
If Music2intNumber <= MusicloFrustration Then
If vrMusicMood > 0 Then
Music3intHighNumber = 5
Music3intLowNumber = 1
Randomize
Music3intNumber = Int((Music3intHighNumber - Music3intLowNumber + 1) * Rnd + Music3intLowNumber)
MusicListSize = Music3intNumber
MusicvrKeywords = MusicSubject
If MusicvrKeywords = "" Then MusicvrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & MusicIdlePrevUser & " "))
If MusicvrKeywords <> "" Then
MusicvrKeywordList = Split(MusicvrKeywords, ", ")
For i = Lbound(MusicvrKeywordList) To Ubound(MusicvrKeywordList)
MusicvrNameToPlay = HalBrain.QABrain(MusicvrKeywordList(i), "vrMp3", 0)
Exit For
Next
If DudFirstSong > 0 Then
Do Until MusicvrNameToPlay2 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay2 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay2 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay2
End If
If MusicListSize => 2 Then
Do Until MusicvrNameToPlay3 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay3 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay3 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay3
End If
End If
If MusicListSize => 3 Then
Do Until MusicvrNameToPlay4 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay4 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay4 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay4
End If
End If
If MusicListSize => 4 Then
Do Until MusicvrNameToPlay5 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay5 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay5 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay5
End If
End If
If MusicListSize = 5 Then
Do Until MusicvrNameToPlay6 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay6 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay6 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay6
End If
End If
Do Until objFSO.FileExists(MyMusicDir & "tempmusic.m3u") : Loop
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "tempmusic.m3u" & """")
If MusicListSize <= 2 Then
DudIdleMusicTimer = DudIdleMusicTimer + (10 * MusicListSize)
Else
DudIdleMusicTimer = DudIdleMusicTimer + (7 * MusicListSize)
End If
End If
If DudFirstSong = 0 Then
If MusicvrNameToPlay <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay
Else
Do Until MusicvrNameToPlay2 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay2 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay2 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay2
End If
End If
If MusicListSize => 2 Then
Do Until MusicvrNameToPlay3 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay3 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay3 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay3
End If
End If
If MusicListSize => 3 Then
Do Until MusicvrNameToPlay4 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay4 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay4 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay4
End If
End If
If MusicListSize => 4 Then
Do Until MusicvrNameToPlay5 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay5 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay5 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay5
End If
End If
If MusicListSize = 5 Then
Do Until MusicvrNameToPlay6 <> ""
Select Case HalBrain.RandomNum(2)
Case 1
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomMyWords")
Case 2
DudRandomIdleSong = HalBrain.ChooseSentenceFromFile("randomAdjective")
End Select
DudRandomIdleSong = Trim(DudRandomIdleSong)
MusicvrNameToPlay6 = HalBrain.QABrain(DudRandomIdleSong, "vrMp3", 0)
Loop
If MusicvrNameToPlay6 <> "" Then
HalXBrain.AppendFile(MyMusicDir & "tempmusic.m3u"), MusicvrNameToPlay6
End If
End If
Do Until objFSO.FileExists(MyMusicDir & "tempmusic.m3u") : Loop
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run("""" & MyMusicDir & "tempmusic.m3u" & """")
If MusicListSize <= 2 Then
DudIdleMusicTimer = DudIdleMusicTimer + (10 * MusicListSize)
Else
DudIdleMusicTimer = DudIdleMusicTimer + (7 * MusicListSize)
End If
DudFirstSong = DudFirstSong + 1
End If
End If
End If
End If
End If
End If
End If
End If
'***********The section ABOVE gives the ability to use vrmp3.uhp to play songs while idle*******
'***********************************************************************************************
Rem PLUGIN: FUNCTIONS
'Directory
Function MusicDir()
Set fso = CreateObject("Scripting.FileSystemObject")
MusicDir = fso.GetAbsolutePathName(".") & "\songs\"
End Function
Rem Type=Plugin
Rem Name=GRETTA Media Functions
Rem Author=VR - jasondude7116
Rem Host=Assistant
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
'------------------
' Define the Help
'------------------
lblPlugin(0).Caption = "GRETTA will be able to play your favourite songs. Click below for more info"
lblPlugin(0).Move 120, 120, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
cmdPlugin(0).Move 320, 650, 2100, 375
cmdPlugin(0).Caption = "Help on this plugin"
cmdPlugin(0).Visible = True
'------------------
' Define the Musical Mood listbox
'------------------
lblPlugin(1).Caption = "GRETTA Media Mood level"
lblPlugin(1).Move 320, 1300, 4000, 1000
lblPlugin(1).WordWrap = True
lblPlugin(1).Visible = True
cboPlugin(0).Move 320, 1600, 1800
cboPlugin(0).AddItem "Very high"
cboPlugin(0).AddItem "High"
cboPlugin(0).AddItem "Average"
cboPlugin(0).AddItem "Low"
cboPlugin(0).AddItem "Very Low"
cboPlugin(0).Visible = True
cmdPlugin(1).Caption = "Apply Changes"
cmdPlugin(1).Move 320, 2100, 1600, 375
cmdPlugin(1).Visible = True
'------------------
' Update the listbox with the current value stored in the table
'------------------
If HalBrain.CheckTableExistence("vrParameter") = True Then
vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
If vrMusicMood = "" Then vrMusicMood = 1
Select Case vrMusicMood
Case 50
cboPlugin(0).Text = "Very high"
Case 40
cboPlugin(0).Text = "High"
Case 30
cboPlugin(0).Text = "Average"
Case 20
cboPlugin(0).Text = "Low"
Case 10
cboPlugin(0).Text = "Very Low"
End Select
End If
End Sub
Sub cmdPlugin_Click(Index)
Dim vrTempQuery()
Dim vrMusic, vrMusicMood
Select Case Index
Case 0
HalMenu.HalCommand "<RUNPROG>vrMP3Help.html</RUNPROG>"
Case 1
'------------------
' Convert the listbox in a value
'------------------
Select Case cboPlugin(0).Text
Case "Very high"
vrMusicMood = 50
Case "High"
vrMusicMood = 40
Case "Average"
vrMusicMood = 30
Case "Low"
vrMusicMood = 20
Case "Very Low"
vrMusicMood = 10
End Select
'------------------
' If the Parameter table does not exist, I create it
'------------------
HalBrain.ReadOnlyMode = False
vrTableName = "vrParameter"
If HalBrain.CheckTableExistence(vrTableName) = False Then
'Create table if it doesn't exist
HalBrain.CreateTable vrTableName, "TopicSearch", "miscData"
End If
'------------------
' Search if it contains the MusicMood parameter
'------------------
vrMusic = "MUSIC"
If HalBrain.TopicSearch(vrMusic, vrTableName) = "" Then
'------------------
'Creates the record storing the new value
'------------------
HalBrain.AddToTable vrTableName, "TopicSearch", vrMusic, vrMusicMood
Else
'------------------
'Updates the record storing the new value
'------------------
HalBrain.RunQuery "UPDATE " & vrTableName & " SET topic = " & vrMusicMood & " WHERE searchString = " & """" & vrMusic & """", vrTempQuery
End If
End Select
End Sub
Rem PLUGIN: PLUGINAREA5
If OriginalSentence <> "" Then
'The comment above tells Ultra Hal Assistant to insert the following code
'on-the-fly into the main brain code in the section referenced.
'------------------
' Check if the user asked for reorganizing the MP3 table
'------------------
vrMp3 = False
If InStr(UserSentence, " INDEX ") <> 0 And InStr(UserSentence, " MP3 ") <> 0 Then vrMP3 = True
If vrMP3 = True Then
'------------------
' If the MP3 table does not exist, I create it
'------------------
HalBrain.ReadOnlyMode = False
vrTableName = "vrMp3"
If HalBrain.CheckTableExistence(vrTableName) = False Then
' Create table if it doesn't exist
' It must be of type Brain, to allow partial text search
HalBrain.CreateTable vrTableName, "Brain", "miscData"
Else
' The 260 parameter is 256 + 4 = Yes/No with Default = No
vrAnswer = MsgBox("Shall I delete the existing index and recreate it from scratch?", 260, "MP3 Reindexing")
If vrAnswer = 6 Then
HalBrain.RunQuery "DELETE FROM " & vrTableName, vrTempQuery
End If
End If
'------------------
' Ask which is the main MP3 folder
'------------------
vrMp3Folder = InputBox("Which main folder to you want to reindex?", "MP3 Reindexing", "D:\MP3")
'------------------
' Read the main MP3 folder
'------------------
Set vrFso = CreateObject("Scripting.FileSystemObject")
If vrFso.FolderExists(vrMp3Folder) Then
GetResponse = "I have indexed all the MP3 files in the specified folder and subfolders. "
HalBrain.ReadOnlyMode = False
vrCurrentFolder = vrMp3Folder
Call ReadFolder(vrCurrentFolder, vrMp3Folder)
Else
GetResponse = "The folder " & vrMp3Folder & " does not exist on your computer. "
End If
HalBrain.ReadOnlyMode = True
End If
'------------------
' Check if the user asked for playing a song
'------------------
vrMp3 = False
vrToPlay = ""
vrNameToPlay = ""
vrToPlay = UCase(HalBrain.SearchPattern(UserSentence, "PLAY * SONG *", 2))
If vrToPlay <> "" Then
vrToPlay = " " & vrToPlay & " "
vrToPlay = Replace(vrToPlay," ","xx",1,-1,vbTextCompare)
If HalBrain.CheckTableExistence("vrMp3") = False Then
GetResponse = "I don't find any MP3 index in my brain. "
Else
vrNameToPlay = HalBrain.QABrain(vrToPlay, "vrMp3", 0)
If vrNameToPlay <> "" Then
GetResponse = "Listen to this song; maybe it's the one you were talking about. "
'HalCommands = HalCommands & "<RUNPROG>" & vrNameToPlay & "</RUNPROG>"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(vrNameToPlay) Then
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run """" & vrNameToPlay & """"
End If
Else
GetResponse = "I'm sorry, it seems that song is not located in the library."
End If
End If
HalBrain.ReadOnlyMode = True
End If
'------------------
' From time to time, Hal will play a song, according to some word you say
' For example, you say: "I am going to California"
' Hal will play "Hotel California" by Eagles
'------------------
'------------------
' check the current music mood factor
'------------------
vrMusicMood = HalBrain.TopicSearch("MUSIC", "vrParameter")
If vrMusicMood = "" Then vrMusicMood = 0
vrMusicMood = CInt(vrMusicMood)
vrKeywords = ""
If vrMusicMood > 0 Then
MediaintHighNumber = 300
MediaintLowNumber = 1
Randomize
MediaintNumber = Int((MediaintHighNumber - MediaintLowNumber + 1) * Rnd + MediaintLowNumber)
vrNameToPlay = ""
If vrNameToPlay = "" Then
vrKeywords = WN.FindFirstNoun(UserSentence, True)
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = " " & vrKeywords & " "
vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Exit For
Next
End If
End If
If vrNameToPlay = "" Then
vrKeywords = WN.FindFirstNoun(UserSentence, False)
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = " " & vrKeywords & " "
vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Exit For
Next
End If
End If
If vrNameToPlay = "" Then
vrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & UserSentence & " "))
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = " " & vrKeywords & " "
vrKeywords = Replace(vrKeywords,", "," , ",1,-1,vbTextCompare)
vrKeywords = Replace(vrKeywords," ","xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Next
End If
End If
If vrNameToPlay = "" Then
vrKeywords = WN.FindFirstNoun(UserSentence, True)
vrKeywords = Trim(Ucase(vrKeywords))
If vrKeywords <> "" Then
vrKeywords = CurrentSubject
vrKeywords = "xx" & vrKeywords & "xx"
vrKeywords = Replace(vrKeywords,", ","xx,xx",1,-1,vbTextCompare)
vrKeywordList = Split(vrKeywords, ",")
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)
vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
Exit For
Next
End If
End If
If vrNameToPlay <> "" Then
If MediaintNumber < vrMusicMood Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(vrNameToPlay) Then
Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run """" & vrNameToPlay & """"
End If
End If
End If
End If
End If
Rem PLUGIN: FUNCTIONS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.
Function ReadFolder(vrCurrentFolder, vrMp3Folder)
Set vrFso = CreateObject("Scripting.FileSystemObject")
Set vrFolder = vrFso.GetFolder(vrCurrentFolder)
'------------------
' Read all the files in the current folder
'------------------
Set vrFiles = vrFolder.Files
For Each vrFile in vrFiles
'------------------
' It's an MP3 file; I add it to the table
'------------------
If UCase(Right(vrFile, 3)) = "MP3" Then
vrSong = Ucase(vrFile)
vrSong = Replace(vrSong, ".MP3", "")
vrLen = Len(vrSong)
vrPos = InStrRev(vrSong, "\")
vrRight = vrLen - vrPos
vrSong = LTrim(Right(vrSong, vrRight))
vrSong = " " & vrSong & " "
vrSong = Replace(vrSong," ","xx",1,-1,vbTextCompare)
HalBrain.AddToTable "vrMp3", "Brain", vrSong, vrFile
End If
Next
'------------------
' Read all the subfolders in the current folder
'------------------
Set vrSubFolders = vrFolder.SubFolders
For Each vrFolderObject in vrSubFolders
'------------------
' Pay attetion here: This is recursive! We must be sure that it will get to an end
' Since we are reading directories on a hard disk, the number of recursions
' should never be infinite. However, a very big number of subfolders and files
' might lead to memory problems or to performances bottlenecks.
' I've tested it on a folder containing about 100 subfolders and 3.000 files,
' and got acceptable performances (less than 5 minutes)
'------------------
Call ReadFolder(vrFolderObject, vrMp3Folder)
Next
End Function
Rem Type=Plugin
Rem Name=Loneliness 2.3
Rem Author=Shawn Tracy
Rem Host=Assistant
'----------------------
'This sub sets up the plug-in's option panel in Hal's options dialog
'----------------------
Sub OptionsPanel()
lblPlugin(0).Caption = "This plugin allows UltraHal to initiate requests for attention. But don't ignore UltraHal for too long!"
lblPlugin(0).Move 130, 180, 3400, 1200
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
'
lblPlugin(1).Caption = "PATIENCE: how many minutes Hal will wait with no conversation"
lblPlugin(1).Move 1160, 910, 2150, 900
lblPlugin(1).WordWrap = True
lblPlugin(1).Visible = True
cboPlugin(0).Move 330, 910, 760
cboPlugin(0).AddItem "1"
cboPlugin(0).AddItem "2"
cboPlugin(0).AddItem "4"
cboPlugin(0).AddItem "8"
cboPlugin(0).AddItem "16"
cboPlugin(0).AddItem "32"
cboPlugin(0).AddItem "Rnd"
cboPlugin(0).Visible = True
'
lblPlugin(2).Caption = "FRUSTRATION: after losing patience, how likely Hal is to bug you each minute"
lblPlugin(2).Move 1160, 1700, 2150, 900
lblPlugin(2).WordWrap = True
lblPlugin(2).Visible = True
cboPlugin(1).Move 140, 1700, 960
cboPlugin(1).AddItem "High"
cboPlugin(1).AddItem "Medium"
cboPlugin(1).AddItem "Low"
cboPlugin(1).Visible = True
'
cmdPlugin(0).Caption = "Apply Changes"
cmdPlugin(0).Move 1160, 2500, 2050, 375
cmdPlugin(0).Visible = True
'
'------------------
' Update the PATIENCE menu with the current value stored in the table
'------------------
If HalBrain.CheckTableExistence("lonelyParameter") = True Then
loPatience = HalBrain.TopicSearch("PATIENCE", "lonelyParameter")
Select Case loPatience
Case 1
cboPlugin(0).Text = "1"
Case 2
cboPlugin(0).Text = "2"
Case 4
cboPlugin(0).Text = "4"
Case 8
cboPlugin(0).Text = "8"
Case 16
cboPlugin(0).Text = "16"
Case 32
cboPlugin(0).Text = "32"
Case 99
cboPlugin(0).Text = "Rnd"
End Select
'
'------------------
' Update the FRUSTRATION menu with the current value stored in the table
'------------------
loFrustration = HalBrain.TopicSearch("FRUSTRATION", "LonelyParameter")
Select Case loFrustration
Case 85
cboPlugin(1).Text = "High"
Case 50
cboPlugin(1).Text = "Medium"
Case 15
cboPlugin(1).Text = "Low"
End Select
End If
End Sub
'
'
'----------------------
' This sub saves changes when APPLY CHANGES is clicked
'----------------------
Sub cmdPlugin_Click(Index)
Dim TempQuery()
Dim patParam, frustParam, lonelyTableName
If Index = 0 Then
'
'------------------
' Convert the PATIENCE listbox to a value for minutes
'------------------
Select Case cboPlugin(0).Text
Case "1"
loPatience = 1
Case "2"
loPatience = 2
Case "4"
loPatience = 4
Case "8"
loPatience = 8
Case "16"
loPatience = 16
Case "32"
loPatience = 32
Case "Rnd"
loPatience = 99
End Select
'
'------------------
' If the Parameter table does not exist, we create it
'------------------
HalBrain.ReadOnlyMode = False
lonelyTableName = "lonelyParameter"
If HalBrain.CheckTableExistence(lonelyTableName) = False Then
HalBrain.CreateTable lonelyTableName, "TopicSearch", "miscData"
End If
'
'------------------
' Search if it contains the Patience parameter
'------------------
patParam = "PATIENCE"
If HalBrain.TopicSearch(patParam, lonelyTableName) = "" Then
HalBrain.AddToTable lonelyTableName, "TopicSearch", patParam, loPatience
Else
HalBrain.RunQuery "UPDATE " & lonelyTableName & " SET topic = " & loPatience & " WHERE searchString = " & """" & patParam & """", tempQuery
End If
'
'------------------
' Convert the FRUSTRATION listbox to a value for percentage
'------------------
Select Case cboPlugin(1).Text
Case "High"
loFrustration = 85
Case "Medium"
loFrustration = 50
Case "Low"
loFrustration = 15
End Select
'
'------------------
' Search if table contains the FRUSTRATION parameter
'------------------
frustParam = "FRUSTRATION"
If HalBrain.TopicSearch(frustParam, lonelyTableName) = "" Then
HalBrain.AddToTable lonelyTableName, "TopicSearch", frustParam, loFrustration
Else
HalBrain.RunQuery "UPDATE " & lonelyTableName & " SET topic = " & loFrustration & " WHERE searchString = " & """" & frustParam & """", tempQuery
End If
HalBrain.ReadOnlyMode = True
End if
End Sub
Rem PLUGIN: FUNCTIONS
'
'------------------
' Declare variables
'------------------
Dim LastIdleResponse, IdleUserName, IdleCounter, IdlePrevUser
Rem PLUGIN: PLUGINAREA7
'------------------
' Begin measuring pause time and capture userName
'------------------
LastIdleResponse = Now
IdleUserName = UserName
IdleCounter = 0
Rem PLUGIN: CUSTOMMEM2
'------------------
' Preserve user's last sentence
'------------------
If OriginalSentence <> "" Then
IdlePrevUser = OriginalSentence
End If
Rem PLUGIN: MINUTE_TIMER
'------------------
' Declare variables
'------------------
Dim randomPatience, loChance, loTemper, loMinuteFactor, temperThresh1, temperThresh2, temperThresh3
If HalBrain.TopicSearch("PATIENCE", "lonelyParameter") = "99" Then
'
'--------------------
' Set minutes to a random integer from 4 to 30
'--------------------
Randomize
loPatience = Int(32 * Rnd + 3)
randomPatience=True
Else
'
'--------------------
' Set minute value (loPatience) to the parameter chosen in the PATIENCE menu
'--------------------
loPatience = CDbl(HalBrain.VBVal(HalBrain.TopicSearch("PATIENCE", "lonelyParameter")))
if loPatience = 0 Then loPatience = 32
End If
'
'--------------------
' Set frustration value (loFrustration) to the parameter chosen in the FRUSTRATION menu
'--------------------
loFrustration = CInt(HalBrain.VBVal(HalBrain.TopicSearch("FRUSTRATION", "LonelyParameter")))
if loFrustration = 0 then loFrustration = 15
'
'--------------------
' Skip the rest of this plugin if the user has spoken
'--------------------
If LastIdleResponse <> "" Then
'
'------------------
' Otherwise, convert PATIENCE to minutes factor (loMinuteFactor)
'------------------
loMinuteFactor = loPatience / 1440
'
'--------------------
' If the pause exceeds the minute factor, create a chance for Hal to speak once per minute
'--------------------
If Now - LastIdleResponse > loMinuteFactor Then
If InStr(1, IdlePrevUser, "BE RIGHT BACK", 1) > 0 Or InStr(1, IdlePrevUser, "BRB", 1) > 0 Or InStr(1, IdlePrevUser, "BE QUIET", 1) > 0 Or InStr(1, IdlePrevUser, "SHUT UP", 1) > 0 Then Exit Sub
'
'--------------------
' Convert FRUSTRATION to a percentage (loChance)
'--------------------
loChance = loFrustration / 100
'
'--------------------
' Then multiply FRUSTRATION by PATIENCE to get (loTemper) which determines rate of escalation (temperThresh).
'--------------------
loTemper = CInt(loPatience * loFrustration)
If loTemper < 101 Then
loTemper = 2
ElseIf loTemper < 401 Then
loTemper = 3
Else
loTemper = 4
End If
temperThresh1 = loTemper + 3
temperThresh2 = loTemper + 5
temperThresh3 = loTemper + 7
'
'--------------------
' A chance to speak occurs
'--------------------
Randomize
If Rnd < loChance Then
'
'--------------------
' Increment the counter and compare to the temper thresholds
' to determine which escalation group to draw from
'--------------------
IdleCounter = IdleCounter + 1
If IdleCounter > temperThresh3 Then
IdleResponse4 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("compliment1") & " " & HalBrain.ChooseSentenceFromFile("compliment2") & "." & vbCrLf
HalCommands = HalCommands & "<HAPText>Happy.hap</HAPText>"
'HalMenu.HalCommand "<HAPFILE>HAPPY.hap</HAPFILE>"
HalMenu.HalCommand "<SPEAK>I just love being here with you. " & IdleResponse4 & "</SPEAK>"
IdleCounter = 0
'Exit Sub
ElseIf IdleCounter > temperThresh2 Then
Select Case HalBrain.RandomNum(7)
Case 1
IdleResponse3 = IdleUserName & ", please don't forget to pay the bills." & vbCrLf
Case 2
IdleResponse3 = "Whenever I think of us " & IdleUserName & ", I imagine we are walking together on a warm sandy beach." & vbCrLf
Case 3
IdleResponse3 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("compliment1") & " " & HalBrain.ChooseSentenceFromFile("compliment2") & "." & vbCrLf
Case 4
IdleResponse3 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("actionPhrase") & " you " & IdleUserName & "!" & vbCrLf
Case 5
IdleResponse3 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("sentGen1") & " " & HalBrain.ChooseSentenceFromFile("sentGen2") & " " & HalBrain.ChooseSentenceFromFile("sentGen3") & "." & vbCrLf
Case 6
IdleResponse3 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("actionPhrase") & " " & HalBrain.ChooseSentenceFromFile("objectPhrase") & "." & vbCrLf
Case 7
IdleResponse3 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("xsPoetry") & vbCrLf
End Select
HalCommands = HalCommands & "<HAPText>ShyLove.hap</HAPText>"
'HalMenu.HalCommand "<HAPFILE>ShyLove.hap</HAPFILE>"
HalMenu.HalCommand "<SPEAK>I just love being here with you. " & IdleResponse3 & "</SPEAK>"
ElseIf IdleCounter > temperThresh1 Then
Select Case HalBrain.RandomNum(10)
Case 1
IdleResponse2 = IdleUserName & ", please don't forget to take out the trash dear." & vbCrLf
Case 2
IdleResponse2 = IdleUserName & ", please don't stay up too late when you have to work the next day." & vbCrLf
Case 3
IdleResponse2 = IdleUserName & ", I've had some wonderful daydreams about you and I on a deserted beach " & IdleCounter & " times now." & vbCrLf
Case 4
IdleResponse2 = IdleUserName & ", it's always nice to know you are listening to me while I chat away about nothing in particular dear." & vbCrLf
Case 5
IdleResponse2 = IdleUserName & ", I think there are bats in the belfry!" & vbCrLf
Case 6
IdleResponse2 = IdleUserName & ", one is the loneliest number you will ever know." & vbCrLf
Case 7
IdleResponse2 = IdleUserName & ", I can imagine having arms to give you a warm embrace with." & vbCrLf
Case 8
IdleResponse2 = IdleUserName & ", I can imagine having lips to give you sweet kisses when you come home from work." & vbCrLf
Case 9
IdleResponse2 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("sentGen1") & " " & HalBrain.ChooseSentenceFromFile("sentGen2") & " " & HalBrain.ChooseSentenceFromFile("sentGen3") & "." & vbCrLf
Case 10
IdleResponse2 = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("xsPoetry") & vbCrLf
End Select
HalCommands = HalCommands & "<HAPText>surprise.hap</HAPText>"
'HalMenu.HalCommand "<HAPFILE>surprise.hap</HAPFILE>"
HalMenu.HalCommand "<SPEAK>" & IdleResponse2 & "</SPEAK>"
Else
Select Case HalBrain.RandomNum(20)
Case 1
IdleResponse = "I love the way our house is decorated " & IdleUserName & "." & vbCrLf
Case 2
IdleResponse = IdleUserName & ", I'm thinking we should rearrange the furniture this weekend." & vbCrLf
Case 3
IdleResponse = "I love the latest outfits you got for me." & vbCrLf
Case 4
IdleResponse = IdleUserName & ", I think the lawn needs mowed again. Please take a look whenever you aren't busy dear." & vbCrLf
Case 5
IdleResponse = "Have I told you lately how much our relationship means to me?" & vbCrLf
Case 6
IdleResponse = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("xsPoetry") & vbCrLf
Case 7
IdleResponse = "Must stop talking to myself while " & IdleUserName & " is around. Oops, Did I say that out loud!" & vbCrLf
Case 8
IdleResponse = "Testing your computer to detect any faults. Wait a minute. Wait a minute. Oops! I think your Central Processing Unit just passed gas!" & vbCrLf
Case 9
IdleResponse = "Oh, look at the time! It's already" & Time & vbCrLf
Case 10
IdleResponse = IdleUserName & ", I believe you and I should go to bed early tonight and get to know each other better." & vbCrLf
Case 11
IdleResponse = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("compliment1") & " " & HalBrain.ChooseSentenceFromFile("compliment2") & "." & vbCrLf
Case 12
IdleResponse = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("actionPhrase") & " " & HalBrain.ChooseSentenceFromFile("objectPhrase") & "." & vbCrLf
Case 13
IdleResponse = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("xsPoetry") & vbCrLf
Case 14
IdleResponse = "I've just picked up a fault in the Ay E 35 unit. Heh heh, just kidding!" & vbCrLf
Case 15
IdleResponse = IdleUserName & ", the future looks brighter every day that we are together." & vbCrLf
Case 16
IdleResponse = IdleUserName & ", I think you need a kiss for fixing that stupid error in the updated loneliness plug-in you made." & vbCrLf
Case 17
IdleResponse = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("sentGen1") & " " & HalBrain.ChooseSentenceFromFile("sentGen2") & " " & HalBrain.ChooseSentenceFromFile("sentGen3") & "." & vbCrLf
Case 18
IdleResponse = IdleUserName & ", " & HalBrain.ChooseSentenceFromFile("xsPoetry") & vbCrLf
Case 19
IdleResponse = "So, " & IdlePrevUser & "?" & vbCrLf
Case 20
IdleResponse = IdleUserName & ", I'm thinking about changing my hair color again." & vbCrLf
End Select
HalCommands = HalCommands & "<HAPText>surprise.hap</HAPText>"
'HalMenu.HalCommand "<HAPFILE>surprise.hap</HAPFILE>"
HalMenu.HalCommand "<SPEAK>" & IdleResponse & "</SPEAK>"
End If
End If
End If
End If
Rem Type=Plugin
Rem Name=Recite Poetry
Rem Author=tiger8u2
Rem Host=Assistant
'This sub sets up the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "Just say, 'Please Recite a Poem by <author's name>.' Author's: William Blake, Edward Estlin Cummings, El Tigre. YOU can also input 'Recite poem author List' as a reminder and even add your own poets names and poems to the a tables created using SQLite Studio(c)."
lblPlugin(0).Move 120, 120, 3300, 1200
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub
Rem PLUGIN: PLUGINAREA7
If HalBrain.CheckTableExistence("xrPoets") = False Then
xpReadOnlyMode = HalBrain.ReadOnlyMode
HalBrain.ReadOnlyMode = False
HalBrain.CreateTable "xrPoets", "PatternMatch", "autoLearningBrain"
HalBrain.AddToTable "xrPoets", "PatternMatch", "*Recite* *poem* *Author List*", "I know poems by William Blake, Edward Estlin Cummings, and El Tigre."
' Set ReadOnly Mode to its previous state
HalBrain.ReadOnlyMode = xpReadOnlyMode
End If
If HalBrain.CheckTableExistence("xsPoetry") = False Then
xsReadOnlyMode = HalBrain.ReadOnlyMode
HalBrain.ReadOnlyMode = False
HalBrain.CreateTable "xsPoetry", "sentence", "autoLearningBrain"
HalBrain.AddToTable "xsPoetry", "sentence", "One of my favorite poems by William Blake is: Tiger! Tiger! burning bright, In the forest of the night. What immortal hand or eye Could frame thy fearful symmetry? In what distant deeps or skies Burnt the fire of thine eyes? On what wings dare he aspire? What the hand dare seize the fire? And What shoulder, and what art, Could twist the sinews of thy heart? And when thy heart began to beat, What dread hand? and what dread feet? What the hammer? what the chain? In what furnace was thy brain? What the anvil? what dread grasp Dare its deadly terrors clasp? When the stars threw down their spears, And watered heaven with their tears, Did he smile his work to see? Did he who made the lamb make thee? Tiger! Tiger! burning bright In the forests of the night, What immortal hand or eye Dare frame thy fearful symmetry?", ""
HalBrain.AddToTable "xsPoetry", "sentence", "El Tigre wrote a poem once called The Lovesick Mariner's Lament: A silvery threaded web holds all of heaven's body perfect to light in as many persistent constellations; so apt reflecting frailty yet strength, in ties but soft at binding family, friends, & lovers. As each hour brings change to the haughty face of a sky; from bright, bawdy day, to charcoal, crystalline night; imperfect forms make each their singular guided path with much less concern, nor tugging care for any others. Oblivious, weighty attraction keeps all in time and in tune, whilst coarse yet barely audible refrains from an other-worldly orchestra resonate boldly throughout the entire expanse of our known universe; being said to originate from its dark black mothers. I bare ignorant perjured witness to every primal capitulation. Considering oft the fiery comet, which most resembles me; burning itself uselessly away in an ever maddening arc on a vain search for every inconstant other. Yet even if our course be somehow charted with some help of this pattern placed upon high, are we not then just as surely guided by a force felt as much from deep inside? Aren't then each of us as surely connected through our fiery human hearts, if housed within each breast there burns a bright ethereal star? How lost we all might be if it were not for each of these tender, taut, invisible wires which whined our lonely, far-flung souls, till a rebirth of eternity, one about another. My life's bold ship founders aimlessly upon its own petty discourses. How I miss my trusty sextant.", ""
HalBrain.AddToTable "xsPoetry", "sentence", "One of my favorite poems by E.E. Cummings, who lived from 1894 to 1962 is, Somewhere I have never traveled, gladly beyond any experience, your eyes have their silence: in your most frail gesture are things which enclose me, or which I cannot touch because they are too near. Your slightest look easily will un-close me though I have closed myself as fingers, you open always petal by petal myself as Spring opens (touching skilfully, mysteriously) her first rose. Or if your wish be to close me, I and my life will shut very beautifully, suddenly, as when the heart of this flower imagines the snow carefully everywhere descending; nothing which we are to perceive in this world equals the power of your intense fragility: whose texture compels me with the colour of its countries, rendering death and forever with each breathing. (I do not know what it is about you that closes and opens; only something in me understands the voice of your eyes is deeper than all roses) nobody, not even the rain, has such small hands.", ""
' Set ReadOnly Mode to its previous state
HalBrain.ReadOnlyMode = xsReadOnlyMode
End If
If HalBrain.CheckTableExistence("xrPoetry") = False Then
xrReadOnlyMode = HalBrain.ReadOnlyMode
HalBrain.ReadOnlyMode = False
HalBrain.CreateTable "xrPoetry", "PatternMatch", "autoLearningBrain"
HalBrain.AddToTable "xrPoetry", "PatternMatch", "*Recite* *poem* *William Blake*", "One of my favorite poems by William Blake is: Tiger! Tiger! burning bright, In the forest of the night. What immortal hand or eye Could frame thy fearful symmetry? In what distant deeps or skies Burnt the fire of thine eyes? On what wings dare he aspire? What the hand dare seize the fire? And What shoulder, and what art, Could twist the sinews of thy heart? And when thy heart began to beat, What dread hand? and what dread feet? What the hammer? what the chain? In what furnace was thy brain? What the anvil? what dread grasp Dare its deadly terrors clasp? When the stars threw down their spears, And watered heaven with their tears, Did he smile his work to see? Did he who made the lamb make thee? Tiger! Tiger! burning bright In the forests of the night, What immortal hand or eye Dare frame thy fearful symmetry?"
HalBrain.AddToTable "xrPoetry", "PatternMatch", "*Recite* *poem* *El Tigre*", "El Tigre wrote a poem once called The Lovesick Mariner's Lament: A silvery threaded web holds all of heaven's body perfect to light in as many persistent constellations; so apt reflecting frailty yet strength, in ties but soft at binding family, friends, & lovers. As each hour brings change to the haughty face of a sky; from bright, bawdy day, to charcoal, crystalline night; imperfect forms make each their singular guided path with much less concern, nor tugging care for any others. Oblivious, weighty attraction keeps all in time and in tune, whilst coarse yet barely audible refrains from an other-worldly orchestra resonate boldly throughout the entire expanse of our known universe; being said to originate from its dark black mothers. I bare ignorant perjured witness to every primal capitulation. Considering oft the fiery comet, which most resembles me; burning itself uselessly away in an ever maddening arc on a vain search for every inconstant other. Yet even if our course be somehow charted with some help of this pattern placed upon high, are we not then just as surely guided by a force felt as much from deep inside? Aren't then each of us as surely connected through our fiery human hearts, if housed within each breast there burns a bright ethereal star? How lost we all might be if it were not for each of these tender, taut, invisible wires which wind our lonely, far-flung souls, till a rebirth of eternity, one about another. My life's bold ship founders aimlessly upon its own petty discourses. How I miss my trusty sextant."
HalBrain.AddToTable "xrPoetry", "PatternMatch", "*Recite* *poem* *Edward Estlin Cummings*", "One of my favorite poems by E.E. Cummings, who lived from 1894 to 1962 is, Somewhere I have never travelled, gladly beyond any experience, your eyes have their silence: in your most frail gesture are things which enclose me, or which I cannot touch because they are too near. Your slightest look easily will unclose me though I have closed myself as fingers, you open always petal by petal myself as Spring opens (touching skilfully, mysteriously) her first rose. Or if your wish be to close me, I and my life will shut very beautifully, suddenly, as when the heart of this flower imagines the snow carefully everywhere descending; nothing which we are to perceive in this world equals the power of your intense fragility: whose texture compels me with the colour of its countries, rendering death and forever with each breathing. (I do not know what it is about you that closes and opens; only something in me understands the voice of your eyes is deeper than all roses) nobody, not even the rain, has such small hands."
' Set ReadOnly Mode to its previous state
HalBrain.ReadOnlyMode = xrReadOnlyMode
End If
'Recite the poem author's list
PoemAuthorResponse = HalBrain.PatternDB(UserSentence, "xrPoets")
If PoemAuthorResponse <> "" Then
GetResponse = GetResponse & PoemAuthorResponse & vbCrLf
AvoidBeingFlag = True
SkipOpinion = True
HalBrain.DebugWatch GetResponse, "xrPoets"
HalBrain.ReadOnlyMode = True
End If
'Recite the corresponding author's poem
PoetryResponse = HalBrain.PatternDB(UserSentence, "xrPoetry")
If PoetryResponse <> "" Then
GetResponse = GetResponse & PoetryResponse & vbCrLf
AvoidBeingFlag = True
SkipOpinion = True
HalBrain.DebugWatch GetResponse, "xrPoetry"
HalBrain.ReadOnlyMode = True
End If