mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-04-05 03:12:29 -04:00
workaround for duplicated tweets
This commit is contained in:
parent
adf062f654
commit
1f96e71b63
@ -322,10 +322,12 @@ class Session(object):
|
|||||||
for z in i.users:
|
for z in i.users:
|
||||||
ids += str(z) + ", "
|
ids += str(z) + ", "
|
||||||
if ids != "":
|
if ids != "":
|
||||||
|
print ids
|
||||||
stream_threaded(self.timelinesStream.statuses.filter, self.session_id, follow=ids)
|
stream_threaded(self.timelinesStream.statuses.filter, self.session_id, follow=ids)
|
||||||
|
|
||||||
def add_friends(self):
|
def add_friends(self):
|
||||||
try:
|
try:
|
||||||
|
print "setting friends"
|
||||||
self.timelinesStream.set_friends(self.main_stream.friends)
|
self.timelinesStream.set_friends(self.main_stream.friends)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -348,7 +350,7 @@ class Session(object):
|
|||||||
self.logged = False
|
self.logged = False
|
||||||
self.twitter = twitter.twitter.twitter()
|
self.twitter = twitter.twitter.twitter()
|
||||||
self.login(False)
|
self.login(False)
|
||||||
pub.sendMessage("streamError", session=self.session_id)
|
# pub.sendMessage("streamError", session=self.session_id)
|
||||||
if self.reconnection_function_active == True: return
|
if self.reconnection_function_active == True: return
|
||||||
self.reconnection_function_active = True
|
self.reconnection_function_active = True
|
||||||
if not hasattr(self, "main_stream"):
|
if not hasattr(self, "main_stream"):
|
||||||
|
@ -37,25 +37,29 @@ class timelinesStreamer(TwythonStreamer):
|
|||||||
try:
|
try:
|
||||||
data_ = self.session.check_quoted_status(data)
|
data_ = self.session.check_quoted_status(data)
|
||||||
data = data_
|
data = data_
|
||||||
except:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s-timeline" % (i,)].append(data)
|
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)
|
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)
|
pub.sendMessage("item-in-timeline", data= data, user= self.session.db["user_name"], who= i)
|
||||||
|
# return
|
||||||
for i in self.session.lists:
|
for i in self.session.lists:
|
||||||
try:
|
try:
|
||||||
i.users.index(data["user"]["id"])
|
i.users.index(data["user"]["id"])
|
||||||
|
print "Index in the list for the specified user: %d" % (i.users.index(data["user"]["id"]),)
|
||||||
usr = data["in_reply_to_user_id"]
|
usr = data["in_reply_to_user_id"]
|
||||||
if (usr != None and usr in self.friends) or data.has_key("retweeted_status"):
|
if (usr != None or usr in self.friends) or data.has_key("retweeted_status"):
|
||||||
|
print "I want test this"
|
||||||
data = self.session.check_quoted_status(data)
|
data = self.session.check_quoted_status(data)
|
||||||
|
print data
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s" % (i.name,)].append(data)
|
if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s" % (i.name,)].append(data)
|
||||||
else: self.session.db["%s" % (i,)].insert(0, data)
|
else: self.session.db["%s" % (i,)].insert(0, data)
|
||||||
pub.sendMessage("item-in-list", data= data, user= self.session.db["user_name"], where= i.name)
|
pub.sendMessage("item-in-list", data=data, user=self.session.db["user_name"], where=i.name)
|
||||||
elif usr == None:
|
elif usr == None:
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s" % (i.name,)].append(data)
|
if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s" % (i.name,)].append(data)
|
||||||
else: self.session.db["%s" % (i,)].insert(0, data)
|
else: self.session.db["%s" % (i,)].insert(0, data)
|
||||||
pub.sendMessage("item-in-list", data= data, user= self.session.db["user_name"], where= i.name)
|
pub.sendMessage("item-in-list", data=data, user=self.session.db["user_name"], where=i.name)
|
||||||
except ValueError:
|
except NameError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_friends(self, friends):
|
def set_friends(self, friends):
|
||||||
|
@ -36,7 +36,7 @@ class streamer(TwythonStreamer):
|
|||||||
if self.session.db.has_key(place):
|
if self.session.db.has_key(place):
|
||||||
if utils.find_item(data["id"], self.session.db[place]) != None:
|
if utils.find_item(data["id"], self.session.db[place]) != None:
|
||||||
log.error("duplicated tweet. Ignoring it...")
|
log.error("duplicated tweet. Ignoring it...")
|
||||||
return
|
return False
|
||||||
try:
|
try:
|
||||||
data_ = self.session.check_quoted_status(data)
|
data_ = self.session.check_quoted_status(data)
|
||||||
data = data_
|
data = data_
|
||||||
@ -47,6 +47,7 @@ class streamer(TwythonStreamer):
|
|||||||
else:
|
else:
|
||||||
self.session.db[place].insert(0, data)
|
self.session.db[place].insert(0, data)
|
||||||
utils.is_audio(data)
|
utils.is_audio(data)
|
||||||
|
return True
|
||||||
|
|
||||||
def block_user(self, data):
|
def block_user(self, data):
|
||||||
id = data["target"]["id"]
|
id = data["target"]["id"]
|
||||||
@ -64,29 +65,35 @@ class streamer(TwythonStreamer):
|
|||||||
|
|
||||||
def check_send(self, data):
|
def check_send(self, data):
|
||||||
if self.session.db["user_name"] == data["user"]["screen_name"]:
|
if self.session.db["user_name"] == data["user"]["screen_name"]:
|
||||||
self.put_data("sent_tweets", data)
|
d = self.put_data("sent_tweets", data)
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("sent-tweet", data=data, user=self.get_user())
|
pub.sendMessage("sent-tweet", data=data, user=self.get_user())
|
||||||
|
|
||||||
def check_favs(self, data):
|
def check_favs(self, data):
|
||||||
if data["source"]["screen_name"] == self.session.db["user_name"]:
|
if data["source"]["screen_name"] == self.session.db["user_name"]:
|
||||||
self.put_data("favourites", data["target_object"])
|
d = self.put_data("favourites", data["target_object"])
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("favourite", data=data["target_object"], user=self.get_user())
|
pub.sendMessage("favourite", data=data["target_object"], user=self.get_user())
|
||||||
|
|
||||||
def check_mentions(self, data):
|
def check_mentions(self, data):
|
||||||
if "@%s" % (self.session.db["user_name"]) in data["text"]:
|
if "@%s" % (self.session.db["user_name"]) in data["text"]:
|
||||||
self.put_data("mentions", data)
|
d = self.put_data("mentions", data)
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("mention", data=data, user=self.get_user())
|
pub.sendMessage("mention", data=data, user=self.get_user())
|
||||||
|
|
||||||
def set_quoted_tweet(self, data):
|
def set_quoted_tweet(self, data):
|
||||||
self.put_data("mentions", data)
|
d = self.put_data("mentions", data)
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("mention", data=data, user=self.get_user())
|
pub.sendMessage("mention", data=data, user=self.get_user())
|
||||||
|
|
||||||
def process_dm(self, data):
|
def process_dm(self, data):
|
||||||
if self.session.db["user_name"] == data["direct_message"]["sender"]["screen_name"]:
|
if self.session.db["user_name"] == data["direct_message"]["sender"]["screen_name"]:
|
||||||
self.put_data("sent_direct_messages", data["direct_message"])
|
d = self.put_data("sent_direct_messages", data["direct_message"])
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("sent-dm", data=data["direct_message"], user=self.get_user())
|
pub.sendMessage("sent-dm", data=data["direct_message"], user=self.get_user())
|
||||||
else:
|
else:
|
||||||
self.put_data("direct_messages", data["direct_message"])
|
d = self.put_data("direct_messages", data["direct_message"])
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("direct-message", data=data["direct_message"], user=self.get_user())
|
pub.sendMessage("direct-message", data=data["direct_message"], user=self.get_user())
|
||||||
|
|
||||||
def check_follower(self, data):
|
def check_follower(self, data):
|
||||||
@ -129,7 +136,8 @@ class streamer(TwythonStreamer):
|
|||||||
self.check_mentions(data)
|
self.check_mentions(data)
|
||||||
self.check_send(data)
|
self.check_send(data)
|
||||||
if data["user"]["id"] in self.friends or data["user"]["screen_name"] == self.session.db["user_name"]:
|
if data["user"]["id"] in self.friends or data["user"]["screen_name"] == self.session.db["user_name"]:
|
||||||
self.put_data("home_timeline", data)
|
d = self.put_data("home_timeline", data)
|
||||||
|
if d != False:
|
||||||
pub.sendMessage("item-in-home", data=data, user=self.get_user())
|
pub.sendMessage("item-in-home", data=data, user=self.get_user())
|
||||||
elif data.has_key("event"):
|
elif data.has_key("event"):
|
||||||
if "favorite" == data["event"] and "favorites" in self.session.settings["general"]["buffer_order"]:
|
if "favorite" == data["event"] and "favorites" in self.session.settings["general"]["buffer_order"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user