Class: Atig::Command::Whois

Inherits:
Command
  • Object
show all
Defined in:
lib/atig/command/whois.rb

Instance Attribute Summary

Attributes inherited from Command

#api, #db, #gateway, #opts

Instance Method Summary collapse

Methods inherited from Command

#find_by_tid, #initialize

Constructor Details

This class inherits a constructor from Atig::Command::Command

Instance Method Details

#action(target, mesg, command, args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/atig/command/whois.rb', line 9

def action(target, mesg, command,args)
  if args.empty?
    yield "/me #{command} <ID>"
    return
  end
  nick,*_ = args

  Atig::Command::Info::user(db, api, nick) do|user|
    id = "id=#{user.id}"
    host = "twitter.com"
    host += "/protected" if user.protected
    desc      = user.name
    desc      = "#{desc} / #{user.description}".gsub(/\s+/, " ") if user.description and not user.description.empty?
    signon_at = ::Time.parse(user.created_at).to_i rescue 0
    idle_sec  = (::Time.now - (user.status ? ::Time.parse(user.status.created_at) : signon_at)).to_i rescue 0
    location  = user.location
    location  = "SoMa neighborhood of San Francisco, CA" if location.nil? or location.empty?

    send Net::IRC::Constants::RPL_WHOISUSER,   nick, id, host, "*", desc
    send Net::IRC::Constants::RPL_WHOISSERVER, nick, host, location
    send Net::IRC::Constants::RPL_WHOISIDLE,   nick, "#{idle_sec}", "#{signon_at}", "seconds idle, signon time"
    send Net::IRC::Constants::RPL_ENDOFWHOIS,  nick, "End of WHOIS list"
  end
end

#command_nameObject



7
# File 'lib/atig/command/whois.rb', line 7

def command_name; %w(whois) end

#send(command, nick, *params) ⇒ Object



34
35
36
# File 'lib/atig/command/whois.rb', line 34

def send(command,nick,*params)
  gateway.post gateway.server_name, command, db.me.screen_name, nick, *params
end