- Code: Select all
on *:TEXT:!google*:#: {
if (!$2) { notice $nick Syntax: $1 <google search string> }
else {
notice $nick Connecting..
var %s = google. $+ $ticks | sockopen %s http://www.google.co.uk 80 | sockmark %s $replace($1-,$chr(32),+) 1 1 $chan
}
}
on *:sockopen:google.*:{
tokenize 32 $sock($sockname).mark
if ($sockerr) { echo -at Google: Unable to open connection to google.co.uk $sock($sockname).wsmsg | halt }
var %s = sockwrite -n $sockname
%s GET /search?hl=en&q= $+ $1 $+ &btnI=Google+Search&meta= HTTP/1.0
%s Host: http://www.google.co.uk
%s User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
%s Connection: keep-alive
%s $crlf
}
on *:sockread:google.*:{
tokenize 32 $gettok($sock($sockname).mark,1,32)
var %all
sockread %all
if (Location: * iswm %all) {
msg $gettok($sock($sockname).mark,2,32) First result for $replace($1,+,$chr(32)) $remove(%all,Location:,$chr(32)))
sockclose $sockname
}
if (Your search* *did not match any documents iswm %all) {
msg $gettok($sock($sockname).mark,2,32) Google: No results for $+(",$replace($1,+,$chr(32)),",)
sockclose $sockname
}
}