Class: Descartes::Url

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/descartes/modules/url.rb

Instance Method Summary collapse

Instance Method Details

#execute(m, ssl, url) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/descartes/modules/url.rb', line 24

def execute(m, ssl, url)
  begin
    page = Nokogiri::HTML open("http#{ssl}://#{url}").read, nil, 'utf-8'

    if url.match 'youtube.com|youtu.be'
      m.reply "[Youtube] #{page.css('//title').first.text.chomp(' - YouTube')}".colorize :pink
    else
      m.reply "[URL] #{page.css('//title').first.text.strip}".colorize :red
    end
  rescue; end
end