Class: Plugins::UrbanDictionary

Inherits:
Object
  • Object
show all
Includes:
Cinch::Helpers, Cinch::Plugin
Defined in:
lib/Zeta/plugins/urban.rb

Instance Method Summary collapse

Methods included from Cinch::Plugin

#check?, #log2chan

Instance Method Details

#query(m, query) ⇒ Object



20
21
22
# File 'lib/Zeta/plugins/urban.rb', line 20

def query(m, query)
  m.reply "UD↦ #{search(query)}"
end

#wotd(m) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Zeta/plugins/urban.rb', line 25

def wotd(m)
  parser = URI::Parser.new
  url = parser.escape("http://www.urbandictionary.com/")

  doc = Nokogiri.HTML(
      RestClient.get(url).body
  )
  word = doc.at_css('.word').text.strip[0..40]
  meaning = doc.at_css('.meaning').text.strip[0..450] + "... \u263A"
  m.reply "UD↦ #{word} -- #{meaning}"
end