class Telegram::Utils::Responder
Constants
- RESPONSE_TYPES
Private Class Methods
register_type(type)
click to toggle source
# File lib/telegram/utils/responder.rb, line 13 def register_type type instance_eval do define_method type do |&block| set_respond_to type, &block end end end
Public Instance Methods
any(&block)
click to toggle source
# File lib/telegram/utils/responder.rb, line 84 def any &block set_respond_to :any, &block end
block()
click to toggle source
# File lib/telegram/utils/responder.rb, line 110 def block @block or raise Telegram::Errors::Controller::BlockNotGivenError end
clear_current_message()
click to toggle source
# File lib/telegram/utils/responder.rb, line 79 def clear_current_message @message = nil end
current_message()
click to toggle source
# File lib/telegram/utils/responder.rb, line 74 def current_message @message end
current_message=(message)
click to toggle source
# File lib/telegram/utils/responder.rb, line 69 def current_message= message @message = message end
set_respond_to(type, &block)
click to toggle source
TEST match first not nil attribute
# File lib/telegram/utils/responder.rb, line 91 def set_respond_to type, &block @stack ||= [] @stack.push type if block && @block.nil? # check if message matches stack has_attr = @stack.find do |format| format == :any || !current_message.send(format).nil? end if has_attr @block = block end @stack.clear end end