lib/chatterbot/bot.rb in chatterbot-2.0.0.pre vs lib/chatterbot/bot.rb in chatterbot-2.0.2
- old
+ new
@@ -78,12 +78,15 @@
if @handlers[:search]
method = :filter
args = streamify_search_options(@handlers[:search].opts)
else
method = :user
- args = nil
+ args = {
+ stall_warnings: "true"
+ }
end
+
streaming_client.send(method, args) do |object|
handle_streaming_object(object)
end
after_run
@@ -129,22 +132,23 @@
def after_run
end
def call_api_immediately?
- streaming?
+ !streaming?
end
def register_handler(method, opts = nil, &block)
# @todo raise error if method already defined
@handlers[method] = Handler.new(opts, &block)
if STREAMING_ONLY_HANDLERS.include?(method)
puts "Forcing usage of Streaming API to support #{method} calls"
self.streaming = true
elsif call_api_immediately?
+ @run_count += 1
h = @handlers[method]
- send(method, *(h.opts)) do |obj|
+ self.send(method, *(h.opts)) do |obj|
h.call(obj)
end
end
end