This is what I have from the plugin downloaded
Rem Type=Plugin
Rem Name=Wiki Search
Rem Author= Victor Yacobucci
Rem Host=Assistant
'------------------------------------------------------------------------------------------------------
' WikiSearch.uhp - Release 1.0 by Victor Yacobucci. 02-25-2016
'------------------------------------------------------------------------------------------------------
Rem PLUGIN: PLUGINAREA1
Dim ie
If InStr(1, UserSentence, "search for", 1) > 0 Then
SearchKeywords = LCase(Replace(Trim(HalBrain.AlphaNumericalOnly(HalBrain.ExtractKeywords(UserSentence))), "search for ", ""))
SearchKeyWords = Replace(SearchKeywords, "search", "")
SearchKeyWords = captializeFirstLetter(SearchKeywords)
SearchKeyWords = Replace(SearchKeywords, " ", "_")
GetResponse = searchWiki(SearchKeyWords)
End If
Rem PLUGIN: FUNCTIONS
'===================================
'Capitalize each keyword (some wiki searches are case sensitive)
Function captializeFirstLetter(SearchKeyWords)
Dim strText, arrText, Word
strText = ""
arrText = Split(SearchKeyWords," ")
For Each Word In arrText
strText = strText & ucase(left(Word, 1)) & mid(Word, 2) & " "
Next
strText = left(strText,len(strText)-1)
strText = right(strText,len(strText)-1)
captializeFirstLetter = strText
End Function
'WaitForLoad() waits for webpage to finish loading before grabbing the content
Function WaitForLoad(ie)
Do while ie.Busy or ie.readystate <> 4
'not used currently
Loop
End Function
'Open windows Internet explorer and go to the specific element of the website
Function searchWiki(SearchKeyWords)
set ie = CreateObject("InternetExplorer.Application")
With ie
.Navigate "
https://en.wikipedia.org/wiki/"&SearchKeyWords&""
.Toolbar=0
.StatusBar=0
.Height=560
.Width=1000
.Top=0
.Left=0
.Resizable=0
WaitForLoad(ie)
.Visible = false
end with
dim element
dim counter
dim item
'the id (mw-content-text) currently stores the content inside separate <p> tags on wikipedia, this will work until they change there layout (HTML) structure
dim ieObject : Set ieObject = ie.document.getElementById("mw-content-text")
'target the element that is storing the content
Set element = ieObject.getElementsByTagName("p")
counter = 1
For Each x In element
'Here i'm targeting the first <p> only I dont want Hal reading the entire page, just the most important portion
If(counter < 2) Then
'get content from <p>
content = x.innerText
'remove special chars from content, I'm sure this can be done better
badchars = Array("[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","?","/","\",":","*","""","<",">","","&","#","~","%","{","}","+","_","(",")",";","'")
for each badchar in badchars
content = replace( content, badchar, "" )
next
'if there is no content available
'possible reasons would be if there are multiple results for the same name or just a bad search string
'check if certain keywords exist, if they do we know wikipedia has multiple selections or no results
if inStr(content, "Other reasons") or inStr(content, "may refer to") then
'im just displaying this for now
searchWiki = "Sorry, I can't find anything"
else
searchWiki = content
end if
End If
counter = counter + 1
Next
End Function
For input I'm saying " Do a wiki search for Bill Gates" The above did not copy correctly and there are words
on the right side that were moved from the left side.
Carl2