Class: Cinch::Plugins::Title

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/title.rb

Instance Method Summary collapse

Instance Method Details

#execute(m, message) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cinch/plugins/title.rb', line 19

def execute m, message
  suffix =  m.user.nick[-1] == 's' ? "'" : "'s"

  URI.extract(message, ["http", "https"]) do |uri|
    begin
      next if ignore uri
      
      title = parse(uri)
      m.reply "#{m.user.nick}#{suffix} URL: #{title}"
    rescue URI::InvalidURIError => e
      m.reply "invalid url: #{uri}"
    end
  end
end