Urban Dictionary

Platform:  TCL
Published  Jun 19, 2012
Updated  Jun 19, 2012
Based on FordLawnmowers verison.

Commands:
!ud - Gives random word definition
!ud <word> - Gives the definition of the word
bind pub - !ud ud

proc ud {nick host hand chan arg} {
package require http

set arg [string map { " " "+" } $arg]
puts $arg
if {[string length $arg] != 0 } { set url "http://www.urbandictionary.com/define.php?term=$arg"
} else {
set url "http://www.urbandictionary.com/random.php"
set page [http::data [http::geturl $url]]
regexp {href="(.*?)"} $page => url
}
set page [http::data [http::geturl $url]]
regexp {'word'>(.*?)<\/td>} $page => word
regexp {definition">(.*?)(<br\/>|<\/div>)} $page => deff
regexp {author">(.*?)<\/a>} $page => author
regexp {example">(.*?)</div>} $page => example
regexp {'not_defined_yet'>} $page => notfound
set deff [string map {&quot; ""} $deff]
set example [string map {&quot; "\""} $example]
regsub -all {(<.*?>)} $example "" example
if {[info exists deff]} {
putserv "PRIVMSG $chan :Word: [string trim $word]"
putserv "PRIVMSG $chan :Definition: [string trim $deff]"
if {[info exists example]} { putserv "PRIVMSG $chan :Example: [string trim $example]" }
putserv "PRIVMSG $chan :By: ([string trim $author]) Link: $url"
}
}

putlog "Urban Dictionary"

Comments

Sign in to comment.
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.