Class: Cinch::Plugins::Title
- Inherits:
-
Object
- Object
- Cinch::Plugins::Title
- 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 |
# File 'lib/cinch/plugins/title.rb', line 19 def execute m, URI.extract(, ["http", "https"]) do |uri| begin next if ignore uri m.reply response(m, parse(uri)) rescue URI::InvalidURIError => e m.reply response_invalid(m, uri) end end rescue puts "URL doesn't exist or can't be accessed." end |
#response(m, title) ⇒ Object
33 34 35 36 |
# File 'lib/cinch/plugins/title.rb', line 33 def response m, title suffix = m.user.nick[-1] == 's' ? "'" : "'s" "#{m.user.nick}#{suffix} URL: #{title}" end |
#response_invalid(m, uri) ⇒ Object
38 39 40 |
# File 'lib/cinch/plugins/title.rb', line 38 def response_invalid m, uri "Invalid url: #{uri}" end |