Urban Dictionary

By Paradox-Paradigm on Mar 20, 2013

Urban Dictionary Script For A Bot

on $*:TEXT:/^[~`!@^&.]u(d|rbandictionary) ./i:*: {
  sockclose UrbanDictionary
  set %UD# $iif($chan,$chan,$nick)
  set %UDURL /define.php?term= $+ $regsubex($2-,/([ `@#$%^&+=\[\]{}\\|;'",<>\/?])/g,% $+ $base($asc(\t),10,16))
  sockopen UrbanDictionary www.urbandictionary.com 80
}

on $*:TEXT:/urbandictionary\.com(\/define\.php\?term=\S+)/i:*: {
  sockclose UrbanDictionary
  set %UD# $iif($chan,$chan,$nick)
  set %UDURL $regml(1)
  sockopen UrbanDictionary www.urbandictionary.com 80
}

on *:SOCKOPEN:UrbanDictionary: {
  sockwrite -n UrbanDictionary GET %UDURL HTTP/1.1
  sockwrite -n UrbanDictionary Host: www.urbandictionary.com
  sockwrite UrbanDictionary $crlf
}

on *:SOCKREAD:UrbanDictionary: {
  sockread %UD
  while ($sockbr) {
    if (<div class="definition">* iswm %UD) {
      var %UD~ = $regsubex($regsubex($remove(%UD,$cr),/(<br\/>)+/g,$chr(32) $+ - $+ $chr(32)),/<div class="definition">(.+?)<\/div>(?:<div class="example">(.+?)<\/div>)?/,\1), %UD~~ = $regml(2)
      msg %UD# $regsubex($replace($regsubex(%UD~,/(<.+?>)+/g,),&amp;,&,&quot;,",&lt;,<,&gt;,>),/&#(x?\d+);/g,$iif(x !isin \t,$chr(\t),$chr($base($remove(\t,x),16,10))))
      $iif(%UD~~,msg %UD# Example - $regsubex($replace($regsubex(%UD~~,/(<.+?>)+/g,),&amp;,&,&quot;,",&lt;,<,&gt;,>),/&#(x?\d+);/g,$iif(x !isin \t,$chr(\t),$chr($base($remove(\t,x),16,10)))))
      unset %UD*
      sockclose UrbanDictionary
      return
    }
    elseif (</i> isn't defined.<br/>Can you define it? isin %UD) {
      msg %UD# $regsubex($gettok(%UDURL,-1,61),/%(..)/g,$chr($base(\t,16,10))) is not defined
      unset %UD*
      sockclose UrbanDictionary
      return
    }
    sockread %UD
  }
}

Comments

Sign in to comment.
Menteroth   -  Oct 08, 2013

The "isn't defined part" doesn't seem to work either btw.

 Respond  
Menteroth   -  Sep 19, 2013

could you add a message if no word is typed after the trigger command?
so people who aren't familiar with it gets a response of what to do.

Menteroth  -  Sep 21, 2013

and also. is it possible to add a timer between messages if the text is too long? 'cause I'm using this in a Twitch.tv channel which has like a 2 second auto message filter in every channel.

rebel9  -  Jan 12, 2014

if (!$2-) { msg $chan Invalid syntax. Please type !ud [search]. }

Menteroth  -  Jan 24, 2014

Thanks.

rebel9  -  Jan 28, 2014

This script doesnt even work anymore does it? I remember my friend was using it and it quit working on him, wondering if its the same for everyone. I wrote my own though so...

Menteroth  -  Apr 05, 2014

I stopped working yeah. I don't know if they changed the site somehow so it can't get the correct feedback.
You're welcome to share yours if it works. I would gladly use it.

rebel9  -  Apr 06, 2014

.

Sign in to comment

CourtneyR001   -  Jun 20, 2013

I have it on my mIRC but yea how do we turn it on?

leboong  -  Jul 17, 2013

Just Paste into Script Editor. Save. Ok. To trigger: !urbandictionary (space) (word to define)

Sign in to comment

Yawhatnever   -  Apr 11, 2013

You should consider using dynamic socket names for this to allow for simultaneous searches to happen.

 Respond  
Shamp00   -  Mar 30, 2013

Hi, what is the trigger to activate this script? Thanks

 Respond  
hxck   -  Mar 23, 2013

Definition comes through alright but you hit a snag with the example. Don't have time to sift through it at the moment but getting

Example No such nick/channel
in the status window.

 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.