Retweets, add and remove from favourites are supported

This commit is contained in:
Manuel Cortez 2015-01-02 10:53:33 -06:00
parent 5cb4e0fef7
commit a599b37e6d
3 changed files with 46 additions and 10 deletions

View File

@ -8,7 +8,7 @@ import config
import sound
import messages
from twitter import compose, prettydate, utils
from wxUI import buffers, dialogs
from wxUI import buffers, dialogs, commonMessageDialogs
from mysc.thread_utils import call_threaded
class bufferController(object):
@ -88,6 +88,9 @@ class bufferController(object):
def direct_message(self):
pass
def retweet(self):
pass
class accountPanel(bufferController):
def __init__(self, parent, name, account):
super(accountPanel, self).__init__(parent, None, name)
@ -200,6 +203,20 @@ class baseBufferController(bufferController):
if dm.message.get_response() == widgetUtils.OK:
call_threaded(self.session.api_call, call_name="send_direct_message", _sound="dm_sent.ogg", text=dm.message.get_text(), screen_name=dm.message.get("cb"))
def retweet(self):
tweet = self.get_right_tweet()
id = tweet["id"]
answer = commonMessageDialogs.retweet_question(self.buffer)
if answer == widgetUtils.YES:
retweet = messages.tweet(self.session, _(u"Retweet"), _(u"Add your comment to the tweet"), u"“@%s: %s" % (tweet["user"]["screen_name"], tweet["text"]))
if retweet.message.get_response() == widgetUtils.OK:
if retweet.image == None:
call_threaded(self.session.api_call, call_name="update_status", _sound="retweet_send.ogg", status=retweet.message.get_text(), in_reply_to_status_id=id)
else:
call_threaded(self.session.api_call, call_name="update_status", _sound="retweet_send.ogg", status=retweet.message.get_text(), in_reply_to_status_id=id, media=retweet.image)
elif answer == widgetUtils.NO:
call_threaded(self.session.api_call, call_name="retweet", _sound="retweet_send.ogg", id=id)
def onFocus(self, ev):
tweet = self.get_tweet()
if self.session.settings["general"]["relative_times"] == True:

View File

@ -63,6 +63,9 @@ class Controller(object):
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.exit, menuitem=self.view.close)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_tweet, self.view.compose)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_reply, self.view.reply)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_retweet, self.view.retweet)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_to_favourites, self.view.fav)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_from_favourites, self.view.unfav)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.send_dm, self.view.dm)
def __init__(self):
@ -243,17 +246,28 @@ class Controller(object):
else:
buffer.direct_message()
def post_retweet(self):
pass
def post_retweet(self, *args, **kwargs):
buffer = self.get_best_buffer()
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
return
else:
buffer.retweet()
def viewTweet(self):
pass
def add_to_favourites(self, *args, **kwargs):
buffer = self.get_best_buffer()
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
return
else:
id = buffer.get_tweet()["id"]
call_threaded(buffer.session.api_call, call_name="create_favorite", _sound="favourite.ogg", id=id)
def add_to_favourites(self):
pass
def remove_from_favourites(self):
pass
def remove_from_favourites(self, *args, **kwargs):
buffer = self.get_best_buffer()
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
return
else:
id = buffer.get_tweet()["id"]
call_threaded(buffer.session.api_call, call_name="destroy_favorite", id=id)
def open_timeline(self, user, timeline_tipe):
pass

View File

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
import wx
def retweet_question(parent):
return wx.MessageDialog(parent, _(u"Would you like to add a comment to this tweet?"), _("Retweet"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION).ShowModal()