Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 23rd, 2012  |  syntax: mIRC  |  size: 7.21 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;.oO{ Google v1.9 by HM2K }Oo. - www.hm2k.org
  2.  
  3. ;Installation: Make sure google.mrc is in your $mircdir then type: /load -rs google.mrc
  4.  
  5. ;Usage: /g or /google <string> or /gs or /googlesay <string> (There is also a popup menu)
  6.  
  7. ;Google v1.9 - Changed the error message to be more in line with what google does now
  8. ;Google v1.8 - Revamped some of the code a little
  9. ;Google v1.7 - Resorted back to the simple method, fixed a few relaying bugs
  10. ;Google v1.6 - Changed the lookup method to a more complicated one (it means the script is more flexable), and added total results to the output, debug mode was added too.
  11. ;Google v1.5 - Added simple flood protection, and urlencoding.
  12. ;Google v1.4 - Completly changed most of the way the script works including the output.
  13. ;Google v1.3 - Original public release.
  14.  
  15. ;Settings
  16. alias -l google.ver return Google v1.9
  17. alias -l google.server return www.google.com
  18. alias -l google.prefix return * Google:
  19.  
  20. ;Code
  21. alias letme say http://letmegooglethatforyou.com/?q= $+ $urlencode($1-)
  22.  
  23. alias -l google.out return $google.relay($1-) $google.prefix
  24. alias -l google.relay {
  25.   var %out echo $color(info2) -gat
  26.   if ($modespl) {
  27.     if ($1) {
  28.       if (($ifmatch != Status Window) && ($ifmatch != -)) {
  29.         if ($left($1,1) != $chr(35)) { var %out msg $1 }
  30.         elseif ($chan($1)) { var %out msg $1 }
  31.       }
  32.     }
  33.     elseif (($nick) && ($nick != $me)) var %out notice $nick
  34.   }
  35.   return %out
  36. }
  37.  
  38. alias g google $1-
  39. alias gs googlesay $1-
  40.  
  41. alias google {
  42.   if (!$1) { $google.out Usage: google (-<server>) <text> | halt }
  43.   if ($left($1,1) == -) { var %server = $right($1,-1) }
  44.   google.open $iif(%server,%server,$google.server) $google.encode($iif(%server,$2-,$1-))
  45.   if (imdb isin $1-) { set %il 1 } | else { set %il 0 }
  46.   ;echo -a %il
  47. }
  48. alias googlesay {
  49.   if (!$1) { $google.out Usage: google (-<server>) <text> | halt }
  50.   if ($left($1,1) == -) { var %server = $right($1,-1) }
  51.   if ($left($1,1) == @) { var %nick = $right($1,-1) }
  52.   google.open $iif(%server,%server,$google.server) $google.encode($iif(%server,$2-,$1-)) $active %nick
  53. }
  54.  
  55. #!google off
  56. on *:text:!google*:*: {
  57.   if (!$2) { $google.out($iif($chan,$chan,$nick)) Usage: google <text> | return }
  58.   if ($1 == !googleuk) { var %server = www.google.co.uk }
  59.   if ($1 == !google2) { var %server = www2.google.com }
  60.   if ($1 == !google3) { var %server = www3.google.com }
  61.   google.open $iif(%server,%server,$google.server) $google.encode($2-) $iif($chan,$chan,$nick) $nick
  62.   $repeatcheck(!google)
  63. }
  64. #!google end
  65.  
  66. alias -l repeatcheck { ;v0.12 by HM2K - will disable the appropriate group if its flooded
  67.   var %rep.lim = 3
  68.   var %rep.t.lim = 25
  69.   var %rep.t.expr = 10
  70.   if (%rep.lockusr- [ $+ [ $nick ] ]) { echo $ifmatch | haltdef }
  71.   inc $+(-u,%rep.t.lim,$chr(32),%,rep-,$nick,.,$len($strip($1-)),.,$hash($strip($1-),32)) 1
  72.   if (%rep- [ $+ [ $nick ] $+ . $+ [ $len($strip($1-)) ] $+ . $+ [ $hash($strip($1-),32) ] ] == %rep.lim) {
  73.     ;ignore -u60 $address($nick,5)
  74.     if ($group($chr(35) $+ $1) == on) { .disable $chr(35) $+ $1 | .echo -gat $1 is $group($chr(35) $+ $1) due to a repeat flood from $iif($chan,$nick in $chan,$nick) $+ , to re-enable: /enable $chr(35) $+ $1 }
  75.     .set $+(-u,%rep.t.expr,$chr(32),%,rep.lockusr-,$nick) 1
  76.   }
  77. }
  78.  
  79. alias -l google.encode {
  80.   return $urlencode($strip($1-))
  81. }
  82.  
  83. alias -l google.open { ;Usage: <server[:port]> <text> [nick/chan]
  84.   if (!$1) { $google.out Usage: google.open <server[:port]> <text> [nick/chan] | halt }
  85.   if ($sock($google.id($2))) { sockclose $google.id($2) }
  86.   if ($1) { sockopen $google.id($2) $iif(: isin $1,$replace($1,:,$chr(32)),$1 80) }
  87.   else { $google.out Usage: google.open <server[:port]> <text> [nick/chan] | halt }
  88.   set % $+ $google.id($2) $1 $strip($2) $3
  89. }
  90.  
  91. alias -l google.id { return google. $+ $md5($1) }
  92.  
  93. on *:sockopen:google.*: {
  94.   if ($sockerr > 0) { return }
  95.   sockwrite -tn $sockname HEAD /search?btnI=&q= $+ $gettok($(% $+ $sockname,2),2,32) HTTP/1.0
  96.   sockwrite -tn $sockname $crlf
  97. }
  98. on *:sockread:google.*: {
  99.   if ($sockerr > 0) { return }
  100.   :i
  101.   if ($sock($sockname) != $null) { sockread -f %y }
  102.   if ($sockbr == 0) { return }
  103.  
  104.   if (Location: isin %y) {
  105.     var %y $gettok(%y,2,32)
  106.     if ($left(%y,1) == /) var %y $+(http://,$sock($sockname).addr,%y)
  107.     sockmark $sockname %y
  108.     halt
  109.   }
  110.  
  111.   goto i
  112. }
  113. on *:sockclose:google.*: {
  114.   if (%il) {
  115.     ;echo -a  $remove($sock($sockname).mark,http://www.imdb.com)
  116.     set %imdburl $$sock($sockname).mark
  117.     xx
  118.   }
  119.   elseif (KKROTTO == homem) {
  120.     var %out $iif($sock($sockname).mark,$sock($sockname).mark,Google wasn't feeling lucky.) See: $+(http://,$sock($sockname).addr,/search?q=,$gettok($(% $+ $sockname,2),2,32))
  121.     $google.out($iif($gettok($(% $+ $sockname,2),3,32),$ifmatch,)) %out
  122.     unset $(% $+ $sockname,1)
  123.   }
  124. }
  125.  
  126. menu status,menubar,channel,query {
  127.   $google.ver
  128.   .Google Search: { google $?="text?" }
  129.   .Google Say: { googlesay $?="text?" }
  130.   .!google trigger $group(#!google) : {
  131.     if ($group(#!google) == off) { .enable #!google | google.out !google is enabled }
  132.     else { .disable #!google | google.out !google is disabled }
  133.   }
  134. }
  135.  
  136. alias -l urlencode {
  137.   var %t = $len($1-),%r = "",%c
  138.   while (%t) {
  139.     %c = $asc($right($1,%t))
  140.     if (%c == 32) { %c = + }
  141.     elseif ((%c <= 32) || (%c == 34) || (%c == 38) || (%c == 43) || (%c >= 127)) { %c = % $+ $base($ifmatch,10,16,2) }
  142.     else { %c = $chr(%c) }
  143.     %r = %r $+ %c
  144.     dec %t
  145.   }
  146.   return %r
  147. }
  148. #google.sockdebug off
  149. ;debug mode for sockets v0.02 by HM2K
  150. alias -l sockdebug {
  151.   var %win @sockdebug
  152.   if (!$window(%win)) { window -e %win }
  153.   if ($1-) { aline %win $timestamp $1- }
  154. }
  155. alias -l sockopen {
  156.   sockopen $1-
  157.   sockdebug -> sockopen $1-
  158. }
  159. alias -l sockwrite {
  160.   sockwrite $1-
  161.   sockdebug > sockwrite $1-
  162. }
  163. alias -l sockread {
  164.   sockread $($1-,1)
  165.   sockdebug < sockread $sockname $($1-,2)
  166. }
  167. alias -l sockclose {
  168.   sockclose $1-
  169.   sockdebug <- sockclose $1-
  170. }
  171. #google.sockdebug end
  172.  
  173. ;EOF
  174.  
  175. http://www.imdb.com/title/tt0947798/
  176.  
  177. on *:sockread:xx:{
  178.   var %xxx
  179.   inc %xl
  180.   sockread %xxx
  181.   ;echo [[ %xl  ]] %xxx
  182.   ;if (%xl == 33) { echo -a 4 %xxx }
  183.   ;; linha 33 ou 35 ;;
  184.   ;if (<title> isin %xxx) { set %infoo $uu($remove(%xxx,<title>,</title>)) - %imdburl }
  185.   if (<br /><span class="title-extra"> isin %xxx) { set %xl1 $calc(%xl + 1) }
  186.   if (%xl == %xl1) { set %infoo $uu($remove(%xxx,<title>,</title>)) - %imdburl }
  187.   if (<div class="star-box-giga-star"> isin %xxx) { set %xl2 $calc(%xl + 1) }
  188.   ;;NOTA
  189.   if (%xl == %xl2) { msg %ll %infoo - Nota: %xxx | sockclose * }
  190.   ;if (%xl == 611) { echo -a %xxx | sockclose xx }
  191. }
  192.  
  193. alias xx {
  194.   sockclose xx
  195.   set %xl 0
  196.   unset %xl2
  197.   unset %infoo
  198.   sockopen xx www.imdb.com 80
  199. }
  200.  
  201. alias uu return $regsubex($replace($1,+,$chr(32)),/%([A-F\d]{2})/gi,$chr($base(\1,16,10)))
  202. on *:sockopen:xx:{
  203.   if ($sockerr) { echo unable to connect | halt }
  204.   else {
  205.     sockwrite -n $sockname GET %imdburl HTTP/1.1
  206.     sockwrite -n $sockname Host: www.imdb.com
  207.     ;sockwrite -n $sockname Connection: keep-alive
  208.     sockwrite -n $sockname Content-type: text/plain
  209.     sockwrite -n $sockname $crlf
  210.  
  211.   }
  212. }
  213.  
  214. on *:INPUT:*: set %ll $active | if ($1 == !nota) { g $2- imdb }
  215. on *:text:!nota*:*: set %ll $active | if ($1 == !nota) { g $2- imdb }