Class: Cinch::Plugins::LinksLogger
- Inherits:
-
Object
- Object
- Cinch::Plugins::LinksLogger
- Includes:
- Cinch::Plugin
- Defined in:
- lib/cinch/plugins/links-logger.rb,
lib/cinch/plugins/links-logger/version.rb
Overview
Versioning info
Constant Summary collapse
- VERSION =
'1.0.3'
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #execute(m) ⇒ Object
-
#initialize(*args) ⇒ LinksLogger
constructor
A new instance of LinksLogger.
- #listen(m) ⇒ Object
Constructor Details
#initialize(*args) ⇒ LinksLogger
Returns a new instance of LinksLogger.
20 21 22 23 24 |
# File 'lib/cinch/plugins/links-logger.rb', line 20 def initialize(*args) super @storage = Cinch::Storage.new(config[:filename] || 'yaml/links.yaml') @storage.data ||= {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
12 13 14 |
# File 'lib/cinch/plugins/links-logger.rb', line 12 def storage @storage end |
Instance Method Details
#execute(m) ⇒ Object
26 27 28 29 |
# File 'lib/cinch/plugins/links-logger.rb', line 26 def execute(m) return if Cinch::Toolbox.(m) get_recent_links(m.channel.name).each { |line| m.user.send line } end |
#listen(m) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/cinch/plugins/links-logger.rb', line 31 def listen(m) urls = URI.extract(m., %w(http https)) urls.each do |url| # Ensure we have a Channel Object in the History to dump links into. @storage.data[m.channel.name] ||= Hash.new @link = get_or_create_link(m, url) end end |