mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Work with user IDS instead usernames in all timelines
This commit is contained in:
parent
020148ac0a
commit
cd7fb6d36f
@ -241,6 +241,8 @@ class baseBufferController(bufferController):
|
|||||||
self.buffer.account = account
|
self.buffer.account = account
|
||||||
self.bind_events()
|
self.bind_events()
|
||||||
self.sound = sound
|
self.sound = sound
|
||||||
|
if "-timeline" in self.name or "-favorite" in self.name:
|
||||||
|
self.finished_timeline = False
|
||||||
|
|
||||||
def get_formatted_message(self):
|
def get_formatted_message(self):
|
||||||
if self.type == "dm" or self.name == "sent_tweets" or self.name == "sent_direct_messages": return self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"])[1]
|
if self.type == "dm" or self.name == "sent_tweets" or self.name == "sent_direct_messages": return self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"])[1]
|
||||||
@ -296,6 +298,13 @@ class baseBufferController(bufferController):
|
|||||||
number_of_items = self.session.order_buffer(self.name, val)
|
number_of_items = self.session.order_buffer(self.name, val)
|
||||||
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
||||||
self.put_items_on_list(number_of_items)
|
self.put_items_on_list(number_of_items)
|
||||||
|
if hasattr(self, "finished_timeline") and self.finished_timeline == False:
|
||||||
|
if "-timeline" in self.name:
|
||||||
|
self.username = val[0]["user"]["screen_name"]
|
||||||
|
elif "-favorite" in self.name:
|
||||||
|
self.username = self.session.api_call("show_user", **self.kwargs)["screen_name"]
|
||||||
|
self.finished_timeline = True
|
||||||
|
pub.sendMessage("buffer-title-changed", buffer=self)
|
||||||
if number_of_items > 0 and self.name != "sent_tweets" and self.name != "sent_direct_messages" and self.sound != None:
|
if number_of_items > 0 and self.name != "sent_tweets" and self.name != "sent_direct_messages" and self.sound != None:
|
||||||
self.session.sound.play(self.sound)
|
self.session.sound.play(self.sound)
|
||||||
return number_of_items
|
return number_of_items
|
||||||
@ -766,6 +775,8 @@ class peopleBufferController(baseBufferController):
|
|||||||
log.debug("Compose_function: %s" % (self.compose_function,))
|
log.debug("Compose_function: %s" % (self.compose_function,))
|
||||||
self.get_tweet = self.get_right_tweet
|
self.get_tweet = self.get_right_tweet
|
||||||
self.url = self.interact
|
self.url = self.interact
|
||||||
|
if "-followers" in self.name or "-friends" in self.name:
|
||||||
|
self.finished_timeline = False
|
||||||
|
|
||||||
def remove_buffer(self):
|
def remove_buffer(self):
|
||||||
if "-followers" in self.name:
|
if "-followers" in self.name:
|
||||||
@ -819,6 +830,10 @@ class peopleBufferController(baseBufferController):
|
|||||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||||
val = self.session.get_cursored_stream(self.name, self.function, *self.args, **self.kwargs)
|
val = self.session.get_cursored_stream(self.name, self.function, *self.args, **self.kwargs)
|
||||||
self.put_items_on_list(val)
|
self.put_items_on_list(val)
|
||||||
|
if hasattr(self, "finished_timeline") and self.finished_timeline == False:
|
||||||
|
self.username = self.session.api_call("show_user", **self.kwargs)["screen_name"]
|
||||||
|
self.finished_timeline = True
|
||||||
|
pub.sendMessage("buffer-title-changed", buffer=self)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def get_more_items(self):
|
def get_more_items(self):
|
||||||
|
@ -120,6 +120,7 @@ class Controller(object):
|
|||||||
pub.subscribe(self.manage_item_in_list, "item-in-list")
|
pub.subscribe(self.manage_item_in_list, "item-in-list")
|
||||||
pub.subscribe(self.restart_streams_, "restart_streams")
|
pub.subscribe(self.restart_streams_, "restart_streams")
|
||||||
pub.subscribe(self.on_tweet_deleted, "tweet-deleted")
|
pub.subscribe(self.on_tweet_deleted, "tweet-deleted")
|
||||||
|
pub.subscribe(self.buffer_title_changed, "buffer-title-changed")
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
|
widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
|
||||||
|
|
||||||
def bind_other_events(self):
|
def bind_other_events(self):
|
||||||
@ -341,14 +342,14 @@ class Controller(object):
|
|||||||
self.buffers.append(timelines)
|
self.buffers.append(timelines)
|
||||||
self.view.insert_buffer(timelines.buffer , name=_(u"Timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
self.view.insert_buffer(timelines.buffer , name=_(u"Timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
||||||
for i in session.settings["other_buffers"]["timelines"]:
|
for i in session.settings["other_buffers"]["timelines"]:
|
||||||
tl = buffersController.baseBufferController(self.view.nb, "get_user_timeline", "%s-timeline" % (i,), session, session.db["user_name"], bufferType=None, screen_name=i, tweet_mode="extended")
|
tl = buffersController.baseBufferController(self.view.nb, "get_user_timeline", "%s-timeline" % (i,), session, session.db["user_name"], bufferType=None, user_id=i, tweet_mode="extended")
|
||||||
self.buffers.append(tl)
|
self.buffers.append(tl)
|
||||||
self.view.insert_buffer(tl.buffer, name=_(u"Timeline for {}").format(i,), pos=self.view.search("timelines", session.db["user_name"]))
|
self.view.insert_buffer(tl.buffer, name=_(u"Timeline for {}").format(i,), pos=self.view.search("timelines", session.db["user_name"]))
|
||||||
favs_timelines = buffersController.emptyPanel(self.view.nb, "favs_timelines", session.db["user_name"])
|
favs_timelines = buffersController.emptyPanel(self.view.nb, "favs_timelines", session.db["user_name"])
|
||||||
self.buffers.append(favs_timelines)
|
self.buffers.append(favs_timelines)
|
||||||
self.view.insert_buffer(favs_timelines.buffer , name=_(u"Likes timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
self.view.insert_buffer(favs_timelines.buffer , name=_(u"Likes timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
||||||
for i in session.settings["other_buffers"]["favourites_timelines"]:
|
for i in session.settings["other_buffers"]["favourites_timelines"]:
|
||||||
tl = buffersController.baseBufferController(self.view.nb, "get_favorites", "%s-favorite" % (i,), session, session.db["user_name"], bufferType=None, screen_name=i, tweet_mode="extended")
|
tl = buffersController.baseBufferController(self.view.nb, "get_favorites", "%s-favorite" % (i,), session, session.db["user_name"], bufferType=None, user_id=i, tweet_mode="extended")
|
||||||
self.buffers.append(tl)
|
self.buffers.append(tl)
|
||||||
self.view.insert_buffer(tl.buffer, name=_(u"Likes for {}").format(i,), pos=self.view.search("favs_timelines", session.db["user_name"]))
|
self.view.insert_buffer(tl.buffer, name=_(u"Likes for {}").format(i,), pos=self.view.search("favs_timelines", session.db["user_name"]))
|
||||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||||
@ -357,7 +358,7 @@ class Controller(object):
|
|||||||
self.buffers.append(followers_timelines)
|
self.buffers.append(followers_timelines)
|
||||||
self.view.insert_buffer(followers_timelines.buffer , name=_(u"Followers' Timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
self.view.insert_buffer(followers_timelines.buffer , name=_(u"Followers' Timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
||||||
for i in session.settings["other_buffers"]["followers_timelines"]:
|
for i in session.settings["other_buffers"]["followers_timelines"]:
|
||||||
tl = buffersController.peopleBufferController(self.view.nb, "get_followers_list", "%s-followers" % (i,), session, session.db["user_name"], screen_name=i)
|
tl = buffersController.peopleBufferController(self.view.nb, "get_followers_list", "%s-followers" % (i,), session, session.db["user_name"], user_id=i)
|
||||||
self.buffers.append(tl)
|
self.buffers.append(tl)
|
||||||
self.view.insert_buffer(tl.buffer, name=_(u"Followers for {}").format(i,), pos=self.view.search("followers_timelines", session.db["user_name"]))
|
self.view.insert_buffer(tl.buffer, name=_(u"Followers for {}").format(i,), pos=self.view.search("followers_timelines", session.db["user_name"]))
|
||||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||||
@ -366,7 +367,7 @@ class Controller(object):
|
|||||||
self.buffers.append(friends_timelines)
|
self.buffers.append(friends_timelines)
|
||||||
self.view.insert_buffer(friends_timelines.buffer , name=_(u"Friends' Timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
self.view.insert_buffer(friends_timelines.buffer , name=_(u"Friends' Timelines"), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
||||||
for i in session.settings["other_buffers"]["friends_timelines"]:
|
for i in session.settings["other_buffers"]["friends_timelines"]:
|
||||||
tl = buffersController.peopleBufferController(self.view.nb, "get_friends_list", "%s-friends" % (i,), session, session.db["user_name"], screen_name=i)
|
tl = buffersController.peopleBufferController(self.view.nb, "get_friends_list", "%s-friends" % (i,), session, session.db["user_name"], user_id=i)
|
||||||
self.buffers.append(tl)
|
self.buffers.append(tl)
|
||||||
self.view.insert_buffer(tl.buffer, name=_(u"Friends for {}").format(i,), pos=self.view.search("friends_timelines", session.db["user_name"]))
|
self.view.insert_buffer(tl.buffer, name=_(u"Friends for {}").format(i,), pos=self.view.search("friends_timelines", session.db["user_name"]))
|
||||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||||
@ -397,7 +398,7 @@ class Controller(object):
|
|||||||
buffer.timer.start()
|
buffer.timer.start()
|
||||||
self.view.insert_buffer(buffer.buffer, name=_(u"Trending topics for %s") % (buffer.name_), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
self.view.insert_buffer(buffer.buffer, name=_(u"Trending topics for %s") % (buffer.name_), pos=self.view.search(session.db["user_name"], session.db["user_name"]))
|
||||||
|
|
||||||
def set_buffer_positions(self,session):
|
def set_buffer_positions(self, session):
|
||||||
"Sets positions for buffers if values exist in the database."
|
"Sets positions for buffers if values exist in the database."
|
||||||
for i in self.buffers:
|
for i in self.buffers:
|
||||||
if i.account == session.db["user_name"] and session.db.has_key(i.name+"_pos") and hasattr(i.buffer,'list'):
|
if i.account == session.db["user_name"] and session.db.has_key(i.name+"_pos") and hasattr(i.buffer,'list'):
|
||||||
@ -807,13 +808,12 @@ class Controller(object):
|
|||||||
if dlg.get_user() in buff.session.settings["other_buffers"]["timelines"]:
|
if dlg.get_user() in buff.session.settings["other_buffers"]["timelines"]:
|
||||||
commonMessageDialogs.timeline_exist()
|
commonMessageDialogs.timeline_exist()
|
||||||
return
|
return
|
||||||
tl = buffersController.baseBufferController(self.view.nb, "get_user_timeline", "%s-timeline" % (dlg.get_user(),), buff.session, buff.session.db["user_name"], bufferType=None, screen_name=dlg.get_user())
|
tl = buffersController.baseBufferController(self.view.nb, "get_user_timeline", "%s-timeline" % (usr["id_str"],), buff.session, buff.session.db["user_name"], bufferType=None, user_id=usr["id_str"])
|
||||||
tl.start_stream()
|
|
||||||
pos=self.view.search("timelines", buff.session.db["user_name"])
|
pos=self.view.search("timelines", buff.session.db["user_name"])
|
||||||
self.insert_buffer(tl, pos+1)
|
self.insert_buffer(tl, pos+1)
|
||||||
# self.buffers.insert(pos+1, tl)
|
|
||||||
self.view.insert_buffer(tl.buffer, name=_(u"Timeline for {}").format(dlg.get_user()), pos=pos)
|
self.view.insert_buffer(tl.buffer, name=_(u"Timeline for {}").format(dlg.get_user()), pos=pos)
|
||||||
buff.session.settings["other_buffers"]["timelines"].append(dlg.get_user())
|
buff.session.settings["other_buffers"]["timelines"].append(usr["id_str"])
|
||||||
|
tl.start_stream()
|
||||||
pub.sendMessage("restart-streams", streams=["timelinesStream"], session=buff.session)
|
pub.sendMessage("restart-streams", streams=["timelinesStream"], session=buff.session)
|
||||||
buff.session.sound.play("create_timeline.ogg")
|
buff.session.sound.play("create_timeline.ogg")
|
||||||
elif tl_type == "favourites":
|
elif tl_type == "favourites":
|
||||||
@ -823,15 +823,14 @@ class Controller(object):
|
|||||||
if dlg.get_user() in buff.session.settings["other_buffers"]["favourites_timelines"]:
|
if dlg.get_user() in buff.session.settings["other_buffers"]["favourites_timelines"]:
|
||||||
commonMessageDialogs.timeline_exist()
|
commonMessageDialogs.timeline_exist()
|
||||||
return
|
return
|
||||||
tl = buffersController.baseBufferController(self.view.nb, "get_favorites", "%s-favorite" % (dlg.get_user(),), buff.session, buff.session.db["user_name"], bufferType=None, screen_name=dlg.get_user())
|
tl = buffersController.baseBufferController(self.view.nb, "get_favorites", "%s-favorite" % (usr["id_str"],), buff.session, buff.session.db["user_name"], bufferType=None, user_id=usr["id_str"])
|
||||||
pos=self.view.search("favs_timelines", buff.session.db["user_name"])
|
pos=self.view.search("favs_timelines", buff.session.db["user_name"])
|
||||||
self.insert_buffer(tl, pos+1)
|
self.insert_buffer(tl, pos+1)
|
||||||
# self.buffers.insert(pos+1, tl)
|
|
||||||
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Likes for {}").format(dlg.get_user()), pos=pos)
|
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Likes for {}").format(dlg.get_user()), pos=pos)
|
||||||
tl.start_stream()
|
tl.start_stream()
|
||||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||||
tl.timer.start()
|
tl.timer.start()
|
||||||
buff.session.settings["other_buffers"]["favourites_timelines"].append(dlg.get_user())
|
buff.session.settings["other_buffers"]["favourites_timelines"].append(usr["id_str"])
|
||||||
buff.session.sound.play("create_timeline.ogg")
|
buff.session.sound.play("create_timeline.ogg")
|
||||||
elif tl_type == "followers":
|
elif tl_type == "followers":
|
||||||
if usr["followers_count"] == 0:
|
if usr["followers_count"] == 0:
|
||||||
@ -840,17 +839,15 @@ class Controller(object):
|
|||||||
if dlg.get_user() in buff.session.settings["other_buffers"]["followers_timelines"]:
|
if dlg.get_user() in buff.session.settings["other_buffers"]["followers_timelines"]:
|
||||||
commonMessageDialogs.timeline_exist()
|
commonMessageDialogs.timeline_exist()
|
||||||
return
|
return
|
||||||
tl = buffersController.peopleBufferController(self.view.nb, "get_followers_list", "%s-followers" % (dlg.get_user(),), buff.session, buff.session.db["user_name"], screen_name=dlg.get_user())
|
tl = buffersController.peopleBufferController(self.view.nb, "get_followers_list", "%s-followers" % (usr["id_str"],), buff.session, buff.session.db["user_name"], user_id=usr["id_str"])
|
||||||
pos=self.view.search("followers_timelines", buff.session.db["user_name"])
|
pos=self.view.search("followers_timelines", buff.session.db["user_name"])
|
||||||
self.insert_buffer(tl, pos+1)
|
self.insert_buffer(tl, pos+1)
|
||||||
# self.buffers.insert(pos+1, tl)
|
|
||||||
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Followers for {}").format(dlg.get_user()), pos=pos)
|
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Followers for {}").format(dlg.get_user()), pos=pos)
|
||||||
tl.start_stream()
|
tl.start_stream()
|
||||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||||
tl.timer.start()
|
tl.timer.start()
|
||||||
buff.session.settings["other_buffers"]["followers_timelines"].append(dlg.get_user())
|
buff.session.settings["other_buffers"]["followers_timelines"].append(usr["id_str"])
|
||||||
buff.session.sound.play("create_timeline.ogg")
|
buff.session.sound.play("create_timeline.ogg")
|
||||||
|
|
||||||
elif tl_type == "friends":
|
elif tl_type == "friends":
|
||||||
if usr["friends_count"] == 0:
|
if usr["friends_count"] == 0:
|
||||||
commonMessageDialogs.no_friends()
|
commonMessageDialogs.no_friends()
|
||||||
@ -858,14 +855,14 @@ class Controller(object):
|
|||||||
if dlg.get_user() in buff.session.settings["other_buffers"]["friends_timelines"]:
|
if dlg.get_user() in buff.session.settings["other_buffers"]["friends_timelines"]:
|
||||||
commonMessageDialogs.timeline_exist()
|
commonMessageDialogs.timeline_exist()
|
||||||
return
|
return
|
||||||
tl = buffersController.peopleBufferController(self.view.nb, "get_friends_list", "%s-friends" % (dlg.get_user(),), buff.session, buff.session.db["user_name"], screen_name=dlg.get_user())
|
tl = buffersController.peopleBufferController(self.view.nb, "get_friends_list", "%s-friends" % (usr["id_str"],), buff.session, buff.session.db["user_name"], user_id=usr["id_str"])
|
||||||
pos=self.view.search("friends_timelines", buff.session.db["user_name"])
|
pos=self.view.search("friends_timelines", buff.session.db["user_name"])
|
||||||
self.insert_buffer(tl, pos+1)
|
self.insert_buffer(tl, pos+1)
|
||||||
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Friends for {}").format(dlg.get_user()), pos=pos)
|
self.view.insert_buffer(buffer=tl.buffer, name=_(u"Friends for {}").format(dlg.get_user()), pos=pos)
|
||||||
tl.start_stream()
|
tl.start_stream()
|
||||||
tl.timer = RepeatingTimer(300, tl.start_stream)
|
tl.timer = RepeatingTimer(300, tl.start_stream)
|
||||||
tl.timer.start()
|
tl.timer.start()
|
||||||
buff.session.settings["other_buffers"]["friends_timelines"].append(dlg.get_user())
|
buff.session.settings["other_buffers"]["friends_timelines"].append(usr["id_str"])
|
||||||
buff.session.sound.play("create_timeline.ogg")
|
buff.session.sound.play("create_timeline.ogg")
|
||||||
else:
|
else:
|
||||||
commonMessageDialogs.user_not_exist()
|
commonMessageDialogs.user_not_exist()
|
||||||
@ -1511,6 +1508,18 @@ class Controller(object):
|
|||||||
if hasattr(i, "remove_tweet") and hasattr(i, "name"):
|
if hasattr(i, "remove_tweet") and hasattr(i, "name"):
|
||||||
i.remove_tweet(id)
|
i.remove_tweet(id)
|
||||||
|
|
||||||
|
def buffer_title_changed(self, buffer):
|
||||||
|
if "-timeline" in buffer.name:
|
||||||
|
title = _(u"Timeline for {}").format(buffer.username,)
|
||||||
|
elif "-favorite" in buffer.name:
|
||||||
|
title = _(u"Likes for {}").format(buffer.username,)
|
||||||
|
elif "-followers" in buffer.name:
|
||||||
|
title = _(u"Followers for {}").format(buffer.username,)
|
||||||
|
elif "-friends" in buffer.name:
|
||||||
|
title = _(u"Friends for {}").format(buffer.username,)
|
||||||
|
buffer_index = self.view.search(buffer.name, buffer.account)
|
||||||
|
self.view.set_page_title(buffer_index, title)
|
||||||
|
|
||||||
def save_data_in_db(self):
|
def save_data_in_db(self):
|
||||||
for i in session_.sessions:
|
for i in session_.sessions:
|
||||||
session_.sessions[i].shelve()
|
session_.sessions[i].shelve()
|
@ -30,7 +30,7 @@ class timelinesStreamer(TwythonStreamer):
|
|||||||
|
|
||||||
def check_tls(self, data):
|
def check_tls(self, data):
|
||||||
for i in self.session.settings["other_buffers"]["timelines"]:
|
for i in self.session.settings["other_buffers"]["timelines"]:
|
||||||
if data["user"]["screen_name"] == i:
|
if data["user"]["id_str"] == i:
|
||||||
if utils.find_item(data["id"], self.session.db["%s-timeline" % (i,)]) != None:
|
if utils.find_item(data["id"], self.session.db["%s-timeline" % (i,)]) != None:
|
||||||
log.error("duplicated tweet. Ignoring it...")
|
log.error("duplicated tweet. Ignoring it...")
|
||||||
return
|
return
|
||||||
|
@ -186,5 +186,11 @@ class mainFrame(wx.Frame):
|
|||||||
if hasattr(self, menuitem):
|
if hasattr(self, menuitem):
|
||||||
getattr(self, menuitem).Check(check)
|
getattr(self, menuitem).Check(check)
|
||||||
|
|
||||||
|
def set_page_title(self, page, title):
|
||||||
|
return self.nb.SetPageText(page, title)
|
||||||
|
|
||||||
|
def get_page_title(self, page):
|
||||||
|
return self.nb.GetPageText(page)
|
||||||
|
|
||||||
def no_update_available():
|
def no_update_available():
|
||||||
wx.MessageDialog(None, _(u"Your {0} version is up to date").format(application.name,), _(u"Update"), style=wx.OK).ShowModal()
|
wx.MessageDialog(None, _(u"Your {0} version is up to date").format(application.name,), _(u"Update"), style=wx.OK).ShowModal()
|
Loading…
Reference in New Issue
Block a user