Advertisement
Ford

Googlism bot script

Jun 26th, 2012
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.71 KB | None | 0 0
  1. ;Googlism by Ford_Lawnmower irc.geekshed.net #Script-Help
  2. menu Channel,Status {
  3.   .$iif($group(#Googlism) == On,$style(1)) Googlism Trigger
  4.   ..$iif($group(#Googlism) == On,$style(2)) On: .enable #Googlism
  5.   ..$iif($group(#Googlism) == Off,$style(2)) Off: .disable #Googlism
  6. }
  7. #Googlism on
  8. On $*:Text:/^(\+|-|!|@)G(ooglism|wh(o|at|en|ere))\s?(.*)/Si:#: {
  9.   ;;;;;;;;;;;;;;;;;;;;;;;;;Setup Start;;;;;;;;;;;;;;;;;;;;;;;;;;;
  10.   ;;Change %delim if you want a different delimiter
  11.   var %delim 09«••09»
  12.   ;;Change %textcolor to change the text color  
  13.   var %textcolor 04
  14.   ;;Change %maxresults for more or less results  
  15.   var %maxresults 10
  16.   ;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
  17.   var %action $regml(1), %searchtext $regml(4)
  18.   var %searchdir $+($replacex($regml(3),o,/who_is/,at,/what_is/,en,/when_is/,ere,/where_is/),$left($NoIsWas($regml(4)),1),/,$urlencode($NoIsWas($regml(4))),/))
  19.   if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
  20.     if (%action == +) {
  21.       if ($istok(%GooglismChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Googlism script }
  22.       else {
  23.         .enable #Googlism
  24.         Set %GooglismChanList $addtok(%GooglismChanList,$+($network,$chan),32)
  25.         .msg $chan $nick has activated the Googlism script for $chan .
  26.       }
  27.     }
  28.     else {
  29.       if (!$istok(%GooglismChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Googlism script }
  30.       else {
  31.         Set %GooglismChanList $remtok(%GooglismChanList,$+($network,$chan),1,32)
  32.         .msg $chan $nick has deactivated the Googlism script for $chan .
  33.       }
  34.     }
  35.   }
  36.   elseif (!$timer($+(Googlism,$network,$nick))) && ($istok(%GooglismChanList,$+($network,$chan),32)) {
  37.     .timer $+ $+(Googlism,$network,$nick) 1 6 noop
  38.     var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  39.     if (%searchtext) GetGooglism %method %searchdir %delim %textcolor %maxresults 0
  40.     else %method %textcolor Please provide some search terms!!
  41.   }
  42. }
  43. #Googlism end
  44. alias Googlism { GetGooglism echo -a $1- }
  45. alias -l GetGooglism {
  46.   $1-2 Searching........
  47.   var %sockname $+(Googlism,$network,$2,$ticks)
  48.   sockopen %sockname www.googlism.com 80
  49.   sockmark %sockname $1-
  50. }
  51. On *:sockopen:Googlism*: {
  52.   if (!$sockerr) {
  53.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  54.     sockwrite -n $sockname Host: www.googlism.com
  55.     sockwrite -n $sockname User-Agent: Opera 9.6
  56.     sockwrite -n $sockname $crlf
  57.   }
  58.   else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  59. }
  60. On *:sockread:Googlism*: {
  61.   if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  62.   else {
  63.     var %Googlism | sockread %Googlism
  64.     if ($gettok($sock($sockname).mark,7,32) >= $gettok($sock($sockname).mark,6,32) || (</html> isin %Googlism)) {
  65.       tokenize 32 $sock($sockname).mark
  66.       put $1-2 $5 $iif($8-,$v1,Nothing Found)
  67.       sockclose $sockname
  68.       return
  69.     }
  70.     elseif ($regex(%Googlism,/Googlism for:.*<b>(.*)</p>/)) {
  71.       $gettok($sock($sockname).mark,1-2,32) $gettok($sock($sockname).mark,5,32) $regml(1)
  72.       sockclose $sockname
  73.       return
  74.     }
  75.     elseif ($regex(%Googlism,/Googlism for:.*<br>(.*)<br\s\/>/)) {
  76.       tokenize 32 $sock($sockname).mark
  77.       sockmark $sockname $1-6 1 $+($5,$replace($regml(1),$chr(9), ,&quot;,"))
  78.     }
  79.     elseif ($gettok($sock($sockname).mark,7,32)) {
  80.       tokenize 32 $sock($sockname).mark
  81.       if (%Googlism == <p>) {
  82.         put $1-2 $5 $iif($8-,$v1,Nothing Found)
  83.         sockclose $sockname
  84.         return        
  85.       }
  86.       else { sockmark $sockname $1-6 $calc($7 + 1) $+($8-,$4,$5,$remove($replace(%Googlism,$chr(9), ,&quot;,"),<br />)) }
  87.     }
  88.   }
  89. }
  90. alias -l NoIsWas {
  91.   tokenize 32 $strip($1)
  92.   return $iif($istok(is was,$1,32),$2-,$1-)
  93. }
  94. alias -l urlencode return $regsubex($replace($1-,$chr(32),_),/([^a-z0-9_])/ig,% $+ $base($asc(\t),10,16,2))
  95. alias -l Put {
  96.   if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text  | return }
  97.   var %tokens $0, %Tstart 4, %Dtimer 1500
  98.   if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  99.   while ($len($($+($,%Tstart,-,%tokens),2)) > 300) {
  100.     dec %tokens
  101.     if ($len($($+($,%Tstart,-,%tokens),2)) <= 300) {
  102.       .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  103.       inc %Dtimer 1500
  104.       %Tstart = $calc(%tokens + 1)
  105.       %tokens = $0
  106.     }
  107.   }
  108.   .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  109.   .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement