Class: Cinch::Plugins::LastSeen::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/cinch/plugins/last_seen/base.rb', line 8

def initialize(*args)
  super
  # TODO config this
  self.backend = RedisStorage.new
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



6
7
8
# File 'lib/cinch/plugins/last_seen/base.rb', line 6

def backend
  @backend
end

Instance Method Details

#check_nick(m, nick) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/cinch/plugins/last_seen/base.rb', line 23

def check_nick(m, nick)
  return unless log_channel?(m.channel)

  if time = backend.get_time(m.channel, nick)
    readable_time = Time.at time.to_i
    m.reply "I've last seen #{nick} at #{readable_time}", true
  else
    m.reply "I haven't seen #{nick}, sorry.", true
  end
end

#log_message(m) ⇒ Object



16
17
18
19
# File 'lib/cinch/plugins/last_seen/base.rb', line 16

def log_message(m)
  return unless log_channel?(m.channel)
  backend.record_time m.channel, m.user.nick
end