lib/chatterbot/config.rb in chatterbot-0.6.6 vs lib/chatterbot/config.rb in chatterbot-0.7.0
- old
+ new
@@ -109,32 +109,44 @@
end
def update_config_at_exit
update_config
end
+
+ def max_id_from(s)
+ s.max { |a, b| a.id <=> b.id }.id
+ end
#
# update the since_id with either the highest ID of the specified
# tweets, unless it is lower than what we have already
def update_since_id(search)
return if search.nil?
+
tmp_id = case search
- when Twitter::SearchResults then search.max_id
+ when Twitter::SearchResults then
+ # don't use max_id if it's this ridiculous number
+ # @see https://dev.twitter.com/issues/1300
+ if search.max_id != 9223372036854775807
+ search.max_id
+ else
+ max_id_from(search)
+ end
# incoming tweets
when Twitter::Tweet then search.id
# an enumeration
- when Array then search.max { |a, b| a.id <=> b.id }.id
+ when Array then max_id_from(search)
# probably an actual tweet ID at this point,
# otherwise it will fail and return 0
else search
end.to_i
- config[:tmp_since_id] = [config[:tmp_since_id].to_i, tmp_id].max
+ config[:tmp_since_id] = [config[:tmp_since_id].to_i, tmp_id].max
end
#
# return a hash of the params we need to connect to the Twitter API
def client_params
@@ -173,10 +185,11 @@
def working_dir
if chatterbot_helper?
Dir.getwd
else
File.dirname($0)
+ #Dir.pwd
end
end
#
# figure out what config file to load based on the name of the bot
@@ -218,10 +231,9 @@
#
# get any config from our global config files
def global_config
tmp = {}
-
global_config_files.each { |f|
tmp.merge!(slurp_file(f) || {})
}
tmp
end