;; GOOGLE! /google.go <channel> <search string>
alias google {
sockclose google
sockopen google google.com 80
%google.temp = $1-
}
on 1:sockopen:google:{
if ($sockerr > 0) return
sockwrite -n google $eval(GET http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=,0) $+ $replace(%google.temp,$chr(32),+) $+ $eval(&btnI=I%27m+Feeling+Lucky HTTP/1.0,0)
sockwrite -n google
}
on 1:sockread:google:{
if ($sockerr > 0) return
:nextread
sockread %google.temp
if ($sockbr == 0) return
if (Location: isin %google.temp) {
if (%google.chan) { msg %google.chan Google says: $+ $right(%google.temp,-10) $+ }
sockclose google | return
}
elseif (did not match any documents isin %google.temp) {
if (%google.chan) { msg %google.chan Google says: nothing... no matches found }
sockclose google | return
}
goto nextread
}
on 1:sockclose:google:{
unset %google.*
}
alias google.go {
set -u300 %google.activ $true
set %google.chan $1
google $2-
}