Dim http
Dim GoogleNick
Dim GoogleServer
Dim MaxReponses
'set this to how many responses you want to show
MaxResponses = 5
Function OUTTEXT(OutgoingText)
if left(lcase(OutGoingText),8) = "!google " then
SendCommand OutGoingText
'get the current channel and server number
Google mid(OutGoingText,9),"",""
else
Outtext = OutGoingText
end if
End Function
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
if left(lcase(message),8) = "!google " and len(Message) > 8 then
Google mid(message,9),Nickname,ServerNumber
end if
End Sub
Sub Google(Search,Nick,ServerNumber)
GoogleNick = Nick
GoogleServer = ServerNumber
Set http = CreateObject("Microsoft.XmlHttp")
search = replace(search," ","%20")
search = replace(search,"&","&")
url = "http://www.google.ca/search?hl=en&q=" & search & "&btnG=Google+Search&meta="
http.onreadystatechange = getRef("ProcessData")
http.open "GET", url, True
http.send
End Sub
Function ProcessData()
if http.readyState = 4 then
if http.status = 200 then
response = http.responsetext
x=instr(response,"
")
if x = 0 then
if GoogleNick = "" then
SendCommand "/echo -a no search results"
else
SendCommand "/notice " & Nick & " no search results",GoogleServer
end if
set http = nothing
exit function
end if
webdata = mid(response,x)
linknum=0
x=0
'parse out the links
do
if left(webdata,12) = "" then
x=instr(webdata,"")
if x <> 0 then x=x+13 else exit do
googlevar1 = left(webdata,x)
i = instr(googlevar1,"")+2)
googlevar3 = left(googlevar3,instr(googlevar3,"")-1)
googlevar3 = replace(googlevar3,"","")
googlevar3 = replace(googlevar3,"","")
googlevar3 = replace(googlevar3,"&","&")
googlevar3 = replace(googlevar3,"","")
googlevar3 = replace(googlevar3,"","")
if GoogleNick = "" then
SendCommand "/echo -a " & googlevar2 & " | " & googlevar3
else
SendCommand "/notice " & GoogleNick & " " & googlevar2 & " | " & googlevar3,GoogleServer
end if
end if
end if
webdata=mid(webdata,x)
linknum=linknum+1
if linknum = MaxResponses then exit do
else
x=instr(webdata,"")
if x <> 0 then x=x+13 else exit do
webdata=mid(webdata,x)
end if
loop
set http = nothing
end if
end if
End Function