diff --git a/doc/changelog.md b/doc/changelog.md index 74f91858..962c6326 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -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 diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index f0e7f693..61f46d8d 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -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