Sha256: 1736678c86991688735ecbcc437b1898ea715ed173a4c555992e490e68258143

Contents?: true

Size: 443 Bytes

Versions: 2

Compression:

Stored size: 443 Bytes

Contents

require 'cinch'
require 'open-uri'
require 'nokogiri'

module Cinch::Plugins
  class UrbanDictionary
    include Cinch::Plugin

    match /urban (.*)/

    def execute(m, query)
      m.reply search(query)
    end

    private
    def search(query)
      url = URI.encode "http://www.urbandictionary.com/define.php?term=#{query}"
      Nokogiri.HTML(open url).at_css('.definition').text.strip
    rescue => e
      e.message
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cinch-urbandictionary-0.10.0 lib/cinch/plugins/urbandictionary.rb
cinch-urbandictionary-0.9.1 lib/cinch/plugins/urbandictionary.rb