Kirby's Urban Dictionary Searcher (v.9)

By Kirby on Dec 28, 2008

It's a dictionary...no longer in a dialog!
Definitions added by everyday people like you!

Okay, so I've gotten rid of the dialog. I have only left it as a channel-bot script and a personal alias, as I have noticed that people in my network who have used this snippet did not tend to use the dialog as much.

NEW THINGS!
Bot commands!

  • Define a word - Use .ud[#] <word(s)> in a channel and the bot will message the definitions, examples, and more to the channel. There is 15 second antispam though.If you don't supply a parameter for [#], the script automatically thinks you want the first term. Word of the Day - Use .wod [1-7] in a channel to get the "Word of the Day" for the entire week. **Info about Urban Dictionary - Use ?? ud to get the total number of words added to the online database.

What really makes this script special compared to others that I've seen is that you can define multiple words, but especially the fact that you can get [size=25]ANY T ERM[/size] from the dictionary.
Whether it is term #1 for 'weenie' or term #123 for 'lol', YOU CAN GET IT!

I have also set restrictions for words that have excessively large definitions/examples, so I have provided a total list of terms available for that word, as well as a link for your convenience.

I know I could've used variables in turn for the tokenized identifiers, but I wanted to practice /sockmark and /tokenize, which has proven well in this experiment

Special thanks to Shinu and Blitzjager on Quakenet for giving me a hand with a few aliases to make this script better. =)

Here's the picture now:
Image

Updates:

Update #1 - (Mon Dec 29, 7:01 PM): Fixed author errors + added bot command (30 second floor per. player) + changed messaging the channel to 3 lines, instead of 1. (help from PunkTuReD)
Update #2 - (Sun Jan 18, 9:06 PM): Fixed $crlf error messages (thanks to NIGathan) and enabled searching for more than one definition meaning for the bot trigger (30 seconds per user).
Update #3 - (Tue Jan 20, 9:01 PM): Fixed cut-off messages by dividing them into sections + Full multi-term definitions/examples of words on bot.
Update #4 - (Thu Jan 22, 9:43 PM): Fixed error with total number of terms for multi-word terms and added an "echo" for if you're not connected to a server.
Update #5 - (Mon Mar 16, 6:53 PM): CHANGED EVERYTHING! Removed dialog, changed it into a bot script and an alias, as well as added error checks (if word does not exist or term # specified is greater than the total # added), strip bold/underline if mode +c is active in a channel, and limit text input per line (good for long definitions).
Update #6 - (Mon Mar 23, 10:41 PM): Added Word of the Day (choose between 1 - 7, number of days in a week) and another command to display total number of words added to the whole database.
Update #7 - (Tue Mar 31, 9:21 PM): Added menu function to turn parts on/off. Fixed some things too.
*Updates to come:** Menu function to turn parts of script On/Off
Enjoy! :D

;BOF

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;          Urban Dictionary Word Searcher        ;
;            Made by Kirby (Quakenet)            ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;Urban Dictionary Aliases/Identifiers;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }
alias -l bet { var %x $calc($pos($1,$2,$3) + $len($2)), %y $calc($pos($1,$4,$5) - %x) | return $mid($1,%x,%y) }
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) | return $replace(%x,&quot;,",&lt;,<,&gt;,>,$cr,$chr(32),$lf,$chr(32),&amp;,&) }
alias -l lt { var %l $1, %t $2- | tokenize 124 $sock(urban).mark | while ($len(%t) > %l) { smsg $1 $left(%t,%l) | var %t $remove(%t,$left(%t,%l)) } | if (%t) smsg $1 %t }
alias -l ltz { var %l $1, %t $2- | tokenize 124 $sock(wod).mark | while ($len(%t) > %l) { smsg $1 $left(%t,%l) | var %t $remove(%t,$left(%t,%l)) } | if (%t) smsg $1 %t }
alias -l smsg { msg $iif(c isincs $chan($1).mode,$1 $strip($2-),$1-) }

menu * {
  Urban Dictionary
  .$iif($group(#UrbanDictionary) == On,$style(1)) Urban Dictionary
  ..$iif($group(#UrbanDictionary) == On,$style(2)) On: .enable #UrbanDictionary
  ..$iif($group(#UrbanDictionary) == Off,$style(2)) Off: .disable #UrbanDictionary
  .$iif($group(#WordOfDay) == On,$style(1)) Word of the Day
  ..$iif($group(#WordOfDay) == On,$style(2)) On: .enable #WordOfDay
  ..$iif($group(#WordOfDay) == Off,$style(2)) Off: .disable #WordOfDay
  .$iif($group(#Ud) == On,$style(1)) UD Information
  ..$iif($group(#Ud) == On,$style(2)) On: .enable #Ud
  ..$iif($group(#Ud) == Off,$style(2)) Off: .disable #Ud
}

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;Search a word - Syntax: .ud[#] <word(s)>;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
#UrbanDictionary off
on $*:text:/^[.!@]ud*/Si:#: { if (!$2-) { .notice $nick [Urban Dictionary] Syntax: .ud[#] <word(s)>. } | elseif ($2-) { $iif($istok(%urbandictionary,#,32),halt,set -u1 %urbandictionary $addtok(%urbandictionary,#,32)) | if ($sock(urban)) { sockclose urban } | sockopen urban www.urbandictionary.com 80 | sockmark urban $+(#,$chr(124),$iif($remove($1,.ud) isnum 1-,$remove($1,.ud),1),$chr(124),$2-) }  }
on *:sockopen:urban: { tokenize 124 $sock(urban).mark | sockwrite -n $sockname GET $+(/define.php?page=,$ceil($calc($2 / 7)),&term=,$replace($3,$chr(32),$chr(43))) HTTP/1.0 | sockwrite -n $sockname Host: www.urbandictionary.com $+ $crlf $+ $crlf }
on *:sockread:urban: {
  tokenize 124 $sock(urban).mark
  if ($sockerr) { msg $1 * There was a problem retrieving data from the website. Please try again. }
  elseif (!$sockerr) {
    var %ud $2 | sockread %urban
    if ($regex(%urban,content=['|"](.*) - (.*) definitio(n|ns))) { sockmark urban $addmark(urban,$regml(2),124) }
    while (%ud > 7) { var $v1 $calc($v1 - 7) }
    if (<div class='definition'> isin %urban) { inc %ud.def | if (%ud.def == $2) { sockread $htmlfree(%ud.definition) | inc %udc } }
    elseif (<div class='example'> isin %urban) { inc %ud.ex | if (%ud.ex == $2) { sockread $htmlfree(%ud.example) | inc %udc } }
    elseif (<span class='date'> isin %urban) { inc %ud.date | if (%ud.date == $2) { sockread %ud.date | sockmark urban $addmark(urban,%ud.date,124) } }
    elseif (by Anonymous isin %urban) { inc %ud.author | if (%ud.author == $2) { sockmark urban $addmark(urban,Anonymous,124) | haltdef } }
    elseif ($regex(%urban,"author">(.*)</a>)) { inc %ud.author | if (%ud.author == $2) { sockmark urban $addmark(urban,$regml(1),124) | haltdef } }
    elseif (<div id='not_defined_yet'> isin %urban) { smsg $1 [Urban Dictionary] ~ Error: It appears that the word $qt($+(,$3,)) cannot be found ~ Click: $+(,http://www.urbandictionary.com/add.php?word=,$replace($3,$chr(32),$chr(43)),) to add it to the dictionary ~ Are you looking for the word: 4WEENIE? | sockclose urban | unset %ud* %urban | halt }
  }
}
on *:sockclose:urban: {
  tokenize 124 $sock(urban).mark | var %x [Urban Dictionary] ~ $+($chr(40),,$2,/,$4,,$chr(41)) ~ $+(,$3,,:) $iif($htmlfree(%ud.definition),$v1,*Definition too long*) $+($chr(40),$iif($htmlfree(%ud.example),$v1,*No example given*),$chr(41)), %y [Urban Dictionary] ~ Author: $5 ~ Date: $6 ~ Url: $replace($+(,http://www.urbandictionary.com/define.php?page=,$ceil($calc($2 / 7)),&term=,$3,),$chr(32),$chr(43))
  if (%udc != 2) { smsg $1 [Urban Dictionary] ~ Error: Unexpected or corrupt data from www.urbandictionary.com ~ Look here: $replace($+(,http://www.urbandictionary.com/define.php?page=,$ceil($calc($2 / 7)),&term=,$3,),$chr(32),$chr(43)) ~ Total number of term(s) found for $+($qt($+(,$3,)),:) $+(,$4,) $+($iif($4 == 1,term,terms),.) | unset %ud* %urban | halt }
  elseif (%udc == 2) { lt 425 %x }
  smsg $1 %y - (15 seconds until next definition) | unset %ud* %urban
}
#UrbanDictionary End

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;Word of the Day (every week) - Syntax: .wod [1-7];
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
#WordOfDay On
on $*:text:/^[.!@]wod*/Si:#: { $iif($istok(%wordofday,#,32),halt,set -u1 %wordofday $addtok(%wordofday,#,32)) | if (!$2) { sockopen wod www.urbandictionary.com 80 | sockmark wod $+(#,$chr(124),1) } | elseif ($2 isnum 1-7) { sockopen wod www.urbandictionary.com 80 | sockmark wod $+(#,$chr(124),$2) } | else { .notice $nick [Word of Day] Syntax: .wod [1~7]>. } }
on *:sockopen:wod: { sockwrite -n $sockname GET / HTTP/1.0 | sockwrite -n $sockname Host: www.urbandictionary.com $+ $crlf $+ $crlf }
on *:sockread:wod: {
  sockread %wod | tokenize 124 $sock(wod).mark
  if (<div class='word'> isin %wod) { inc %wodw | if (%wodw == $2) { sockread %wod | sockmark wod $addmark(wod,$htmlfree(%wod),124) } }
  elseif (<div class='definition'> isin %wod) { inc %wodd | if (%wodd == $2) { sockread %wod | set %wod.def $htmlfree(%wod) } }
  elseif (<div class='example'> isin %wod) { inc %wode | if (%wode == $2) { sockread %wod | set %wod.ex $htmlfree(%wod) } }
  elseif (<div class='smallcaps'> isin %wod) { inc %wods | if (%wods == $2) { sockread %wod | sockmark wod $addmark(wod,$left($gettok($htmlfree(%wod),1,32),3) $+($gettok($htmlfree(%wod),2,32),$chr(44)) $iif($date(m) == 1,$iif($date(d) <= 7,$+(0,$calc($date(yyyy) - 1))),$date(yyyy)),124) } }
  elseif ($regex(%wod,"author">(.*)</a>)) { inc %woda | if (%woda == $2) { sockmark wod $addmark(wod,$regml(1),124) } }
}
on *:sockclose:wod: { tokenize 124 $sock(wod).mark | ltz 425 [Word of Day ~ $+(,$2,,]) ~ $+(,$3,,:) %wod.def $+($chr(40),%wod.ex,$chr(41)) | ltz 425 [Word of Day] ~ Author: $5 ~ Date: $4 ~ Url: Check the homepage @ http://www.urbandictionary.com/ - (15 seconds until next word of the day) | unset %wod* }
#WordOfDay End

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;What is Urban Dictionary? - Syntax: ?? ud;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
#Ud On
on $*:text:/^(\?\?) (ur(b|a|n)|ud|def(i|n|e))/Si:#: { sockopen total www.urbandictionary.com 80 | sockmark total # }
on *:sockopen:total: { sockwrite -n $sockname GET / HTTP/1.0 | sockwrite -n $sockname Host: www.urbandictionary.com $+ $crlf $+ $crlf }
on *:sockread:total: { sockread %total | if (<div class='count'> isin %total) { sockread %total | tokenize 32 $sock(total).mark | smsg $1 Urban Dictionary is the slang dictionary you wrote. Define your world. ~ $+(04,%total definitions written since 1999.) } }
#Ud End

;EOF

Comments

Sign in to comment.
dma   -  Oct 10, 2015

still working in 2015 thanks kirby only problem is i get this msg
[Urban Dictionary] ~ Error: Unexpected or corrupt data from www.urbandictionary.com ~

i have to click a link to se the word... tnx

rebel9  -  Oct 25, 2015

I fixed it if you want my version of it

dma  -  Oct 27, 2015

nahh it's ok... it works fine .. i wanted to change the color to light grey.. any suggestions???

dma  -  Oct 27, 2015

14 cock blocker: [121] (15 These nigs haven't defined anything like that yet.)
i want that to be light grey plz

Sign in to comment

chachin   -  Sep 15, 2011

this script was so cool before but now i got it a few days and every time i try to do !ud or .ud or anything ud it gives me this:

[6:42:58pm] <~chachin> .ud2 steve jobs
[6:42:59pm] [Urban Dictionary] ~ Error: Unexpected or corrupt data from www.urbandictionary.com ~ Look here: http://www.urbandictionary.com/define.php?page=1&term=steve+jobs ~ Total number of term(s) found for "steve jobs": Apr 24, 2008 terms.

Aurora801  -  Dec 25, 2013

I get the same thing

Sign in to comment

WarHawks24   -  Sep 02, 2010

ok nvm... somethign went wrong but i just took out the % and itsok now

Can you explain that to me? I'm having the same issue

 Respond  
Jethro   -  Jun 21, 2010

Even though kirby's been inactive for some time now, his snippets have not ceased to gain responses...especially the one he made about youtube url detector, which has people baffled for a fix. kirby, wherever you are, come back once more and rescue those who've been your loyal fans...then you can vanish at your leisure afterward.

 Respond  
xplo   -  Jun 21, 2010

u know what i would love to see in it.

$iif($left($1,1) == @,.msg $chan,.notice $nick)

Giving a "standard" in bot commands is something i like.

on my bots i try to use this all the time. so when a script is triggered with ! or . its sending the /notice, and when @ is used its msg #
i am using a lots of script found in hawkee.com on the bot, and i had a hard time moding all of them :P
Keep it in mind :P "Standardize your bots" heh

 Respond  
Kirby   -  Feb 10, 2010

I will get back to this as soon as possible.

 Respond  
Weapon-X   -  Nov 15, 2009

When I trigger the script from my bot:

[22:04] <+Weapon-X> !ud cock block
[22:04] <+Botthole> [Urban Dictionary] ~ (1/90) ~ cock block: Trudy and Dan frequently had time alone but her cockblocking roommate ruined any chances they had to have sex. (No example given)
[22:04] <+Botthole> [Urban Dictionary] ~ Author: Apr 13, 2003 ~ Date: ~ Url: http://www.urbandictionary.com/define.php?page=1&term=cock+block - (15 seconds until next definition)

[22:04] <+Weapon-X> !wod 1
[22:04] <+Botthole> [Word of Day ~ 1] ~ gaydar detector: (Les's gaydar detector was going crazy when she drove to Laramie.)
[22:04] <+Botthole> [Word of Day] ~ Author: ~ Date: Nov 15, 2009 ~ Url: Check the homepage @ http://www.urbandictionary.com/ - (15 seconds until next word of the day)

The first line, where it gives the definition of the word, does not get posted.

 Respond  
Cold_Fussion   -  Nov 11, 2009

ok nvm... somethign went wrong but i just took out the % and itsok now

 Respond  
Cold_Fussion   -  Nov 11, 2009

ok i find one fault though...

[12:26:16] !ud milf
[12:26:19] [Urban Dictionary] ~ (1/139) ~ milf: mothers, whether married, separated or divorced, that a male individual sees as physical attractive enough to want to have sexual intercourse with them. Just cuz their moms doesn't mean that they don't need a spark in their love life. If they've ever breastfed,they have really responsive nipples and a core of erectile tissue in their breasts. The ones in good shape have
[12:27:31] !ud ass monger
[12:27:33] [Urban Dictionary] ~ (1/9) ~ ass monger: mothers, whether married, separated or divorced, that a male individual sees as physical attractive enough to want to have sexual intercourse with them. Just cuz their moms doesn't mean that they don't need a spark in their love life. If they've ever breastfed,they have really responsive nipples and a core of erectile tissue in their breasts. The ones in good shape
[12:28:21] !ud boob
[12:28:25] [Urban Dictionary] ~ (1/31) ~ boob: mothers, whether married, separated or divorced, that a male individual sees as physical attractive enough to want to have sexual intercourse with them. Just cuz their moms doesn't mean that they don't need a spark in their love life. If they've ever breastfed,they have really responsive nipples and a core of erectile tissue in their breasts. The ones in good shape have

might be a small quick fix... ill see what i can do to it :D

 Respond  
Cold_Fussion   -  Nov 11, 2009

kirby great script... 10/10 :D nice work

 Respond  
PATX   -  Sep 27, 2009

how are you going to get a mirc bot to run html?

 Respond  
Kirby   -  Sep 25, 2009

That obviously means that Urban Dictionary changed their site source, which also means that I have to update this script again.

 Respond  
^Neptune   -  Sep 07, 2009

I get this:

(15:53:34) (~Neptune) .urban potatoes
(15:53:36) (~Spoink) [Urban Dictionary] ~ (1/11) ~ potatoes: something you can boil, mash, or stick in a stew. (PO-TAT-OES! Boil 'em, Mash 'em, Stick 'em in a stew.)
(15:53:37) (~Spoink) [Urban Dictionary] ~ Author: DaChazman ~ Date: <a href="#" id="share_this_632417" onclick="emailer.toggle($(&quot;share_this_632417&quot;), &quot;http:\/\/potatoes.urbanup.com\/632417&quot;, 632417, &quot;http:\/\/twitter.com\/home?status=potatoes%20-%20Food%20that%20Irish%20people%20really%20like.%20-%20http%3A%2F%2Fpotatoes.urbanup.com%2F632417&quot;); return false;">share this</a> ~ Url: http://www.urbandictionary.com/d

What's going on?

 Respond  
Kirby   -  May 10, 2009

wouldn't it make more sense if !wod did the current word of the day and if you enter a # it goes to that day I guess that makes more sense. Thanks! I'll update it now.

Edit: Updated

 Respond  
greenlanter420   -  May 10, 2009

wouldn't it make more sense if !wod did the current word of the day and if you enter a # it goes to that day

 Respond  
Kirby   -  May 09, 2009

how hard would it be to just make it say the current word of the day?
What do you mean, the script has that available...
Use: .wod 1, numbers can range from 1-7; it's more of "words of the week".

 Respond  
greenlanter420   -  May 09, 2009

how hard would it be to just make it say the current word of the day?

 Respond  
PATX   -  May 04, 2009

hmmm... useful and cool. i lurve it.

 Respond  
Kirbeh_Pr0nz   -  Apr 02, 2009

No, Kirbeh_Pr0nz is incorrect.
I just allowed triggers . ! and @ to be possible triggers people could use, since people have different tastes.
Using .ud2 test shows me the second definition, using !ud2 test still shows me the 1st definition. Thats what i was aiming at earlier. =\
So really, .ud[#] word is the way to go :P

 Respond  
greenlanter420   -  Apr 01, 2009

I dunno I managed to put my hard drive in the freezer in a ziplock and got my copy i edited off it along with everything else actually now the drive appears to be back to normal pretty funny but i'll take a look at the update

 Respond  
Kirby   -  Mar 31, 2009

greenlanter: What term # did you define?
Remember, the new syntax is: .ud[#]

Also: It was most likely the semicolon I added to the /echo. I think it works now. Sorry for my mistakes.

Anyways, updated. Added menus to turn parts of the script off.

 Respond  
greenlanter420   -  Mar 31, 2009

I had a hard drive crash so I lost the copy I was using now I tried this script the wod part works but not the other part? I just get this

Urban Dictionary] ~ Error: Unexpected or corrupt data from www.urbandictionary.com ~ Look here: http://www.urbandictionary.com/define.php?page=1&term=fuck ~ Total number of term(s) found for "fuck": 134 terms.

 Respond  
Kirby   -  Mar 27, 2009

so like only . works for the search ? not any other command?
No, Kirbeh_Pr0nz is incorrect.
I just allowed triggers . ! and @ to be possible triggers people could use, since people have different tastes.

I'm making some updates right now. Check back in 1 ~ 2 hours or so.

 Respond  
greenlanter420   -  Mar 27, 2009

ah I see the issue now its in the second part of the script it only looks for the . command to search I just went along an changed the . in the second par to - now it all works on -ud word or -ud2 word.great script

 Respond  
Jethro   -  Mar 27, 2009

It is a nice, useful script, Kirby. I'll give you a 10 for the time and hard work you put into this.

 Respond  
Kirby   -  Mar 27, 2009

I was thinking of that, but I had to change it because it got a little too confusing. ;/
I'll actually try to bring it back to normal now, but

.ud[#] word

(no space between the command and the number) is what you should be using.

I'll set examples in the introduction for clarification.

 Respond  
Kirbeh_Pr0nz   -  Mar 27, 2009

try using .ud2 hooker instead of !ud 2 hooker ;]
dont space the number from .ud
Kirby, it would be a little easier to follow if you were able to use

.ud # word

instead of

.ud# word
 Respond  
greenlanter420   -  Mar 25, 2009

kirby just noticed you added word of the day this script works great but is it just me or does it not let you chose the # like if I go !ud 2 hooker it gives me a error that 2 hooker couldn't be found.

 Respond  
Kirby   -  Mar 24, 2009

Next update will (probably) be the last one, unless I can think of ideas.
Have fun.

(And ES, I'm making changes for the one that doesn't show Author, Date, and URL for v.8, sorry :P)

 Respond  
ES   -  Mar 19, 2009

thanks Kirby
cant wait for the next update :D

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.