Class: Cinch::Plugins::Seen

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

Overview

Versioning Info

Defined Under Namespace

Classes: Activity

Constant Summary collapse

VERSION =
'1.0.5'

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Seen

Returns a new instance of Seen.



22
23
24
25
26
# File 'lib/cinch/plugins/seen.rb', line 22

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

Instance Method Details

#execute(m, nick) ⇒ Object



37
38
39
40
41
# File 'lib/cinch/plugins/seen.rb', line 37

def execute(m, nick)
  return if Cinch::Toolbox.sent_via_private_message?(m) ||
            m.user.nick.downcase == nick.downcase
  m.reply last_seen(m.channel.name, nick), true
end

#listen(m) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/cinch/plugins/seen.rb', line 28

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