mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-18 16:40:41 -06:00
Added Tweet deletion based in streaming events
This commit is contained in:
parent
2124f6c60b
commit
92d803717f
@ -207,7 +207,7 @@ class accountPanel(bufferController):
|
||||
|
||||
class emptyPanel(bufferController):
|
||||
def __init__(self, parent, name, account):
|
||||
super(emptyPanel, self).__init__(parent, None, name)
|
||||
super(emptyPanel, self).__init__(parent=parent)
|
||||
log.debug("Initializing buffer %s, account %s" % (name, account,))
|
||||
self.buffer = buffers.emptyPanel(parent, name)
|
||||
self.type = self.buffer.type
|
||||
@ -350,6 +350,13 @@ class baseBufferController(bufferController):
|
||||
output.speak(_(u"This buffer is not a timeline; it can't be deleted."), True)
|
||||
return False
|
||||
|
||||
def remove_tweet(self, id):
|
||||
if type(self.session.db[self.name]) == dict: return
|
||||
for i in xrange(0, len(self.session.db[self.name])):
|
||||
if self.session.db[self.name][i]["id"] == id:
|
||||
self.session.db[self.name].pop(i)
|
||||
self.remove_item(i)
|
||||
|
||||
def put_items_on_list(self, number_of_items):
|
||||
log.debug("The list contains %d items " % (self.buffer.list.get_count(),))
|
||||
log.debug("Putting %d items on the list" % (number_of_items,))
|
||||
|
@ -119,6 +119,7 @@ class Controller(object):
|
||||
pub.subscribe(self.manage_item_in_timeline, "item-in-timeline")
|
||||
pub.subscribe(self.manage_item_in_list, "item-in-list")
|
||||
pub.subscribe(self.restart_streams_, "restart_streams")
|
||||
pub.subscribe(self.on_tweet_deleted, "tweet-deleted")
|
||||
widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
|
||||
|
||||
def bind_other_events(self):
|
||||
@ -1484,4 +1485,10 @@ class Controller(object):
|
||||
output.speak(_(u"Updating buffer..."))
|
||||
n = bf.start_stream(mandatory=True)
|
||||
if n != None:
|
||||
output.speak(_(u"{0} items retrieved").format(n,))
|
||||
output.speak(_(u"{0} items retrieved").format(n,))
|
||||
|
||||
def on_tweet_deleted(self, data):
|
||||
id = data["delete"]["status"]["id"]
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "remove_tweet") and hasattr(i, "name"):
|
||||
i.remove_tweet(id)
|
@ -126,6 +126,8 @@ class streamer(TwythonStreamer):
|
||||
|
||||
def on_success(self, data):
|
||||
try:
|
||||
if "delete" in data:
|
||||
pub.sendMessage("tweet-deleted", data=data)
|
||||
if "direct_message" in data:
|
||||
self.process_dm(data)
|
||||
elif "friends" in data:
|
||||
|
Loading…
x
Reference in New Issue
Block a user