Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Urban Dictionary Script by Ford_Lawnmower irc.GeekShed.net #Script-Help
- menu Channel,Status {
- .$iif($group(#Slang) == On,$style(1)) Slang Trigger
- ..$iif($group(#Slang) == On,$style(2)) On: .enable #Slang
- ..$iif($group(#Slang) == Off,$style(2)) Off: .disable #Slang
- ..Add Badwords: {
- if (!$hget(censored)) { hmake censored 5 }
- $?="Enter the badword"
- if ($!) {
- if (!$hfind(censored,$!).data) {
- hadd censored $calc($hget(censored,0).item + 1) $!
- echo -a $! added to badword list
- }
- else { echo -a $! is already in my database. }
- }
- }
- ..Delete Badwords: {
- $?="Enter the bad word or the item number!"
- if ($!) {
- if ($! isnum) && ($hget(censored,$!)) {
- echo -a $hget(censored,$!) was deleted!
- hdel censored $!
- halt
- }
- if ($! isalpha) && ($hfind(censored,$!).data) {
- echo -a $! has been deleted from my database!
- hdel censored $hfind(censored,$!).data
- }
- else { echo -a Can't find $! in my database. Try checking the list. }
- }
- }
- ..List Badwords:censored.list
- }
- #Slang on
- On $*:Text:/^(\+|-|!|@)Slang.*/Si:#: {
- var %action $regml(1)
- if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
- if (%action == +) {
- if ($istok(%SlangChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Slang script }
- else {
- .enable #Slang
- Set %SlangChanList $addtok(%SlangChanList,$+($network,$chan),32)
- .msg $chan $nick has activated the Slang script for $chan .
- }
- }
- else {
- if (!$istok(%SlangChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Slang script }
- else {
- Set %SlangChanList $remtok(%SlangChanList,$+($network,$chan),1,32)
- .msg $chan $nick has deactivated the Slang script for $chan .
- }
- }
- }
- elseif (!$timer($+(Slang,$network,$nick))) && ($istok(%SlangChanList,$+($network,$chan),32)) {
- .timer $+ $+(Slang,$network,$nick) 1 6 noop
- var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%|\+)/),.msg $chan,.notice $nick))
- GetSlang %method $2-
- }
- }
- #Slang end
- alias slang { GetSlang echo -a $1- }
- alias -l GetSlang {
- var %sockname $+(SlangUD,$network,$2,$ticks)
- 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)
- sockopen %sockname www.urbandictionary.com 80
- sockmark %sockname $1-2 %SlangUD.url $iif($3 isnum,$iif($calc($3 % 7),$v1,7),1) 0 0
- }
- On *:sockopen:SlangUD*: {
- if (!$sockerr) {
- sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.1
- sockwrite -n $sockname Host: www.urbandictionary.com
- sockwrite -n $sockname $crlf
- }
- else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
- }
- On *:sockread:SlangUD*: {
- if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
- else {
- var %SlangUD | sockread %SlangUD
- if (Location: http://www.urbandictionary.com/define.php?term isin %SlangUD) {
- GetSlang $gettok($sock($sockname).mark,1-2,32) 1 $gettok(%SlangUD,-1,61)
- sockclose $sockname
- return
- }
- if (<div id='not_defined_yet'> isin %SlangUD) { $gettok($sock($sockname).mark,1-2,32) Sorry that word has yet to be defined. }
- if (<td class='index'> isin %SlangUD) { sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32) }
- if ($gettok($sock($sockname).mark,5,32) == $gettok($sock($sockname).mark,4,32)) {
- if ($gettok($sock($sockname).mark,6,32) == word && $httpstrip(%SlangUD)) {
- if (<span style='font-weight: normal'> !isin %SlangUD) { $gettok($sock($sockname).mark,1-2,32) Word $censored($httpstrip(%SlangUD)) }
- sockmark $sockname $puttok($sock($sockname).mark,0,6,32)
- }
- if ($regex(%SlangUD,/<div class=['"]([^>]*)['"]>/)) { sockmark $sockname $puttok($sock($sockname).mark,$regml(1),6,32) }
- if ($gettok($sock($sockname).mark,6,32) == definition && $regex(def,%SlangUD,/<div class="definition">(.*)<div class="example">(.*)<\/div>/)) {
- put $gettok($sock($sockname).mark,1-2,32) Definition $censored($replace($httpstrip($regml(def,1)),$chr(13),$chr(32)))
- ;put $gettok($sock($sockname).mark,1-2,32) 06Example -04 $censored($replace($httpstrip($regml(def,2)),$chr(13),$chr(32)))
- }
- if ($gettok($sock($sockname).mark,6,32) == example && $httpstrip(%SlangUD)) { ;put $gettok($sock($sockname).mark,1-2,32) 06Example -04 $censored($replace($v1,$chr(13),$chr(32))) }
- if (<a href="/author.php?author= isin %SlangUD) {
- ;put $gettok($sock($sockname).mark,1-2,32) 06Author -04 $censored($httpstrip(%SlangUD) - $+(07,http://www.urbandictionary.com,$gettok($sock($sockname).mark,3,32)))
- sockclose $sockname
- return
- }
- if (%SlangUD == <td class='word'>) { sockmark $sockname $puttok($sock($sockname).mark,word,6,32) }
- }
- }
- }
- alias -l httpstrip { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x) | return $remove($replace(%x,&,&,",",>,>,<,<), ,<) }
- alias -l Put {
- if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text | return }
- var %tokens $0, %Tstart 3, %Dtimer 1500
- if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }
- while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
- dec %tokens
- if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
- .timer -m 1 %Dtimer $1-2 $+(04,$($+($,%Tstart,-,%tokens),2)))
- inc %Dtimer 1500
- %Tstart = $calc(%tokens + 1)
- %tokens = $0
- }
- }
- .timer -m 1 %Dtimer $1-2 $+(04,$($+($,%Tstart,-,%tokens),2)))
- .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
- }
- alias censored {
- if (!$hget(censored)) { hmake censored 5 }
- var %censored.string = $1-, %censored.words = $gettok($1-,0,32)
- while %censored.words {
- if ($hfind(censored,$left($gettok(%censored.string,%censored.words,32),4) $+ *,1,w).data) || ($hfind(censored,$gettok(%censored.text,%censored.word,32)).data) {
- %censored.string = $replace(%censored.string,$gettok(%censored.string,%censored.words,32),!@#&)
- }
- dec %censored.words
- }
- return %censored.string
- }
- alias censored.list {
- var %censored.counter = $hget(censored,0).item
- while %censored.counter {
- echo -a $hget(censored,%censored.counter).item $hget(censored,%censored.counter).data
- dec %censored.counter
- }
- }
- On *:Unload: { hfree censored }
- On *:Start: {
- unset %UDChanList
- if (!$hget(censored)) { hmake censored 5 }
- if ($isfile(censored.hsh)) { hload censored censored.hsh }
- }
- On *:Exit: { if ($hget(censored)) { hsave censored censored.hsh } }
- On *:Disconnect: { if ($hget(censored)) { hsave censored censored.hsh } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement