Module: Hector::Commands::Who

Included in:
Session
Defined in:
lib/hector/commands/who.rb

Instance Method Summary collapse

Instance Method Details

#on_whoObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/hector/commands/who.rb', line 4

def on_who
  name = request.args.first

  if destination = destination_klass_for(name).find(name)
    sessions_for_who(destination).each do |session|
      respond_with("352", nickname, name, session.who, :source => Hector.server_name)
    end
  end

  respond_with("315", nickname, name, :source => Hector.server_name, :text => "End of /WHO list.")
end

#sessions_for_who(destination) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/hector/commands/who.rb', line 16

def sessions_for_who(destination)
  if destination.respond_to?(:sessions)
    destination.sessions.select do |session|
      session.respond_to?(:identity)
    end
  else
    [destination]
  end
end

#whoObject



26
27
28
# File 'lib/hector/commands/who.rb', line 26

def who
  "#{username} #{Hector.server_name} #{Hector.server_name} #{nickname} H :0 #{realname}"
end