Class: BotBaseModulePhrases
- Inherits:
-
Object
- Object
- BotBaseModulePhrases
- Defined in:
- lib/botbase-module-phrases.rb
Instance Method Summary collapse
-
#initialize(host: nil, package_src: nil, reg: nil, keywords: '', px_url: nil, logfile: nil, voiceassistant: 'emma', callback: nil) ⇒ BotBaseModulePhrases
constructor
A new instance of BotBaseModulePhrases.
- #query(sender = 'user01', said, mode: :voicechat, echo_node: 'node1') ⇒ Object
Constructor Details
#initialize(host: nil, package_src: nil, reg: nil, keywords: '', px_url: nil, logfile: nil, voiceassistant: 'emma', callback: nil) ⇒ BotBaseModulePhrases
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/botbase-module-phrases.rb', line 16 def initialize(host: nil, package_src: nil, reg: nil, keywords: '', px_url: nil, logfile: nil, voiceassistant: 'emma', callback: nil) @rsc = RSC.new host, package_src #px = Polyrex.new px_url @ste = SPSTriggerExecute.new keywords, reg=nil, px=nil, logfile: logfile @keywords = keywords @bot = callback @voiceassistant = voiceassistant end |
Instance Method Details
#query(sender = 'user01', said, mode: :voicechat, echo_node: 'node1') ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/botbase-module-phrases.rb', line 30 def query(sender='user01', said, mode: :voicechat, echo_node: 'node1') #puts 'inside phrases::query()' + said.inspect a = @ste.mae message: said if a.length > 0 then h = { rse: ->(x, rsc){ job = x.shift[/\/\/job:(.*)/,1] package_path = x.shift package = package_path[/([^\/]+)\.rsf$/,1] rsc.run_job package, job, {}, args=x, package_path: package_path }, sps: ->(x, rsc){ topic, msg = x.split(':',2) fqm = (topic == 'reply' and mode == :voicechat) ? echo_node + "/echo/#{@voiceassistant}: " + msg : x @bot.notice fqm }, ste: ->(x, rsc){ @ste.run x } } end r = nil a.each do |type, x| Thread.new do begin h[type].call x, @rsc rescue warning = 'botbase-module-phrases warning: ' + ($!).inspect puts warning end end # /thread if type == :sps and x[/^reply/] and mode != :voicechat then r = x[/:\s*(.*)/,1].to_s end end # /each return r end |