mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Retweets, add and remove from favourites are supported
This commit is contained in:
parent
5cb4e0fef7
commit
a599b37e6d
@ -8,7 +8,7 @@ import config
|
|||||||
import sound
|
import sound
|
||||||
import messages
|
import messages
|
||||||
from twitter import compose, prettydate, utils
|
from twitter import compose, prettydate, utils
|
||||||
from wxUI import buffers, dialogs
|
from wxUI import buffers, dialogs, commonMessageDialogs
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
|
|
||||||
class bufferController(object):
|
class bufferController(object):
|
||||||
@ -88,6 +88,9 @@ class bufferController(object):
|
|||||||
def direct_message(self):
|
def direct_message(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def retweet(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class accountPanel(bufferController):
|
class accountPanel(bufferController):
|
||||||
def __init__(self, parent, name, account):
|
def __init__(self, parent, name, account):
|
||||||
super(accountPanel, self).__init__(parent, None, name)
|
super(accountPanel, self).__init__(parent, None, name)
|
||||||
@ -200,6 +203,20 @@ class baseBufferController(bufferController):
|
|||||||
if dm.message.get_response() == widgetUtils.OK:
|
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"))
|
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):
|
def onFocus(self, ev):
|
||||||
tweet = self.get_tweet()
|
tweet = self.get_tweet()
|
||||||
if self.session.settings["general"]["relative_times"] == True:
|
if self.session.settings["general"]["relative_times"] == True:
|
||||||
|
@ -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.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_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_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)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.send_dm, self.view.dm)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -243,17 +246,28 @@ class Controller(object):
|
|||||||
else:
|
else:
|
||||||
buffer.direct_message()
|
buffer.direct_message()
|
||||||
|
|
||||||
def post_retweet(self):
|
def post_retweet(self, *args, **kwargs):
|
||||||
pass
|
buffer = self.get_best_buffer()
|
||||||
|
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
buffer.retweet()
|
||||||
|
|
||||||
def viewTweet(self):
|
def add_to_favourites(self, *args, **kwargs):
|
||||||
pass
|
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):
|
def remove_from_favourites(self, *args, **kwargs):
|
||||||
pass
|
buffer = self.get_best_buffer()
|
||||||
|
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
||||||
def remove_from_favourites(self):
|
return
|
||||||
pass
|
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):
|
def open_timeline(self, user, timeline_tipe):
|
||||||
pass
|
pass
|
||||||
|
5
src/wxUI/commonMessageDialogs.py
Normal file
5
src/wxUI/commonMessageDialogs.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user