Advertisement
mruno

!slang without color

Dec 1st, 2013
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 8.17 KB | None | 0 0
  1. ;Urban Dictionary Script by Ford_Lawnmower irc.GeekShed.net #Script-Help
  2. ;modified by mruno
  3.  
  4. menu Channel,Status {
  5.   .$iif($group(#Slang) == On,$style(1)) Slang Trigger
  6.   ..$iif($group(#Slang) == On,$style(2)) On: .enable #Slang
  7.   ..$iif($group(#Slang) == Off,$style(2)) Off: .disable #Slang
  8.   ..Add Badwords: {
  9.     if (!$hget(censored)) { hmake censored 5 }
  10.     $?="Enter the badword"
  11.     if ($!) {
  12.       if (!$hfind(censored,$!).data) {
  13.         hadd  censored $calc($hget(censored,0).item + 1) $!
  14.         echo -a $! added to badword list
  15.       }
  16.       else { echo -a $! is already in my database. }
  17.     }
  18.   }
  19.   ..Delete Badwords: {
  20.     $?="Enter the bad word or the item number!"
  21.     if ($!) {
  22.       if ($! isnum) && ($hget(censored,$!)) {
  23.         echo -a $hget(censored,$!) was deleted!
  24.         hdel  censored $!
  25.         halt
  26.       }
  27.       if ($! isalpha) && ($hfind(censored,$!).data) {
  28.         echo -a $! has been deleted from my database!
  29.         hdel censored $hfind(censored,$!).data
  30.       }
  31.       else { echo -a Can't find $! in my database. Try checking the list. }
  32.     }
  33.   }
  34.   ..List Badwords:censored.list
  35. }
  36. #Slang on
  37. On $*:Text:/^(\+|-|!|@)(Slang|ud).*/Si:#: {
  38.   var %action $regml(1)
  39.   if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
  40.     if (%action == +) {
  41.       if ($istok(%SlangChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Slang script }
  42.       else {
  43.         .enable #Slang
  44.         Set %SlangChanList $addtok(%SlangChanList,$+($network,$chan),32)
  45.         .msg $chan $nick has activated the Slang script for $chan .
  46.       }
  47.     }
  48.     else {
  49.       if (!$istok(%SlangChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Slang script }
  50.       else {
  51.         Set %SlangChanList $remtok(%SlangChanList,$+($network,$chan),1,32)
  52.         .msg $chan $nick has deactivated the Slang script for $chan .
  53.       }
  54.     }
  55.   }
  56.   elseif (!$timer($+(Slang,$network,$nick))) && ($istok(%SlangChanList,$+($network,$chan),32)) {
  57.     .timer $+ $+(Slang,$network,$nick) 1 6 noop
  58.     var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%|\+)/),.msg $chan,.notice $nick))
  59.     GetSlang %method $2-
  60.   }
  61. }
  62. #Slang end
  63. alias slang { GetSlang echo -a $1- }
  64. alias -l GetSlang {
  65.   var %sockname $+(SlangUD,$network,$2,$ticks)
  66.   var %SlangUD.url $iif($3,$replace($+(/define.php?page=,$iif($ceil($calc($3 / 7)),$v1,1),&term=,$iif($3 !isnum,$3-,$4-)),$chr(32),+),/random.php)
  67.   sockopen %sockname www.urbandictionary.com 80
  68.   sockmark %sockname $1-2 %SlangUD.url $iif($3 isnum,$iif($calc($3 % 7),$v1,7),1) 0 0
  69. }
  70. On *:sockopen:SlangUD*: {
  71.   if (!$sockerr) {
  72.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.1
  73.     sockwrite -n $sockname Host: www.urbandictionary.com
  74.     sockwrite -n $sockname $crlf
  75.   }
  76.   else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  77. }
  78. On *:sockread:SlangUD*: {
  79.   if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  80.   else {
  81.     var %SlangUD | sockread %SlangUD
  82.     if (Location: http://www.urbandictionary.com/define.php?term isin %SlangUD) {
  83.       GetSlang $gettok($sock($sockname).mark,1-2,32) 1 $gettok(%SlangUD,-1,61)
  84.       sockclose $sockname
  85.       return
  86.     }
  87.     if (<div id='not_defined_yet'> isin %SlangUD) { $gettok($sock($sockname).mark,1-2,32) Sorry that word has yet to be defined. }
  88.     ;if (<td class='index'> isin %SlangUD) { sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32)  }
  89.     if (<a class="index" isin %SlangUD) { sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32)  }
  90.     if ($gettok($sock($sockname).mark,5,32) == $gettok($sock($sockname).mark,4,32)) {
  91.       if ($gettok($sock($sockname).mark,6,32) == word) && ($httpstrip(%SlangUD)) {
  92.         if (<span style='font-weight: normal'> !isin %SlangUD) { $gettok($sock($sockname).mark,1-2,32) Word - $censored($httpstrip(%SlangUD)) }
  93.         sockmark $sockname $puttok($sock($sockname).mark,0,6,32)
  94.       }
  95.       if ($regex(%SlangUD,/<div class=['"]([^>]*)['"]>/)) { sockmark $sockname $puttok($sock($sockname).mark,$regml(1),6,32)  }
  96.       if ($gettok($sock($sockname).mark,6,32) == definition && $regex(def,%SlangUD,/<div class="definition">(.*)<div class="example">(.*)<\/div>/)) {
  97.         put $gettok($sock($sockname).mark,1-2,32) Definition - $censored($replace($httpstrip($regml(def,1)),$chr(13),$chr(32)))
  98.         put $gettok($sock($sockname).mark,1-2,32) Example - $censored($replace($httpstrip($regml(def,2)),$chr(13),$chr(32)))
  99.       }
  100.       if ($gettok($sock($sockname).mark,6,32) == example && $httpstrip(%SlangUD)) { put $gettok($sock($sockname).mark,1-2,32) Example - $censored($replace($v1,$chr(13),$chr(32))) }
  101.       if (<a href="/author.php?author= isin %SlangUD) {
  102.         put $gettok($sock($sockname).mark,1-2,32) Author - $censored($httpstrip(%SlangUD) - $+(http://www.urbandictionary.com,$gettok($sock($sockname).mark,3,32)))
  103.         sockclose $sockname
  104.         return
  105.       }
  106.       if (%SlangUD == <td class='word'>) { sockmark $sockname $puttok($sock($sockname).mark,word,6,32) }
  107.     }
  108.   }
  109. }
  110. alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) | return $remove($replace(%x,&amp;,&,&quot;,",&gt;,>,&lt;,<),&nbsp;,&lt;) }
  111. alias -l Put {
  112.   if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text  | return }
  113.   tokenize 32 $fix&#($regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t)))
  114.   var %tokens $0, %Tstart 3, %Dtimer 1500
  115.   if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }  
  116.   while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
  117.     dec %tokens
  118.     if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
  119.       .timer -m 1 %Dtimer $1-2 $+($($+($,%Tstart,-,%tokens),2)))
  120.       inc %Dtimer 1500
  121.       %Tstart = $calc(%tokens + 1)
  122.       %tokens = $0
  123.     }
  124.   }
  125.   .timer -m 1 %Dtimer $1-2 $+($($+($,%Tstart,-,%tokens),2)))
  126.   .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
  127. }
  128. alias censored {
  129.   if (!$hget(censored)) { hmake censored 5 }
  130.   var %censored.string = $1-, %censored.words = $gettok($1-,0,32)
  131.   while %censored.words {
  132.     if ($hfind(censored,$left($gettok(%censored.string,%censored.words,32),4) $+ *,1,w).data) || ($hfind(censored,$gettok(%censored.text,%censored.word,32)).data) {
  133.       %censored.string = $replace(%censored.string,$gettok(%censored.string,%censored.words,32),!@#&)
  134.     }
  135.     dec %censored.words
  136.   }
  137.   return %censored.string
  138. }
  139. alias censored.list {
  140.   var %censored.counter = $hget(censored,0).item
  141.   while %censored.counter {
  142.     echo -a $hget(censored,%censored.counter).item $hget(censored,%censored.counter).data
  143.     dec %censored.counter
  144.   }
  145. }
  146. alias -l fix&# {
  147.   return $regsubex($regsubex($replace($regsubex($1-,/\&\#([0-9]{1,});/g,$utf8(\t)),&quot;,",&amp;,&,&gt;,>,&lt;,<,&#39;,',$chr(9),$chr(32)),$&
  148.     /([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t)),/\&\#x([0-9a-f]{1,});/gi,$H2U(\t))
  149. }
  150. alias -l UTF8 {
  151.   if ($version >= 7) return $chr($1)
  152.   elseif ($1 < 255) { return $chr($1) }
  153.   elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
  154.   elseif ($1 >= 2048) && ($1 < 65536) { return $+($chr($calc(224 + $div($1,4096))),$chr($calc(128 + $mod($div($1,64),64))),$chr($calc(128 + $mod($1,64)))) }
  155.   elseif ($1 >= 65536) && ($1 < 2097152) {
  156.     return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
  157.       $chr($calc(128 + $mod($1,64))))
  158.   }
  159. }
  160. alias -l div { return $int($calc($1 / $2)) }
  161. alias -l mod {
  162.   var %int $int($calc($1 / $2))
  163.   return $calc($1 - (%int * $2))
  164. }
  165. alias -l H2U { return $utf8($base($1,16,10)) }
  166. On *:Unload: { hfree censored }
  167. On *:Start: {
  168.   unset %UDChanList
  169.   if (!$hget(censored)) { hmake censored 5 }
  170.   if ($isfile(censored.hsh)) { hload censored censored.hsh }
  171. }
  172. On *:Exit: { if ($hget(censored)) { hsave censored censored.hsh } }
  173. On *:Disconnect: { if ($hget(censored)) { hsave censored censored.hsh } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement