Class: Botiasloop::Commands::Switch
- Defined in:
- lib/botiasloop/commands/switch.rb
Overview
Switch command - switches to a different conversation by label or ID
Instance Method Summary collapse
-
#execute(context, args = nil) ⇒ String
Execute the switch command.
Methods inherited from Base
command, description, inherited
Instance Method Details
#execute(context, args = nil) ⇒ String
Execute the switch command
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/botiasloop/commands/switch.rb', line 15 def execute(context, args = nil) identifier = args.to_s.strip return "Usage: /switch <label-or-id>" if identifier.empty? new_conversation = context.chat.switch_conversation(identifier) context.conversation = new_conversation format_switch_response(new_conversation) rescue Botiasloop::Error => e "Error: #{e.message}" end |