I know several other people have made scripts that use Urban Dictionary. I've seen a few of them and I like mine better :)
*******************This Script Requires mIRC 6.32 or Higher***********************
This script will work with older versions of mIRC but some text will get cut of on longer posts.
**********************************************************************************
Now then :) Because Urban Dictionary can be very offensive, I added a badword censor to this script. This might seem funny to some people, but it's not very funny when you come home from work and find you have been glined for racial slurs. If you don't add anything to the badword dictionary, then it doesn't do anything at all. FYI. It's there if you need it or want to use it.
Myself, I added some very offensive terms and racially offensive ones. The censor is very primitive. All it does is replace the words with $#%@! ;/
Anyhow! There is a !slang trigger - Syntax: !slang word|phrase || !slang number word|Phrase.
There is also a private alias - Syntax: /slang word|Phrase || /slang number word|Phrase.
Enjoy :) This is a fun script :)
***Updated Script Usage***
- Paste this code into a new remote and save it with a unique file name.
- Type +Slang in each channel you want this script to run in.
- -Slang to turn it off.
Triggers are now !slang, @slang and /slang(alias)
- !slang will notice the user.
- @slang will message the channel if the user has ops.
- /slang is a local alias to be typed from the bot.
Syntax is !slang # words here
Where ! could be @ or / and # is a number.
The number is optional.
Example: !slang 1 funny money
Example: @slang funny money
I also added a random word and attached it with !slang. If you type !slang without a number or search word it will return a random result.
18:20:03 <
Ford_Lawnmower> @slang
18:20:04 <
BOX> Word - hashist
18:20:06 <
BOX> Definition - One who believes in the principles and leads a life dedicated to the use of marijuana and spreading its virtues as the new gospel.
18:20:06 <
BOX> Example Dude you are either always stoned or talking about getting stoned you are becoming a real hashist!
18:20:07 <
BOX> Author - by samlap - http://www.urbandictionary.com/define.php?page=1&term=hashist
;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) 06Word -04 $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) 06Definition -04 $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 }
tokenize 32 $regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
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 } }