lib/chatterbot/client.rb in chatterbot-0.7.0 vs lib/chatterbot/client.rb in chatterbot-0.7.1
- old
+ new
@@ -47,10 +47,19 @@
def reset_since_id
config[:tmp_since_id] = 0
result = client.search("a")
update_since_id(result)
end
+
+ #
+ # resets the since_id_reply for this bot to the last mention received
+ #
+ def reset_since_id_reply
+ config[:tmp_since_id_reply] = 0
+ result = client.mentions.max_by(&:id)
+ update_since_id_reply(result)
+ end
#
# the URL we should use for api calls
#
@@ -65,10 +74,11 @@
def default_opts
opts = {
:result_type => "recent"
}
opts[:since_id] = since_id if since_id > 0
+ opts[:since_id_reply] = since_id_reply if since_id_reply > 0
opts
end
@@ -159,17 +169,18 @@
begin
# this will throw an error that we can try and catch
@access_token = request_token.get_access_token(:oauth_verifier => pin.chomp)
get_screen_name
- config[:token] = @access_token.token
- config[:secret] = @access_token.secret
+ self.config[:token] = @access_token.token
+ self.config[:secret] = @access_token.secret
update_config unless ! do_update_config
reset_client
rescue OAuth::Unauthorized => e
display_oauth_error
+ puts e.inspect
return false
end
end
return true