Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on $*:text:/^[!](urban|urbandictionary|ud)/Si:#: {
- sockclose UrbanDictionary
- set %UD# $iif($chan,$chan,$nick)
- set %UDterm $2-
- sockopen UrbanDictionary api.urbandictionary.com 80
- }
- on *:SOCKOPEN:UrbanDictionary: {
- sockwrite -n UrbanDictionary GET $+(/v0/define?term=,$urlencode(%udterm)) HTTP/1.1
- sockwrite -n UrbanDictionary Host: api.urbandictionary.com
- sockwrite -n UrbanDictionary $crlf
- }
- on *:SOCKREAD:UrbanDictionary: {
- if ($sockerr) { echo -a SOCKET ERROR: $sockerr | halt }
- else {
- sockread &t
- if ($bfind(&t,1,no_results) != 0) {
- msg %UD# There are no results for %udterm $+ .
- sockclose $sockname
- }
- if ($bfind(&t,1,"thumbs_down":) != 0) {
- var %sockreader $replace($bvar(&t,$+($bfind(&t,1,"definition":),-)).text,\",$chr(2341),\r\n,$chr(32))
- var %definition $replace($gettok(%sockreader,$calc($findtok(%sockreader,definition,1,34) + 2),34),$chr(2341),")
- var %example $replace($gettok(%sockreader,$calc($findtok(%sockreader,example,1,34) + 2),34),$chr(2341),")
- msg %ud# $+([,%udterm,]) %definition Example: %example More: $+(http://,$replace(%udterm,$chr(32),-),.urbanup.com)
- sockclose $sockname
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement