Class: Ruboty::Url::Actions::Title

Inherits:
Actions::Base
  • Object
show all
Defined in:
lib/ruboty/url/actions/title.rb

Overview

Ruboty::Url::Actions::Title

Instance Method Summary collapse

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruboty/url/actions/title.rb', line 8

def call
  url = message[0]
  title = ''
  open(url) do |f|
    doc = Nokogiri::HTML(f)
    title = doc.xpath('/html/head/title').text
  end
  attachments = [{
    color: '#EEEEEE',
    title: title,
    title_link: url,
  }]
  message.reply(nil, attachments: attachments) unless title.empty?
end