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!
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. =)
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, ) | return $replace(%x,",",<,<,>,>,$cr,$chr(32),$lf,$chr(32),&,&) }
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
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.
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.
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
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.
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
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($("share_this_632417"), "http:\/\/potatoes.urbanup.com\/632417", 632417, "http:\/\/twitter.com\/home?status=potatoes%20-%20Food%20that%20Irish%20people%20really%20like.%20-%20http%3A%2F%2Fpotatoes.urbanup.com%2F632417"); return false;">share this</a> ~ Url: http://www.urbandictionary.com/d
What's going on?
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
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.
I fixed it if you want my version of it