mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
TWBlue allows ask for comment or not in a retweet. Check account settings
This commit is contained in:
parent
7565d2ea57
commit
c2521f28fc
@ -11,6 +11,7 @@ max_tweets_per_call = integer(default=100)
|
|||||||
reverse_timelines = boolean(default=False)
|
reverse_timelines = boolean(default=False)
|
||||||
time_to_check_streams = integer(default=30)
|
time_to_check_streams = integer(default=30)
|
||||||
announce_stream_status = boolean(default=True)
|
announce_stream_status = boolean(default=True)
|
||||||
|
retweet_mode = string(default="ask")
|
||||||
|
|
||||||
[sound]
|
[sound]
|
||||||
volume = float(default=1.0)
|
volume = float(default=1.0)
|
||||||
|
@ -365,8 +365,18 @@ class baseBufferController(bufferController):
|
|||||||
def retweet(self, *args, **kwargs):
|
def retweet(self, *args, **kwargs):
|
||||||
tweet = self.get_right_tweet()
|
tweet = self.get_right_tweet()
|
||||||
id = tweet["id"]
|
id = tweet["id"]
|
||||||
|
if self.session.settings["general"]["retweet_mode"] == "ask":
|
||||||
answer = commonMessageDialogs.retweet_question(self.buffer)
|
answer = commonMessageDialogs.retweet_question(self.buffer)
|
||||||
if answer == widgetUtils.YES:
|
if answer == widgetUtils.YES:
|
||||||
|
self._retweet_with_comment(tweet, id)
|
||||||
|
else:
|
||||||
|
self._direct_retweet(id)
|
||||||
|
elif self.session.settings["general"]["retweet_mode"] == "direct":
|
||||||
|
self._direct_retweet(id)
|
||||||
|
else:
|
||||||
|
self._retweet_with_comment(tweet, id)
|
||||||
|
|
||||||
|
def _retweet_with_comment(self, tweet, id):
|
||||||
retweet = messages.tweet(self.session, _(u"Retweet"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (tweet["user"]["screen_name"], tweet["text"]), max=116-len("@%s " % (tweet["user"]["screen_name"],)), messageType="retweet")
|
retweet = messages.tweet(self.session, _(u"Retweet"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (tweet["user"]["screen_name"], tweet["text"]), max=116-len("@%s " % (tweet["user"]["screen_name"],)), messageType="retweet")
|
||||||
if retweet.message.get_response() == widgetUtils.OK:
|
if retweet.message.get_response() == widgetUtils.OK:
|
||||||
text = retweet.message.get_text()
|
text = retweet.message.get_text()
|
||||||
@ -379,7 +389,8 @@ class baseBufferController(bufferController):
|
|||||||
else:
|
else:
|
||||||
call_threaded(self.session.api_call, call_name="update_status", _sound="retweet_send.ogg", status=text, media=retweet.image)
|
call_threaded(self.session.api_call, call_name="update_status", _sound="retweet_send.ogg", status=text, media=retweet.image)
|
||||||
if hasattr(retweet.message, "destroy"): retweet.message.destroy()
|
if hasattr(retweet.message, "destroy"): retweet.message.destroy()
|
||||||
elif answer == widgetUtils.NO:
|
|
||||||
|
def _direct_retweet(self, id):
|
||||||
call_threaded(self.session.api_call, call_name="retweet", _sound="retweet_send.ogg", id=id)
|
call_threaded(self.session.api_call, call_name="retweet", _sound="retweet_send.ogg", id=id)
|
||||||
|
|
||||||
def onFocus(self, *args, **kwargs):
|
def onFocus(self, *args, **kwargs):
|
||||||
@ -487,6 +498,8 @@ class eventsBufferController(bufferController):
|
|||||||
self.buffer.list.insert_item(True, *tweet)
|
self.buffer.list.insert_item(True, *tweet)
|
||||||
if self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
|
if self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
|
||||||
output.speak(" ".join(tweet))
|
output.speak(" ".join(tweet))
|
||||||
|
if self.buffer.list.get_count() == 1:
|
||||||
|
self.buffer.list.select_item(0)
|
||||||
|
|
||||||
def clear_list(self):
|
def clear_list(self):
|
||||||
dlg = commonMessageDialogs.clear_list()
|
dlg = commonMessageDialogs.clear_list()
|
||||||
|
67
src/controller/listsController.py
Normal file
67
src/controller/listsController.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import widgetUtils
|
||||||
|
import output
|
||||||
|
from wxUI.dialogs import lists
|
||||||
|
from twython import TwythonError
|
||||||
|
from twitter import compose, utils
|
||||||
|
|
||||||
|
class listsController(object):
|
||||||
|
def __init__(self, session, user=None):
|
||||||
|
super(listsController, self).__init__()
|
||||||
|
self.session = session
|
||||||
|
if user == None:
|
||||||
|
self.dialog = lists.listViewer()
|
||||||
|
self.dialog.populate_list(self.get_all_lists())
|
||||||
|
widgetUtils.connect_event(self.dialog.createBtn, widgetUtils.BUTTON_PRESSED, self.create_list)
|
||||||
|
widgetUtils.connect_event(self.dialog.editBtn, widgetUtils.BUTTON_PRESSED, self.edit_list)
|
||||||
|
self.dialog.get_response()
|
||||||
|
|
||||||
|
def get_all_lists(self):
|
||||||
|
return [compose.compose_list(item) for item in self.session.db["lists"]]
|
||||||
|
|
||||||
|
def create_list(self, *args, **kwargs):
|
||||||
|
dialog = lists.createListDialog()
|
||||||
|
if dialog.get_response() == widgetUtils.OK:
|
||||||
|
name = dialog.get("name")
|
||||||
|
description = dialog.get("description")
|
||||||
|
p = dialog.get("public")
|
||||||
|
if public == True:
|
||||||
|
mode = "public"
|
||||||
|
else:
|
||||||
|
mode = "private"
|
||||||
|
try:
|
||||||
|
new_list = self.session.twitter.twitter.create_list(name=name, description=description, mode=mode)
|
||||||
|
self.session.db["lists"].append(new_list)
|
||||||
|
self.dialog.lista.insert_item(False, *compose.compose_list(new_list))
|
||||||
|
except TwythonError as e:
|
||||||
|
output.speak("error %s: %s" % (e.status_code, e.msg))
|
||||||
|
dialog.destroy()
|
||||||
|
|
||||||
|
def edit_list(self, *args, **kwargs):
|
||||||
|
if self.dialog.lista.get_count() == 0: return
|
||||||
|
list = self.session.db["lists"][self.dialog.get_item()]
|
||||||
|
dialog = lists.editListDialog(list)
|
||||||
|
if dialog.get_response() == widgetUtils.OK:
|
||||||
|
name = dialog.get("name")
|
||||||
|
description = dialog.get("description")
|
||||||
|
p = dialog.get("public")
|
||||||
|
if p == True:
|
||||||
|
mode = "public"
|
||||||
|
else:
|
||||||
|
mode = "private"
|
||||||
|
try:
|
||||||
|
self.session.twitter.twitter.update_list(list_id=list["id"], name=name, description=description, mode=mode)
|
||||||
|
except TwythonError as e:
|
||||||
|
output.speak("error %s: %s" % (e.error_code, e.msg))
|
||||||
|
dialog.destroy()
|
||||||
|
|
||||||
|
def remove_list(self, *args, **kwargs):
|
||||||
|
if self.dialog.lista.get_count() == 0: return
|
||||||
|
list = self.session.db["lists"][self.dialog.get_item()]["id"]
|
||||||
|
if lists.remove_list() == widgetUtils.YES:
|
||||||
|
try:
|
||||||
|
self.session.twitter.twitter.delete_list(list_id=list)
|
||||||
|
self.session.db["lists"].pop(self.dialog.get_item())
|
||||||
|
self.dialog.lista.remove_item(self.dialog.get_item())
|
||||||
|
except TwythonError as e:
|
||||||
|
output.speak("error %s: %s" % (e.error_code, e.msg))
|
@ -12,6 +12,7 @@ if system == "Windows":
|
|||||||
import userActionsController
|
import userActionsController
|
||||||
import trendingTopics
|
import trendingTopics
|
||||||
import user
|
import user
|
||||||
|
import listsController
|
||||||
from issueReporter import issueReporter
|
from issueReporter import issueReporter
|
||||||
elif system == "Linux":
|
elif system == "Linux":
|
||||||
from gtkUI import (view, commonMessageDialogs)
|
from gtkUI import (view, commonMessageDialogs)
|
||||||
@ -124,6 +125,7 @@ class Controller(object):
|
|||||||
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
|
pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed")
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.search, menuitem=self.view.menuitem_search)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.search, menuitem=self.view.menuitem_search)
|
||||||
|
# widgetUtils.connect_event(self.view, widgetUtils.MENU, self.list_manager, menuitem=self.view.lists)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.get_trending_topics, menuitem=self.view.trends)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.get_trending_topics, menuitem=self.view.trends)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.accountConfiguration, menuitem=self.view.account_settings)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.accountConfiguration, menuitem=self.view.account_settings)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.configuration, menuitem=self.view.prefs)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.configuration, menuitem=self.view.prefs)
|
||||||
@ -432,8 +434,10 @@ class Controller(object):
|
|||||||
def remove_from_list(self, user):
|
def remove_from_list(self, user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def lists_manager(self):
|
def list_manager(self, *args, **kwargs):
|
||||||
pass
|
s = self.get_best_buffer().session
|
||||||
|
l = listsController.listsController(s)
|
||||||
|
|
||||||
|
|
||||||
def configuration(self, *args, **kwargs):
|
def configuration(self, *args, **kwargs):
|
||||||
""" Opens the global settings dialogue."""
|
""" Opens the global settings dialogue."""
|
||||||
|
@ -65,6 +65,13 @@ class accountSettingsController(globalSettingsController):
|
|||||||
self.dialog.set_value("general", "apiCalls", self.config["general"]["max_api_calls"])
|
self.dialog.set_value("general", "apiCalls", self.config["general"]["max_api_calls"])
|
||||||
self.dialog.set_value("general", "itemsPerApiCall", self.config["general"]["max_tweets_per_call"])
|
self.dialog.set_value("general", "itemsPerApiCall", self.config["general"]["max_tweets_per_call"])
|
||||||
self.dialog.set_value("general", "reverse_timelines", self.config["general"]["reverse_timelines"])
|
self.dialog.set_value("general", "reverse_timelines", self.config["general"]["reverse_timelines"])
|
||||||
|
rt = self.config["general"]["retweet_mode"]
|
||||||
|
if rt == "ask":
|
||||||
|
self.dialog.set_value("general", "retweet_mode", _(u"Ask"))
|
||||||
|
elif rt == "direct":
|
||||||
|
self.dialog.set_value("general", "retweet_mode", _(u"Retweet without comments"))
|
||||||
|
else:
|
||||||
|
self.dialog.set_value("general", "retweet_mode", _(u"Retweet with comments"))
|
||||||
self.dialog.create_other_buffers()
|
self.dialog.create_other_buffers()
|
||||||
self.dialog.set_value("buffers", "followers", self.config["other_buffers"]["show_followers"])
|
self.dialog.set_value("buffers", "followers", self.config["other_buffers"]["show_followers"])
|
||||||
self.dialog.set_value("buffers", "friends", self.config["other_buffers"]["show_friends"])
|
self.dialog.set_value("buffers", "friends", self.config["other_buffers"]["show_friends"])
|
||||||
@ -105,6 +112,13 @@ class accountSettingsController(globalSettingsController):
|
|||||||
if self.config["general"]["reverse_timelines"] != self.dialog.get_value("general", "reverse_timelines"):
|
if self.config["general"]["reverse_timelines"] != self.dialog.get_value("general", "reverse_timelines"):
|
||||||
self.needs_restart = True
|
self.needs_restart = True
|
||||||
self.config["general"]["reverse_timelines"] = self.dialog.get_value("general", "reverse_timelines")
|
self.config["general"]["reverse_timelines"] = self.dialog.get_value("general", "reverse_timelines")
|
||||||
|
rt = self.dialog.get_value("general", "retweet_mode")
|
||||||
|
if rt == _(u"Ask"):
|
||||||
|
self.config["general"]["retweet_mode"] = "ask"
|
||||||
|
elif rt == _(u"Retweet without comments"):
|
||||||
|
self.config["general"]["retweet_mode"] = "direct"
|
||||||
|
else:
|
||||||
|
self.config["general"]["retweet_mode"] = "comment"
|
||||||
if self.config["other_buffers"]["show_followers"] != self.dialog.get_value("buffers", "followers"):
|
if self.config["other_buffers"]["show_followers"] != self.dialog.get_value("buffers", "followers"):
|
||||||
self.config["other_buffers"]["show_followers"] = self.dialog.get_value("buffers", "followers")
|
self.config["other_buffers"]["show_followers"] = self.dialog.get_value("buffers", "followers")
|
||||||
pub.sendMessage("create-new-buffer", buffer="followers", account=self.user, create=self.config["other_buffers"]["show_followers"])
|
pub.sendMessage("create-new-buffer", buffer="followers", account=self.user, create=self.config["other_buffers"]["show_followers"])
|
||||||
|
@ -48,6 +48,12 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
|
|||||||
sizer.Add(tweetsPerCallBox, 0, wx.ALL, 5)
|
sizer.Add(tweetsPerCallBox, 0, wx.ALL, 5)
|
||||||
self.reverse_timelines = wx.CheckBox(self, wx.NewId(), _(u"Inverted buffers: The newest tweets will be shown at the beginning of the lists while the oldest at the end"))
|
self.reverse_timelines = wx.CheckBox(self, wx.NewId(), _(u"Inverted buffers: The newest tweets will be shown at the beginning of the lists while the oldest at the end"))
|
||||||
sizer.Add(self.reverse_timelines, 0, wx.ALL, 5)
|
sizer.Add(self.reverse_timelines, 0, wx.ALL, 5)
|
||||||
|
lbl = wx.StaticText(self, wx.NewId(), _(u"Retweets mode"))
|
||||||
|
self.retweet_mode = wx.ComboBox(self, wx.NewId(), choices=[_(u"Ask"), _(u"Retweet without comments"), _(u"Retweet with comments")], style=wx.CB_READONLY)
|
||||||
|
rMode = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
rMode.Add(lbl, 0, wx.ALL, 5)
|
||||||
|
rMode.Add(self.retweet_mode, 0, wx.ALL, 5)
|
||||||
|
sizer.Add(rMode, 0, wx.ALL, 5)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
class other_buffers(wx.Panel):
|
class other_buffers(wx.Panel):
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import wx
|
import wx
|
||||||
|
import widgetUtils
|
||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
|
|
||||||
class listViewer(wx.Dialog):
|
class listViewer(widgetUtils.BaseDialog):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(listViewer, self).__init__(parent=None, *args, **kwargs)
|
super(listViewer, self).__init__(parent=None, *args, **kwargs)
|
||||||
@ -48,10 +49,10 @@ class userListViewer(listViewer):
|
|||||||
self.editBtn.Disable()
|
self.editBtn.Disable()
|
||||||
self.view.Disable()
|
self.view.Disable()
|
||||||
|
|
||||||
class createListDialog(wx.Dialog):
|
class createListDialog(widgetUtils.BaseDialog):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(createListDialog, self).__init__(*args, **kwargs)
|
super(createListDialog, self).__init__(parent=None, *args, **kwargs)
|
||||||
self.SetTitle(_(u"Create a new list"))
|
self.SetTitle(_(u"Create a new list"))
|
||||||
panel = wx.Panel(self)
|
panel = wx.Panel(self)
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
@ -83,9 +84,6 @@ class createListDialog(wx.Dialog):
|
|||||||
sizer.Add(modeBox)
|
sizer.Add(modeBox)
|
||||||
sizer.Add(btnBox)
|
sizer.Add(btnBox)
|
||||||
|
|
||||||
def get(self, field):
|
|
||||||
return getattr(self, field).GetValue()
|
|
||||||
|
|
||||||
class editListDialog(createListDialog):
|
class editListDialog(createListDialog):
|
||||||
|
|
||||||
def __init__(self, list, *args, **kwargs):
|
def __init__(self, list, *args, **kwargs):
|
||||||
@ -121,3 +119,7 @@ class removeUserListDialog(listViewer):
|
|||||||
# self.subscriptors.Disable()
|
# self.subscriptors.Disable()
|
||||||
# self.members.Disable()
|
# self.members.Disable()
|
||||||
self.deleteBtn.Disable()
|
self.deleteBtn.Disable()
|
||||||
|
|
||||||
|
def remove_list():
|
||||||
|
return wx.MessageDialog(None, _("Do you really want to delete this list?"), _("Delete"), wx.YES_NO).ShowModal()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user