lib/kanal/interfaces/pachka/pachka_interface.rb in kanal-interfaces-pachka-0.1.0 vs lib/kanal/interfaces/pachka/pachka_interface.rb in kanal-interfaces-pachka-0.1.1

- old
+ new

@@ -19,11 +19,11 @@ # Input parameters registered: # input.pachka_command - command sent from users to bot. Full text of command passed, like "/hello" # # Output parameters registered: # output.pachka_text - you can specify it in the respond block for bot to reply with text - # TODO: more parameters + # output.pachka_file_path - you can specify it in the respond block for bot to reply with file # class PachkaInterface < Kanal::Core::Interfaces::Interface include Kanal::Logger # # Creates interface with core and optional parameters @@ -51,14 +51,15 @@ core.register_plugin Kanal::Plugins::Batteries::BatteriesPlugin.new core.register_plugin Kanal::Interfaces::Pachka::Plugins::PachkaIntegrationPlugin.new end def consume_output(output) - @api.send_text(output.pachka_entity_id, output.pachka_text) unless output.pachka_text.nil? + unless output.pachka_file_path.nil? + @api.send_file(output.pachka_entity_id, output.pachka_file_path, output.pachka_text) + return + end - return if output.pachka_file_path.nil? - - @api.send_file(output.pachka_entity_id, output.pachka_file_path, output.pachka_text) + @api.send_text(output.pachka_entity_id, output.pachka_text) unless output.pachka_text.nil? end def start logger.info "Starting Pachka interface on http://#{@host}:#{@port}"