Advertisement
illpastethat

Urban Dictionary script for Jared/Chromatic

Jan 30th, 2014
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.19 KB | None | 0 0
  1. on $*:text:/^[!](urban|urbandictionary|ud)/Si:#: {
  2.   sockclose UrbanDictionary
  3.   set %UD# $iif($chan,$chan,$nick)
  4.   set %UDterm $2-
  5.   sockopen UrbanDictionary api.urbandictionary.com 80
  6. }
  7.  
  8. on *:SOCKOPEN:UrbanDictionary: {
  9.   sockwrite -n UrbanDictionary GET $+(/v0/define?term=,$urlencode(%udterm)) HTTP/1.1
  10.   sockwrite -n UrbanDictionary Host: api.urbandictionary.com
  11.   sockwrite -n UrbanDictionary $crlf
  12. }
  13.  
  14. on *:SOCKREAD:UrbanDictionary: {
  15.   if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
  16.   else {
  17.     sockread &t
  18.     if ($bfind(&t,1,no_results) != 0) {
  19.       msg %UD# There are no results for %udterm $+ .
  20.       sockclose $sockname
  21.     }
  22.     if ($bfind(&t,1,"thumbs_down":) != 0) {
  23.       var %sockreader $replace($bvar(&t,$+($bfind(&t,1,"definition":),-)).text,\",$chr(2341),\r\n,$chr(32))
  24.       var %definition $replace($gettok(%sockreader,$calc($findtok(%sockreader,definition,1,34) + 2),34),$chr(2341),")
  25.       var %example $replace($gettok(%sockreader,$calc($findtok(%sockreader,example,1,34) + 2),34),$chr(2341),")
  26.       msg %ud# $+([,%udterm,]) %definition Example: %example More: $+(http://,$replace(%udterm,$chr(32),-),.urbanup.com)
  27.       sockclose $sockname
  28.     }
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement