Class: Cogibara::FileHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/cogibara/file_handler.rb

Instance Method Summary collapse

Instance Method Details

#convert_to_audio(file) ⇒ Object



39
40
41
# File 'lib/cogibara/file_handler.rb', line 39

def convert_to_audio(file)

end

#handle(file, clientID) ⇒ Object



4
5
6
7
# File 'lib/cogibara/file_handler.rb', line 4

def handle(file, clientID)
  Responder.new.send_reply("@transcribe",clientID)
  handle_audio(file, clientID)
end

#handle_audio(file, clientID, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cogibara/file_handler.rb', line 9

def handle_audio(file, clientID, options={})
  if Cogibara::config.active_file_mode
    if Cogibara::dispatcher.registered_file?(Cogibara::config.active_file_mode)
      response = Cogibara::dispatcher.call_file(Cogibara::config.active_file_mode, file)
      Responder.new.send_reply(response,clientID)
    else
      puts "active file mode #{Cogibara::config.active_file_mode} enabled but not registered, doing the regular thing"
      newmessage = Message.new(Transcriber.new.transcribe(file), clientID)
      Responder.new.send_reply("you: #{newmessage.text}",clientID)
      Cogibara::message_handler.handle(newmessage)
    end
  else
    newmessage = Message.new(Transcriber.new.transcribe(file), clientID)
    Responder.new.send_reply("you: #{newmessage.text}",clientID)
    Cogibara::message_handler.handle(newmessage)
  end
end

#handle_image(file) ⇒ Object



31
32
33
# File 'lib/cogibara/file_handler.rb', line 31

def handle_image(file)
  "images not yet implemented"
end

#handle_other(file) ⇒ Object



35
36
37
# File 'lib/cogibara/file_handler.rb', line 35

def handle_other(file)
  "#{file} not supported"
end

#handle_video(file) ⇒ Object



27
28
29
# File 'lib/cogibara/file_handler.rb', line 27

def handle_video(file)

end