Class: Atig::Command::Time

Inherits:
Command
  • Object
show all
Defined in:
lib/atig/command/time.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



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

def action(target, mesg, command, args)
  if args.empty?
    yield "/me #{command} <NICK>"
    return
  end
  nick, *_ = args
  Info.user(db, api, nick){|user|
    offset = user.utc_offset
    time   = "TIME :%s%s (%s)" %  [
                                   (::Time.now + offset).utc.iso8601[0, 19],
                                   "%+.2d:%.2d" % (offset/60).divmod(60),
                                   user.time_zone
                                  ]
    entry = TwitterStruct.make('user'   => user,
                               'status' => { 'text' =>
                                 Net::IRC.ctcp_encode(time) })
    gateway[target].message entry, Net::IRC::Constants::NOTICE
  }
end

#command_nameObject



9
# File 'lib/atig/command/time.rb', line 9

def command_name; %w(time) end