Class: Cinch::Plugins::Seen

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

Constant Summary collapse

VERSION =
"1.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Seen

Returns a new instance of Seen.



20
21
22
23
24
# File 'lib/cinch/plugins/seen/seen.rb', line 20

def initialize(*args)
  super
  @storage = CinchStorage.new(config[:filename] || 'yaml/seen.yml')
  @storage.data ||= {}
end

Instance Method Details

#execute(m, nick) ⇒ Object



33
34
35
36
37
38
# File 'lib/cinch/plugins/seen/seen.rb', line 33

def execute(m, nick)
  return if sent_via_pm?(m)
  unless m.user.nick.downcase == nick.downcase
    m.reply last_seen(m.channel.name, nick), true
  end
end

#listen(m) ⇒ Object



26
27
28
29
30
31
# File 'lib/cinch/plugins/seen/seen.rb', line 26

def listen(m)
  channel = m.channel.name
  @storage.data[channel] ||= Hash.new
  @storage.data[channel][m.user.nick.downcase] = Time.now
  @storage.synced_save(@bot)
end