Class: Lita::Extensions::Confirmation::UnconfirmedCommand
- Inherits:
-
Object
- Object
- Lita::Extensions::Confirmation::UnconfirmedCommand
- Defined in:
- lib/lita/extensions/confirmation/unconfirmed_command.rb
Instance Attribute Summary collapse
-
#allow_self ⇒ Object
readonly
Returns the value of attribute allow_self.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#timer_thread ⇒ Object
readonly
Returns the value of attribute timer_thread.
Class Method Summary collapse
Instance Method Summary collapse
- #call(user) ⇒ Object
-
#initialize(handler, message, robot, route, options) ⇒ UnconfirmedCommand
constructor
A new instance of UnconfirmedCommand.
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, , robot, route, ) @handler = handler @message = @robot = robot @route = route @code = SecureRandom.hex(3) self.class.confirmations[code] = self () end |
Instance Attribute Details
#allow_self ⇒ Object (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 |
#code ⇒ Object (readonly)
Returns the value of attribute code.
7 8 9 |
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7 def code @code end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
7 8 9 |
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7 def groups @groups end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
7 8 9 |
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7 def handler @handler end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7 def @message end |
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
7 8 9 |
# File 'lib/lita/extensions/confirmation/unconfirmed_command.rb', line 7 def robot @robot end |
#route ⇒ Object (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_thread ⇒ Object (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
.confirmations ⇒ Object
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 |
.reset ⇒ Object
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, ) end |