From 89e39e2168cd83d3dcd085c46f9d971e26294a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Wed, 23 Sep 2015 10:01:00 -0500 Subject: [PATCH] Double tweets should be ignored in streams --- src/twitter/buffers/indibidual.py | 3 +++ src/twitter/buffers/stream.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/twitter/buffers/indibidual.py b/src/twitter/buffers/indibidual.py index f6340a96..5c3d9781 100644 --- a/src/twitter/buffers/indibidual.py +++ b/src/twitter/buffers/indibidual.py @@ -30,6 +30,9 @@ class timelinesStreamer(TwythonStreamer): def check_tls(self, data): for i in self.session.settings["other_buffers"]["timelines"]: if data["user"]["screen_name"] == i: + if utils.find_item(data["id"], self.session.db["%s-timeline" % (i,)]) != None: + log.error("duplicated tweet. Ignoring it...") + return if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s-timeline" % (i,)].append(data) else: self.session.db["%s-timeline" % (i,)].insert(0, data) pub.sendMessage("item-in-timeline", data= data, user= self.session.db["user_name"], who= i) diff --git a/src/twitter/buffers/stream.py b/src/twitter/buffers/stream.py index 6345cf51..936d5b2c 100644 --- a/src/twitter/buffers/stream.py +++ b/src/twitter/buffers/stream.py @@ -33,6 +33,9 @@ class streamer(TwythonStreamer): def put_data(self, place, data): if self.session.db.has_key(place): + if utils.find_item(data["id"], self.session.db[place]) != None: + log.error("duplicated tweet. Ignoring it...") + return if self.session.settings["general"]["reverse_timelines"] == False: self.session.db[place].append(data) else: