Class: Lita::Extensions::Confirmation::UnconfirmedCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/extensions/confirmation/unconfirmed_command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler, message, robot, route, options) ⇒ UnconfirmedCommand

Returns a new instance of UnconfirmedCommand.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 23

def initialize(handler, message, robot, route, options)
  @handler = handler
  @message = message
  @robot = robot
  @route = route

  @code = SecureRandom.hex(3)

  self.class.confirmations[code] = self

  process_options(options)
end

Instance Attribute Details

#allow_selfObject (readonly)

Returns the value of attribute allow_self.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def allow_self
  @allow_self
end

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def code
  @code
end

#groupsObject (readonly)

Returns the value of attribute groups.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def groups
  @groups
end

#handlerObject (readonly)

Returns the value of attribute handler.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def handler
  @handler
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def message
  @message
end

#robotObject (readonly)

Returns the value of attribute robot.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def robot
  @robot
end

#routeObject (readonly)

Returns the value of attribute route.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def route
  @route
end

#timer_threadObject (readonly)

Returns the value of attribute timer_thread.



7
8
9
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7

def timer_thread
  @timer_thread
end

Class Method Details

.confirmationsObject



14
15
16
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 14

def confirmations
  @confirmations ||= {}
end

.find(code) ⇒ Object



10
11
12
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 10

def find(code)
  confirmations[code]
end

.resetObject



18
19
20
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 18

def reset
  confirmations.clear
end

Instance Method Details

#call(user) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 36

def call(user)
  return :other_user_required if disallow_self?(user)
  return :user_in_group_required unless in_required_group?(user)

  expire
  timer_thread.kill if timer_thread
  handler.dispatch_to_route(route, robot, message)
end