Share Pastebin
Guest
Public paste!

[DA]Jared

By: a guest | Mar 20th, 2010 | Syntax: None | Size: 4.82 KB | Hits: 61 | Expires: Never
Copy text to clipboard
  1.  
  2.   .$iif($group(#UD) == On,$style(1)) Urban Dictionary
  3.   ..$iif($group(#UD) == On,$style(2)) Trigger On: .enable #UD
  4.   ..$iif($group(#UD) == Off,$style(2)) Trigger Off: .disable #UD
  5. }
  6. #UD off
  7. On $*:Text:/^(!|@)Slang.*/Si:#: {
  8.   if (!$timer($+(UD,$network,$nick))) {
  9.     .timer $+ $+(UD,$network,$nick) 1 6 noop
  10.     var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
  11.     UD %method $2-
  12.   }
  13. }
  14. #UD end
  15. alias slang { UD echo -a $1- }
  16. alias -l UD {
  17.   var %sockname $+(UD,$network,$2,$ticks)
  18.   var %UD.url $iif($3,$replace($+(/define.php?page=,$iif($ceil($calc($3 / 7)),$v1,1),&term=,$iif($3 !isnum,$3-,$4-)),$chr(32),+),/random.php)
  19.   sockopen %sockname www.urbandictionary.com 80
  20.   sockmark %sockname $1-2 %UD.url $iif($3 isnum,$iif($calc($3 % 7),$v1,7),1) 0 0
  21. }
  22. On *:sockopen:UD*: {
  23.   if (!$sockerr) {
  24.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.1
  25.     sockwrite -n $sockname Host: www.urbandictionary.com
  26.     sockwrite -n $sockname $crlf
  27.   }
  28.   else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  29. }
  30. On *:sockread:UD*: {
  31.   if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  32.   else {
  33.     var %UD | sockread %UD
  34.     if (Location: http://www.urbandictionary.com/define.php?term isin %UD) {
  35.       UD $gettok($sock($sockname).mark,1-2,32) 1 $gettok(%UD,-1,61)
  36.       sockclose $sockname
  37.       return
  38.     }
  39.     if (<div id='not_defined_yet'> isin %UD) { $gettok($sock($sockname).mark,1-2,32) Sorry that word has yet to be defined. }
  40.     if (<td class='index'> isin %UD) { sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32)  }
  41.     if ($gettok($sock($sockname).mark,5,32) == $gettok($sock($sockname).mark,4,32)) {
  42.       if ($gettok($sock($sockname).mark,6,32) == word && $httpstrip(%UD)) {
  43.         if (<span style='font-weight: normal'> !isin %UD) { $gettok($sock($sockname).mark,1-2,32) 06Word -04 $censored($httpstrip(%UD)) }
  44.         sockmark $sockname $puttok($sock($sockname).mark,0,6,32)
  45.       }
  46.       if ($regex(%UD,/<div class='(.*)'>/)) { sockmark $sockname $puttok($sock($sockname).mark,$regml(1),6,32) }      
  47.       if ($gettok($sock($sockname).mark,6,32) == definition && $httpstrip(%UD)) { put $gettok($sock($sockname).mark,1-2,32) 06Definition -04 $censored($replace($v1,$chr(13),$chr(32))) }
  48.       if ($gettok($sock($sockname).mark,6,32) == example && $httpstrip(%UD)) { put $gettok($sock($sockname).mark,1-2,32) 06Example -04 $censored($replace($v1,$chr(13),$chr(32))) }
  49.       if (<a href="/author.php?author= isin %UD) {
  50.         put $gettok($sock($sockname).mark,1-2,32) 06Author -04 $censored($httpstrip(%UD) - $+(07,http://www.urbandictionary.com,$gettok($sock($sockname).mark,3,32)))
  51.         sockclose $sockname
  52.         return
  53.       }
  54.       if (%UD == <td class='word'>) { sockmark $sockname $puttok($sock($sockname).mark,word,6,32) }
  55.     }
  56.   }
  57. }
  58. alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) | return $remove($replace(%x,&amp;,&,&quot;,"),&nbsp;,&lt;) }
  59. alias -l Put {
  60.   if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text  | return }
  61.   var %tokens $0, %Tstart 3, %Dtimer 1500
  62.   if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  63.   while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
  64.     dec %tokens
  65.     if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
  66.       .timer -m 1 %Dtimer $1-2 $+(04,$($+($,%Tstart,-,%tokens),2)))
  67.       inc %Dtimer 1500
  68.       %Tstart = $calc(%tokens + 1)
  69.       %tokens = $0
  70.     }
  71.   }
  72.   .timer -m 1 %Dtimer $1-2 $+(04,$($+($,%Tstart,-,%tokens),2)))
  73.   .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
  74. }
  75. alias  censored {
  76.   if (!$hget(censored)) { hmake censored 5 }
  77.   var %censored.string = $1-, %censored.words = $gettok($1-,0,32)
  78.   while %censored.words {
  79.     if ($hfind(censored,$left($gettok(%censored.string,%censored.words,32),4) $+ *,1,w).data) || ($hfind(censored,$gettok(%censored.text,%censored.word,32)).data) {
  80.       %censored.string = $replace(%censored.string,$gettok(%censored.string,%censored.words,32),!@#&)
  81.     }
  82.     dec %censored.words
  83.   }
  84.   return %censored.string
  85. }
  86. alias censored.list {
  87.   var %censored.counter = $hget(censored,0).item
  88.   while %censored.counter {
  89.     echo -a $hget(censored,%censored.counter).item $hget(censored,%censored.counter).data
  90.     dec %censored.counter
  91.   }
  92. }
  93. On *:Unload: { hfree censored }
  94. On *:Start: {
  95.   if (!$hget(censored)) { hmake censored 5 }
  96.   if ($isfile(censored.hsh)) { hload censored censored.hsh }
  97. }
  98. On *:Exit: { if ($hget(censored)) { hsave censored censored.hsh } }
  99. On *:Disconnect: { if ($hget(censored)) { hsave censored censored.hsh } }