Class: TelegramOnSteroids::Process
- Inherits:
-
Object
- Object
- TelegramOnSteroids::Process
- Defined in:
- lib/telegram_on_steroids/process.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#initialize(raw_params) ⇒ Process
constructor
A new instance of Process.
- #log_request ⇒ Object
- #process ⇒ Object
Constructor Details
#initialize(raw_params) ⇒ Process
Returns a new instance of Process.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/telegram_on_steroids/process.rb', line 4 def initialize(raw_params) @params = TelegramOnSteroids::Params.new(raw_params) @session = TelegramOnSteroids::Session.new(@params) chat_id = @params.chat_id @client = TelegramOnSteroids.config.client.new(chat_id) @logger = TelegramOnSteroids.config.logger if TelegramOnSteroids.config.commands.keys.include?(params.) set_current_action(TelegramOnSteroids.config.commands[params.]) end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
2 3 4 |
# File 'lib/telegram_on_steroids/process.rb', line 2 def client @client end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
2 3 4 |
# File 'lib/telegram_on_steroids/process.rb', line 2 def params @params end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
2 3 4 |
# File 'lib/telegram_on_steroids/process.rb', line 2 def session @session end |
Instance Method Details
#log_request ⇒ Object
16 17 18 19 |
# File 'lib/telegram_on_steroids/process.rb', line 16 def log_request @logger.info "[TelegramOnSteroids] Processing by #{current_action.class.name}##{current_step}" @logger.info "[TelegramOnSteroids] Params: #{params.to_h}" end |
#process ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/telegram_on_steroids/process.rb', line 21 def process log_request if current_action.respond_to?("__run_on_#{params.type}".to_sym) current_action.send("__run_on_#{params.type}".to_sym) else current_action. if current_action.respond_to?(:__run_on_message) end session.write(:current_page, 1) unless params.callback? if current_action.redirect_to do_redirect end @session.dump @client.inline_request end |