Class: Telegem::Scene::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/session/scene_middleware.rb

Instance Method Summary collapse

Instance Method Details

#call(ctx, next_middleware) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/session/scene_middleware.rb', line 5

def call(ctx, next_middleware)
  # Check if user is in a scene
  if ctx.session[:telegem_scene]
    scene_data = ctx.session[:telegem_scene]
    scene = ctx.bot.scenes[scene_data[:id].to_sym]
    
    if scene
      # Let scene handle it
      scene.process(ctx)
    end
  end
  
  # Not in scene, proceed normally
  next_middleware.call(ctx)
end