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
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|ud).*/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
svar %sockname method $1-2
svar %sockname url %SlangUD.url
svar %sockname num $iif($3 isnum, $3, 1)
}
On *:sockopen:SlangUD*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $svar($sockname,url) 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 $svar($sockname,method) 1 $gettok(%SlangUD,-1,61)
sockclose $sockname
return
}
elseif (<div id='not_defined_yet'> isin %SlangUD) { $svar($sockname,method) Sorry that word has yet to be defined. }
elseif ($regex(%SlangUD,/ribbon ribbon-without-header/)) {
svar $sockname div small
}
elseif (($svar($sockname,div) == small) && ($regex(%SlangUD,/(^\d+)\.?/))) {
svar $sockname itemnum $regml(1)
svar $sockname div noop
}
elseif ($regex(%SlangUD,/<title>Urban\sDictionary:\s(.*?)<\/title>/i)) {
$svar($sockname,method) 06Word -04 $censored($httpstrip($regml(1)))
}
elseif ($svar($sockname,num) == $svar($sockname,itemnum)) {
if ($regex(%SlangUD,/<div\sclass=['"]([^>]*)['"]>/i)) {
svar $sockname div $regml(1)
}
if ($svar($sockname,div) == meaning) {
var %definition $svar($sockname,definition)
svar $sockname definition $+($iif($+($svar($sockname,definition),$chr(32)),$v1),%SlangUD)
if (</div> isin %SlangUD) {
put $svar($sockname,method) 06Definition -04 $censored($replace($httpstrip($svar($sockname,definition)),$chr(13),$chr(32)))
svar $sockname div noop
}
}
if ($svar($sockname,div) == example) {
svar $sockname example $+($svar($sockname,example),$chr(32),%SlangUD)
if (</div> isin %SlangUD) {
put $svar($sockname,method) 06Example -04 $censored($replace($httpstrip($svar($sockname,example)),$chr(13),$chr(32)))
svar $sockname div noop
}
}
if ($svar($sockname,div) == contributor) {
svar $sockname contributor $+($svar($sockname,contributor),$chr(32),%SlangUD)
if (</div> isin %SlangUD) {
put $svar($sockname,method) 06Author -04 $censored($replace($httpstrip($svar($sockname,contributor)),$chr(13),$chr(32))) - $+(07,http://www.urbandictionary.com,$svar($sockname,url)))
sockclose $sockname
return
}
}
}
}
}
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 $fix&#($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
}
}
alias -l fix&# {
return $regsubex($regsubex($replace($regsubex($1-,/\&\#([0-9]{1,});/g,$utf8(\t)),",",&,&,>,>,<,<,',',$chr(9),$chr(32)),$&
/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t)),/\&\#x([0-9a-f]{1,});/gi,$H2U(\t))
}
alias -l UTF8 {
if ($version >= 7) return $chr($1)
elseif ($1 < 255) { return $chr($1) }
elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
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)))) }
elseif ($1 >= 65536) && ($1 < 2097152) {
return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
$chr($calc(128 + $mod($1,64))))
}
}
alias -l div { return $int($calc($1 / $2)) }
alias -l mod {
var %int $int($calc($1 / $2))
return $calc($1 - (%int * $2))
}
alias -l H2U { return $utf8($base($1,16,10)) }
alias -l Svar {
var %sockname $1, %item $+($2,$1)
if ($isid) {
if ($regex(svar,$sock(%sockname).mark,/ $+ %item $+ \x01([^\x01]*)/i)) return $regml(svar,1)
}
elseif ($3) {
var %value $3-
if (!$regex(svar,$sock(%sockname).mark,/ $+ %item $+ \x01/i)) { sockmark %sockname $+($sock(%sockname).mark,$chr(1),%item,$chr(1),%value) }
else { sockmark %sockname $regsubex(svar,$sock(%sockname).mark,/( $+ %item $+ \x01[^\x01]*)/i,$+(%item,$chr(1),%value)) }
}
}
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 } }
Hey there, i was wondering if this script isent working anymore? as : http://prntscr.com/5ifoty
if you look at that picture, nothing happens at all, where is if i sit on my irc client and type : /slang WORD, it comes up, but only visible to me! :)
im kinda stuck! so if anyone has an idea! please share :-D
If it is not too much trouble, i would like to be able to use ".ud" or ".slang" to message the $chan instead of @. I tried to make this edit myself, but now whenever someone types "pudding", or "audio" it brings up a random word. Thanks in advance, and may you be awarded MANY internets for your awesome scripting!
Urbandictionary updated again. I got it to work for me by
changing line 89 from elseif ($regex(%SlangUD,/<div\sclass=['"]small['"]>/)) { to elseif ($regex(%SlangUD,/<div\sclass=['"]ribbon)) {
and changing line 92 from elseif (($svar($sockname,div) == small) && ($regex(%SlangUD,/(^\d+)./))) { to elseif (($svar($sockname,div) == small) && ($regex(%SlangUD,/(^\d+)/))) {
Probably a cleaner way to do it, but it works lol. Regex is hard.
http://pastebin.com/5gWY7i4S here's a nicer link
Updated
@rebel9 There is really no reason to be rude or arrogant here. It's good to see people step up and help out, but this can be done without talking down to people.
FordLawnmower: I didn't mean any disrespect. I don't see why people are so touchy over the internet when I was only trying to help incognitus on how to fix it and read the code and recognize the problem without having to ask questions. I meant absolutely no harm and I was NOT trying to be rude or arrogant by any means. In my opinion, I helped a lot of people figure out how to fix this issue on their own, not just the person who asked the question. That's all I'm doing, no harm no foul, I thought.
[15:12] !ud crappola
[15:12] <start> Definition - A whole load of crap. Not to be confused with shitload. [15:12] <start
> Example - What's all this crappola?
Any idea why I am getting the censored stuff all of a sudden? I changed nothing, I have no censored words. I checked the hsh file and was empty.
I even went back to earlier scripts to see if there was something that I inadvertently did and still the same. Any ideas?
You can add it manually under Varibles.
But else search for
if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/))
and replace it with
if (%action isin +-) && (($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) || ($nick == NewbieGuy))
Change NewbieGuy to what ever IRC nick you are using
Your welcome snackled :)
@NewbieGuy
From the Description:
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.
@slang will message the channel if you have Ops.
If you would like the script to work different for you, please explain and I will pastebin an edit for you.
@startmeup I'll try to post an update for you this weekend. It's a very small edit , I'm just real busy atm.
@snackled Thanks.
To change the default color for the second line, change line numbers: 115 and 121
115:
.timer -m 1 %Dtimer $1-2 $+(04,$($+($,%Tstart,-,%tokens),2)))
121:
.timer -m 1 %Dtimer $1-2 $+(04,$($+($,%Tstart,-,%tokens),2)))
These two lines add a default color to text if the line is too large to post in a single message.
This is old code and not very customizable. I'll add it to my rewrite list.
@KilllerX First you have to type +slang in each channel you want to run this in.(Requires ops)
The rest I can make an edit and post it here in a few.
Try this edit -->> http://pastebin.com/qJkHE6Cs
Yah. I am having a little problem with this.
I can only activate it with.
/slang (word) [which only echo's it, and I want it messaged]
and unless they are using an irc like mIRC they will see the []12,2. So also if you could help me by not having it colorized. I would appreciated it.
Also if there is a way to take out the example and the user that uploaded it.
Just wanted to say thanks...
So far no errors found... works like a charm :D:D:D:D
Didn't have any problems with adding channels either with the +Slang
ooO( Running mIRC version 6.35 )
6.16 works for me now...it was not adding channels, figured how to add in variables manually. my question is...is there an edit so that anyone can trigger it with @slang and have it output to the channel? In a previous comment from henbone11, that it was not outputting to the channel. Well I have found that you must be voiced or opped in order to output to the channel. I would like to have it so that anyone can output to the channel...thanks for your help
any solutions? haven't figured it out yet myself :(