Method: E4z::DevBot#run

Defined in:
lib/eezee_bot.rb

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/eezee_bot.rb', line 16

def run
  ::E4z::SocketClient.new(project_slug) do |data|
    instruction_id = JSON.parse(data)['instruction_id']
    instruction = @eezee_client.get_instruction(project_id, instruction_id)
    data = instruction['data']
    execute = instruction['execute']

    puts "Running `#{execute}` with #{data}"

    begin
      OpenStruct.new(data).instance_eval(execute)
    rescue Exception => e
      puts "Err log data: #{data}"
      puts "Err log execute: #{execute}"
      puts e.message
    end

    payload = { did_run: true }
    @eezee_client.update_instruction(project_id, instruction_id, payload)
  end
end