lib/telegram/bot/updates_controller/message_context.rb in telegram-bot-0.16.1 vs lib/telegram/bot/updates_controller/message_context.rb in telegram-bot-0.16.3
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Telegram
module Bot
class UpdatesController
# Allows to store context in session and treat next message according to this context.
#
@@ -46,15 +48,15 @@
# Fetches context and finds handler for it. If message has new command,
# it has higher priority than contextual action.
def action_for_message
val = message_context_session.delete(:context)
- context = val && val.to_s
- super || context && begin
- args = payload['text'].try!(:split) || []
+ context = val&.to_s
+ super || (context && begin
+ args = payload['text']&.split || []
action = action_for_message_context(context)
- [[action, type: :message_context, context: context], args]
- end
+ [[action, {type: :message_context, context: context}], args]
+ end)
end
# Save context for the next request.
def save_context(context)
message_context_session[:context] = context