Sha256: 14aa9449c6732cfdd9e99c01a1dcf8c8b17f89f507cdb8105d30c1e3af22ace3
Contents?: true
Size: 884 Bytes
Versions: 1
Compression:
Stored size: 884 Bytes
Contents
class Define < Linkbot::Plugin def self.on_message(message, match) word = URI.escape(match[0]) doc = Hpricot(open("http://www.urbandictionary.com/define.php?term=#{word}").read) definition = doc.search("#entries td div[@class=definition]") if definition.empty? message = "No definition for '#{match[0]}' found" else definition = definition[0].inner_html.gsub("<br />", "\n") definition = Sanitize.clean(definition) message = "#{match[0]}: #{definition}" end message end def self.help "!define (word) - use a dictionary, foo" end Linkbot::Plugin.register('urban', self, { :message => {:regex => /!define (.*)/, :handler => :on_message, :help => :help}, :"direct-message" => {:regex => /!define (.*)/, :handler => :on_message, :help => :help} } ) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protolink-0.2.8 | example/linkbot/plugins/urban.rb |