Don't add old tweets in buffers. Fixes #116 and #133

This commit is contained in:
Manuel Cortez 2017-05-07 10:45:35 +04:00
parent 713ac0251b
commit 160d168c63
2 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,7 @@
* Release audio files after uploading them. ([#130](https://github.com/manuelcortez/TWBlue/issues/130))
* Now TWBlue will use Yandex's translation services instead microsoft translator. ([#132](https://github.com/manuelcortez/TWBlue/issues/132))
* SndUp users will be able to upload audio in their account by using their API Key again. ([#134](https://github.com/manuelcortez/TWBlue/issues/134))
* old tweets shouldn't be added as new items in buffers. ([#116,](https://github.com/manuelcortez/TWBlue/issues/116)) ([#133](https://github.com/manuelcortez/TWBlue/issues/133))
## Changes in version 0.90

View File

@ -51,7 +51,7 @@ class Session(object):
raise Exceptions.NotConfiguredSessionError("Not configured.")
return f
def order_buffer(self, name, data):
def order_buffer(self, name, data, ignore_older=True):
""" Put the new items in the local database.
name str: The name for the buffer stored in the dictionary.
@ -59,9 +59,19 @@ class Session(object):
returns the number of items that have been added in this execution"""
num = 0
last_id = None
if self.db.has_key(name) == False:
self.db[name] = []
if ignore_older and len(self.db[name]) > 0:
if self.settings["general"]["reverse_timelines"] == False:
last_id = self.db[name][0]["id"]
else:
last_id = self.session.db[self.name][-1]["id"]
for i in data:
if ignore_older and last_id != None:
if i["id"] < last_id:
log.error("Ignoring an older tweet... Last id: {0}, tweet id: {1}".format(last_id, tweet["id"]))
continue
if utils.find_item(i["id"], self.db[name]) == None and utils.is_allowed(i, self.settings["twitter"]["ignored_clients"]) == True:
try: i = self.check_quoted_status(i)
except: pass