Class: Cinch::Plugins::LastSeen::Base
- Inherits:
-
Object
- Object
- Cinch::Plugins::LastSeen::Base
- Includes:
- Cinch::Plugin
- Defined in:
- lib/cinch/plugins/last_seen/base.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
Returns the value of attribute backend.
Instance Method Summary collapse
- #check_nick(m, nick) ⇒ Object
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
- #log_message(m) ⇒ Object
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
#backend ⇒ Object
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 (m) return unless log_channel?(m.channel) backend.record_time m.channel, m.user.nick end |