mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-04-04 19:12:28 -04:00
Now conversation buffers are removed properly
This commit is contained in:
parent
594b0cd546
commit
e1d14b8c27
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import time
|
||||||
import platform
|
import platform
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
import wx
|
import wx
|
||||||
@ -42,6 +43,7 @@ class bufferController(object):
|
|||||||
self.account = ""
|
self.account = ""
|
||||||
self.needs_init = True
|
self.needs_init = True
|
||||||
self.invisible = False # False if the buffer will be ignored on the invisible interface.
|
self.invisible = False # False if the buffer will be ignored on the invisible interface.
|
||||||
|
self.execution_time = 0
|
||||||
|
|
||||||
def clear_list(self): pass
|
def clear_list(self): pass
|
||||||
|
|
||||||
@ -271,15 +273,19 @@ class baseBufferController(bufferController):
|
|||||||
return (tweet, tweetsList)
|
return (tweet, tweetsList)
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
|
# starts stream every 3 minutes.
|
||||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
current_time = time.time()
|
||||||
val = self.session.call_paged(self.function, *self.args, **self.kwargs)
|
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||||
number_of_items = self.session.order_buffer(self.name, val)
|
self.execution_time = current_time
|
||||||
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
|
||||||
self.put_items_on_list(number_of_items)
|
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||||
if self.sound == None: return
|
val = self.session.call_paged(self.function, *self.args, **self.kwargs)
|
||||||
if number_of_items > 0 and self.name != "sent_tweets" and self.name != "sent_direct_messages":
|
number_of_items = self.session.order_buffer(self.name, val)
|
||||||
self.session.sound.play(self.sound)
|
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
||||||
|
self.put_items_on_list(number_of_items)
|
||||||
|
if self.sound == None: return
|
||||||
|
if number_of_items > 0 and self.name != "sent_tweets" and self.name != "sent_direct_messages":
|
||||||
|
self.session.sound.play(self.sound)
|
||||||
|
|
||||||
def get_more_items(self):
|
def get_more_items(self):
|
||||||
elements = []
|
elements = []
|
||||||
@ -739,12 +745,14 @@ class peopleBufferController(baseBufferController):
|
|||||||
if hasattr(message.message, "destroy"): message.message.destroy()
|
if hasattr(message.message, "destroy"): message.message.destroy()
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
log.debug("Starting stream for %s buffer, %s account" % (self.name, self.account,))
|
# starts stream every 3 minutes.
|
||||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
current_time = time.time()
|
||||||
val = self.session.get_cursored_stream(self.name, self.function, *self.args, **self.kwargs)
|
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||||
# self.session.order_cursored_buffer(self.name, self.session.db[self.name])
|
self.execution_time = current_time
|
||||||
# log.debug("Number of items retrieved: %d" % (val,))
|
log.debug("Starting stream for %s buffer, %s account" % (self.name, self.account,))
|
||||||
self.put_items_on_list(val)
|
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||||
|
val = self.session.get_cursored_stream(self.name, self.function, *self.args, **self.kwargs)
|
||||||
|
self.put_items_on_list(val)
|
||||||
|
|
||||||
def get_more_items(self):
|
def get_more_items(self):
|
||||||
try:
|
try:
|
||||||
@ -834,17 +842,21 @@ class peopleBufferController(baseBufferController):
|
|||||||
|
|
||||||
class searchBufferController(baseBufferController):
|
class searchBufferController(baseBufferController):
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
log.debug("Starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type))
|
# starts stream every 3 minutes.
|
||||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
current_time = time.time()
|
||||||
log.debug("Function: %s" % (self.function,))
|
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||||
|
self.execution_time = current_time
|
||||||
|
log.debug("Starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type))
|
||||||
|
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||||
|
log.debug("Function: %s" % (self.function,))
|
||||||
# try:
|
# try:
|
||||||
val = self.session.search(self.name, *self.args, **self.kwargs)
|
val = self.session.search(self.name, *self.args, **self.kwargs)
|
||||||
# except:
|
# except:
|
||||||
# return None
|
# return None
|
||||||
num = self.session.order_buffer(self.name, val)
|
num = self.session.order_buffer(self.name, val)
|
||||||
self.put_items_on_list(num)
|
self.put_items_on_list(num)
|
||||||
if num > 0:
|
if num > 0:
|
||||||
self.session.sound.play("search_updated.ogg")
|
self.session.sound.play("search_updated.ogg")
|
||||||
|
|
||||||
def remove_buffer(self):
|
def remove_buffer(self):
|
||||||
dlg = commonMessageDialogs.remove_buffer()
|
dlg = commonMessageDialogs.remove_buffer()
|
||||||
@ -868,18 +880,22 @@ class searchPeopleBufferController(peopleBufferController):
|
|||||||
self.function = function
|
self.function = function
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
log.debug("starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type))
|
# starts stream every 3 minutes.
|
||||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
current_time = time.time()
|
||||||
log.debug("Function: %s" % (self.function,))
|
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||||
|
self.execution_time = current_time
|
||||||
|
log.debug("starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type))
|
||||||
|
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||||
|
log.debug("Function: %s" % (self.function,))
|
||||||
# try:
|
# try:
|
||||||
val = self.session.call_paged(self.function, *self.args, **self.kwargs)
|
val = self.session.call_paged(self.function, *self.args, **self.kwargs)
|
||||||
# except:
|
# except:
|
||||||
# return
|
# return
|
||||||
number_of_items = self.session.order_cursored_buffer(self.name, val)
|
number_of_items = self.session.order_cursored_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 number_of_items > 0:
|
if number_of_items > 0:
|
||||||
self.session.sound.play("search_updated.ogg")
|
self.session.sound.play("search_updated.ogg")
|
||||||
|
|
||||||
def remove_buffer(self):
|
def remove_buffer(self):
|
||||||
dlg = commonMessageDialogs.remove_buffer()
|
dlg = commonMessageDialogs.remove_buffer()
|
||||||
@ -911,15 +927,19 @@ class trendsBufferController(bufferController):
|
|||||||
self.reply = self.search_topic
|
self.reply = self.search_topic
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
try:
|
# starts stream every 3 minutes.
|
||||||
data = self.session.call_paged("get_place_trends", id=self.trendsFor)
|
current_time = time.time()
|
||||||
except:
|
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||||
return
|
self.execution_time = current_time
|
||||||
if not hasattr(self, "name_"):
|
try:
|
||||||
self.name_ = data[0]["locations"][0]["name"]
|
data = self.session.call_paged("get_place_trends", id=self.trendsFor)
|
||||||
self.trends = data[0]["trends"]
|
except:
|
||||||
self.put_items_on_the_list()
|
return
|
||||||
self.session.sound.play(self.sound)
|
if not hasattr(self, "name_"):
|
||||||
|
self.name_ = data[0]["locations"][0]["name"]
|
||||||
|
self.trends = data[0]["trends"]
|
||||||
|
self.put_items_on_the_list()
|
||||||
|
self.session.sound.play(self.sound)
|
||||||
|
|
||||||
def put_items_on_the_list(self):
|
def put_items_on_the_list(self):
|
||||||
selected_item = self.buffer.list.get_selected()
|
selected_item = self.buffer.list.get_selected()
|
||||||
@ -1004,30 +1024,42 @@ class trendsBufferController(bufferController):
|
|||||||
class conversationBufferController(searchBufferController):
|
class conversationBufferController(searchBufferController):
|
||||||
|
|
||||||
def start_stream(self, start=False):
|
def start_stream(self, start=False):
|
||||||
if start == True:
|
# starts stream every 3 minutes.
|
||||||
self.statuses = []
|
current_time = time.time()
|
||||||
self.ids = []
|
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||||
self.statuses.append(self.tweet)
|
self.execution_time = current_time
|
||||||
self.ids.append(self.tweet["id"])
|
if start == True:
|
||||||
tweet = self.tweet
|
self.statuses = []
|
||||||
while tweet["in_reply_to_status_id"] != None:
|
self.ids = []
|
||||||
tweet = self.session.twitter.twitter.show_status(id=tweet["in_reply_to_status_id"])
|
self.statuses.append(self.tweet)
|
||||||
self.statuses.insert(0, tweet)
|
self.ids.append(self.tweet["id"])
|
||||||
self.ids.append(tweet["id"])
|
tweet = self.tweet
|
||||||
if tweet["in_reply_to_status_id"] == None:
|
while tweet["in_reply_to_status_id"] != None:
|
||||||
self.kwargs["since_id"] = tweet["id"]
|
tweet = self.session.twitter.twitter.show_status(id=tweet["in_reply_to_status_id"])
|
||||||
self.ids.append(tweet["id"])
|
self.statuses.insert(0, tweet)
|
||||||
val2 = self.session.search(self.name, *self.args, **self.kwargs)
|
self.ids.append(tweet["id"])
|
||||||
for i in val2:
|
if tweet["in_reply_to_status_id"] == None:
|
||||||
if i["in_reply_to_status_id"] in self.ids:
|
self.kwargs["since_id"] = tweet["id"]
|
||||||
self.statuses.append(i)
|
self.ids.append(tweet["id"])
|
||||||
self.ids.append(i["id"])
|
val2 = self.session.search(self.name, *self.args, **self.kwargs)
|
||||||
tweet = i
|
for i in val2:
|
||||||
number_of_items = self.session.order_buffer(self.name, self.statuses)
|
if i["in_reply_to_status_id"] in self.ids:
|
||||||
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
self.statuses.append(i)
|
||||||
self.put_items_on_list(number_of_items)
|
self.ids.append(i["id"])
|
||||||
if number_of_items > 0:
|
tweet = i
|
||||||
self.session.sound.play("search_updated.ogg")
|
number_of_items = self.session.order_buffer(self.name, self.statuses)
|
||||||
|
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
||||||
|
self.put_items_on_list(number_of_items)
|
||||||
|
if number_of_items > 0:
|
||||||
|
self.session.sound.play("search_updated.ogg")
|
||||||
|
|
||||||
|
def remove_buffer(self):
|
||||||
|
dlg = commonMessageDialogs.remove_buffer()
|
||||||
|
if dlg == widgetUtils.YES:
|
||||||
|
self.timer.cancel()
|
||||||
|
return True
|
||||||
|
elif dlg == WidgetUtils.NO:
|
||||||
|
return False
|
||||||
|
|
||||||
class pocketBufferController(baseBufferController):
|
class pocketBufferController(baseBufferController):
|
||||||
def __init__(self, parent, name, sessionObject, account, sound=None, function=None, bufferType=None, *args, **kwargs):
|
def __init__(self, parent, name, sessionObject, account, sound=None, function=None, bufferType=None, *args, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user