All pastes #419944 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-01 19:22 UTC
rendered paste body
on $*:TEXT:/^[!@.](goog|le) */si:#: {
  if (!$2) {
    /notice $nick 1Please state an item to search.
  }
  else {
    if ($sock(google)) .sockclose google
    set %google.return /notice $nick 
    if (@ isin $1) set %google.return /msg $chan
    set %google.search $replace($2-,$chr(32),$chr(95))
    sockopen google www.google.com 80
  }
}
on *:sockopen:google: {
  sockwrite -nt $sockname GET /search?hl=en&q= $+ %google.search $+ &btnI=I%27m+Feeling+Lucky HTTP/1.1
  sockwrite -nt $sockname Host: www.google.com
  sockwrite -nt $sockname $crlf
}
on *:sockread:google: {
  var %google.read
  sockread %google.read
  if (*Location* iswm %google.read ) { set %google.url $htmlfree(%google.read)
    unset %google.read
    sockclose $sockname
  }
}
on *:sockclose:google: {
  %google.return 1You searched:4 %google.search
  %google.return 1URL:4 %google.url
  %google.return 1Can't see the URL? Type: '4/mode <your name> -f1'.
  unset %google.*
}
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&amp;) | return %x }