Class: Descartes::Seen

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/descartes/modules/seen.rb

Defined Under Namespace

Classes: SeenStruct

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Seen

Returns a new instance of Seen.



15
16
17
18
# File 'lib/descartes/modules/seen.rb', line 15

def initialize(*args)
  super
  @users = {}
end

Instance Method Details

#execute(m, nick) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/descartes/modules/seen.rb', line 24

def execute(m, nick)
  if nick == @bot.nick
    m.reply "That's me!"
  elsif nick == m.user.nick
    m.reply "That's you!"
  elsif @users.key?(nick)
    m.reply @users[nick].to_s
  else
    m.reply "I haven't seen #{nick}"
  end
end

#listen(m) ⇒ Object



20
21
22
# File 'lib/descartes/modules/seen.rb', line 20

def listen(m)
  @users[m.user.nick] = SeenStruct.new(m.user, m.channel, m.message, Time.now)
end