mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Update buffers by pressing ctrl+win+shift+u; workaround for dm issues
This commit is contained in:
parent
0882e4707d
commit
0afba81c71
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
name = 'TWBlue'
|
||||
snapshot = False
|
||||
snapshot = True
|
||||
if snapshot == False:
|
||||
version = "0.80"
|
||||
update_url = 'http://twblue.es/updates/twblue_ngen.json'
|
||||
|
@ -84,7 +84,9 @@ class bufferController(object):
|
||||
sound.URLPlayer.stream.volume = self.session.settings["sound"]["volume"]
|
||||
self.session.sound.play("volume_changed.ogg")
|
||||
|
||||
def start_stream(self):
|
||||
def start_stream(self, mandatory=False):
|
||||
if mandatory == True:
|
||||
output.speak(_(u"Unable to update this buffer."))
|
||||
pass
|
||||
|
||||
def get_more_items(self):
|
||||
@ -272,10 +274,10 @@ class baseBufferController(bufferController):
|
||||
tweetsList.append(tweet)
|
||||
return (tweet, tweetsList)
|
||||
|
||||
def start_stream(self):
|
||||
def start_stream(self, mandatory=False):
|
||||
# starts stream every 3 minutes.
|
||||
current_time = time.time()
|
||||
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||
if self.execution_time == 0 or current_time-self.execution_time >= 180 or mandatory==True:
|
||||
self.execution_time = current_time
|
||||
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
|
||||
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
|
||||
@ -283,9 +285,9 @@ class baseBufferController(bufferController):
|
||||
number_of_items = self.session.order_buffer(self.name, val)
|
||||
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":
|
||||
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)
|
||||
return number_of_items
|
||||
|
||||
def get_more_items(self):
|
||||
elements = []
|
||||
@ -481,7 +483,13 @@ class baseBufferController(bufferController):
|
||||
users = utils.get_all_users(tweet, self.session.db)
|
||||
dm = messages.dm(self.session, _(u"Direct message to %s") % (screen_name,), _(u"New direct message"), users)
|
||||
if dm.message.get_response() == widgetUtils.OK:
|
||||
call_threaded(self.session.api_call, call_name="send_direct_message", text=dm.message.get_text(), screen_name=dm.message.get("cb"))
|
||||
val = self.session.api_call(call_name="send_direct_message", text=dm.message.get_text(), screen_name=dm.message.get("cb"))
|
||||
if val != None:
|
||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||
self.session.db["sent_direct_messages"].append(val)
|
||||
else:
|
||||
self.session.db["sent_direct_messages"].insert(0, val)
|
||||
pub.sendMessage("sent-dm", data=val, user=self.session.db["user_name"])
|
||||
if hasattr(dm.message, "destroy"): dm.message.destroy()
|
||||
|
||||
@_tweets_exist
|
||||
@ -638,9 +646,9 @@ class listBufferController(baseBufferController):
|
||||
self.list_id = list_id
|
||||
self.kwargs["list_id"] = list_id
|
||||
|
||||
def start_stream(self):
|
||||
def start_stream(self, mandatory=False):
|
||||
self.get_user_ids()
|
||||
super(listBufferController, self).start_stream()
|
||||
super(listBufferController, self).start_stream(mandatory)
|
||||
|
||||
def get_user_ids(self):
|
||||
self.users = []
|
||||
@ -762,15 +770,16 @@ class peopleBufferController(baseBufferController):
|
||||
call_threaded(self.session.api_call, call_name="update_status_with_media", _sound="reply_send.ogg", status=message.message.get_text(), media=message.file)
|
||||
if hasattr(message.message, "destroy"): message.message.destroy()
|
||||
|
||||
def start_stream(self):
|
||||
def start_stream(self, mandatory=False):
|
||||
# starts stream every 3 minutes.
|
||||
current_time = time.time()
|
||||
if self.execution_time == 0 or current_time-self.execution_time >= 180:
|
||||
if self.execution_time == 0 or current_time-self.execution_time >= 180 or mandatory==True:
|
||||
self.execution_time = current_time
|
||||
log.debug("Starting stream for %s buffer, %s account" % (self.name, self.account,))
|
||||
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)
|
||||
return val
|
||||
|
||||
def get_more_items(self):
|
||||
try:
|
||||
@ -875,6 +884,7 @@ class searchBufferController(baseBufferController):
|
||||
self.put_items_on_list(num)
|
||||
if num > 0:
|
||||
self.session.sound.play("search_updated.ogg")
|
||||
return num
|
||||
|
||||
def remove_buffer(self):
|
||||
dlg = commonMessageDialogs.remove_buffer()
|
||||
@ -914,6 +924,7 @@ class searchPeopleBufferController(peopleBufferController):
|
||||
self.put_items_on_list(number_of_items)
|
||||
if number_of_items > 0:
|
||||
self.session.sound.play("search_updated.ogg")
|
||||
return number_of_items
|
||||
|
||||
def remove_buffer(self):
|
||||
dlg = commonMessageDialogs.remove_buffer()
|
||||
@ -1070,6 +1081,7 @@ class conversationBufferController(searchBufferController):
|
||||
self.put_items_on_list(number_of_items)
|
||||
if number_of_items > 0:
|
||||
self.session.sound.play("search_updated.ogg")
|
||||
return number_of_items
|
||||
|
||||
def remove_buffer(self):
|
||||
dlg = commonMessageDialogs.remove_buffer()
|
||||
|
@ -118,6 +118,7 @@ class Controller(object):
|
||||
pub.subscribe(self.manage_unblocked_user, "unblocked-user")
|
||||
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")
|
||||
widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
|
||||
|
||||
def bind_other_events(self):
|
||||
@ -1459,5 +1460,21 @@ class Controller(object):
|
||||
if hasattr(self, action):
|
||||
getattr(self, action)()
|
||||
|
||||
def restart_streams(self, session):
|
||||
for i in self.buffers:
|
||||
if i.session != None and i.session.session_id == session:
|
||||
i.start_stream()
|
||||
|
||||
def __del__(self):
|
||||
config.app.write()
|
||||
config.app.write()
|
||||
|
||||
def update_buffer(self, *args, **kwargs):
|
||||
bf = self.get_current_buffer()
|
||||
if not hasattr(bf, "start_stream"):
|
||||
output.speak(_(u"Unable to update this buffer."))
|
||||
return
|
||||
else:
|
||||
output.speak(_(u"Updating buffer..."))
|
||||
n = bf.start_stream(mandatory=True)
|
||||
if n != None:
|
||||
output.speak(_(u"{0} items retrieved").format(n,))
|
@ -31,4 +31,5 @@ find = string(default="control+win+shift+/")
|
||||
check_for_updates = string(default="alt+win+u)
|
||||
list_manager = string(default="control+win+shift+l")
|
||||
configuration = string(default="control+win+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
update_buffer = string(default="control+win+shift+u")
|
@ -50,4 +50,5 @@ get_trending_topics = string(default="control+win+shift+t")
|
||||
check_for_updates = string(default="control+win+u")
|
||||
list_manager = string(default="control+win+shift+l")
|
||||
configuration = string(default="control+win+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
update_buffer = string(default="control+win+shift+u")
|
@ -52,4 +52,5 @@ get_trending_topics = string(default="alt+win+t")
|
||||
check_for_updates = string(default="alt+win+u")
|
||||
list_manager = string(default="alt+win+shift+l")
|
||||
configuration = string(default="control+win+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
update_buffer = string(default="control+alt+shift+u")
|
@ -53,4 +53,5 @@ get_trending_topics = string(default="control+win+t")
|
||||
check_for_updates = string(default="control+win+u")
|
||||
list_manager = string(default="control+win+shift+l")
|
||||
configuration = string(default="control+win+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
update_buffer = string(default="control+win+shift+u")
|
@ -53,4 +53,5 @@ find = string(default="control+win+{")
|
||||
check_for_updates = string(default="control+win+u")
|
||||
list_manager = string(default="control+win+shift+l")
|
||||
configuration = string(default="control+win+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
accountConfiguration = string(default="control+win+shift+o")
|
||||
update_buffer = string(default="control+win+shift+u")
|
@ -51,4 +51,5 @@ actions = {
|
||||
"configuration": _(u"Opens the global settings dialogue"),
|
||||
"accountConfiguration": _(u"Opens the account settings dialogue"),
|
||||
"audio": _(u"Try to play an audio file"),
|
||||
"update_buffer": _(u"Updates the buffer and retrieves possible lost items there."),
|
||||
}
|
@ -194,6 +194,7 @@ class Session(object):
|
||||
if report_success:
|
||||
output.speak(_("%s succeeded.") % action)
|
||||
if _sound != None: self.sound.play(_sound)
|
||||
return val
|
||||
|
||||
def search(self, name, *args, **kwargs):
|
||||
tl = self.twitter.twitter.search(*args, **kwargs)
|
||||
@ -352,7 +353,7 @@ class Session(object):
|
||||
self.logged = False
|
||||
self.twitter = twitter.twitter.twitter()
|
||||
self.login(False)
|
||||
# pub.sendMessage("streamError", session=self.session_id)
|
||||
pub.sendMessage("restart_streams", session=self.session_id)
|
||||
if self.reconnection_function_active == True: return
|
||||
self.reconnection_function_active = True
|
||||
if not hasattr(self, "main_stream"):
|
||||
|
Loading…
Reference in New Issue
Block a user