mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Implemented code to quote Tweets by using the new GUI
This commit is contained in:
parent
cfc25eb89a
commit
269db95fe3
@ -458,40 +458,21 @@ class BaseBuffer(base.Buffer):
|
|||||||
else:
|
else:
|
||||||
self._retweet_with_comment(tweet, id)
|
self._retweet_with_comment(tweet, id)
|
||||||
|
|
||||||
def _retweet_with_comment(self, tweet, id, comment=''):
|
def _retweet_with_comment(self, tweet, id):
|
||||||
# If quoting a retweet, let's quote the original tweet instead the retweet.
|
|
||||||
if hasattr(tweet, "retweeted_status"):
|
if hasattr(tweet, "retweeted_status"):
|
||||||
tweet = tweet.retweeted_status
|
tweet = tweet.retweeted_status
|
||||||
if hasattr(tweet, "full_text"):
|
retweet = messages.tweet(session=self.session, title=_("Quote"), caption=_("Add your comment to the tweet"), max=256, thread_mode=False)
|
||||||
comments = tweet.full_text
|
retweet = messages.tweet(session=self.session, title=_("Quote"), caption=_("Add your comment to the tweet"), max=256, thread_mode=False)
|
||||||
else:
|
if retweet.message.ShowModal() == widgetUtils.OK:
|
||||||
comments = tweet.text
|
text = retweet.message.text.GetValue()
|
||||||
retweet = messages.tweet(self.session, _(u"Quote"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (self.session.get_user(tweet.user).screen_name, comments), max=256, messageType="retweet")
|
|
||||||
if comment != '':
|
|
||||||
retweet.message.set_text(comment)
|
|
||||||
if retweet.message.get_response() == widgetUtils.OK:
|
|
||||||
text = retweet.message.get_text()
|
|
||||||
text = text+" https://twitter.com/{0}/status/{1}".format(self.session.get_user(tweet.user).screen_name, id)
|
text = text+" https://twitter.com/{0}/status/{1}".format(self.session.get_user(tweet.user).screen_name, id)
|
||||||
if retweet.image == None:
|
tweet_data = dict(text=text, attachments=retweet.attachments)
|
||||||
# We will no longer will reuse the sent item from here as Streaming API should give us the new and correct item.
|
call_threaded(self.session.send_tweet, *[tweet_data])
|
||||||
# but in case we'd need it, just uncomment the following couple of lines and make sure we reduce the item correctly.
|
if hasattr(retweet.message, "destroy"):
|
||||||
item = self.session.api_call(call_name="update_status", _sound="retweet_send.ogg", status=text, in_reply_to_status_id=id, tweet_mode="extended")
|
retweet.message.destroy()
|
||||||
# if item != None:
|
|
||||||
# new_item = self.session.twitter.get_status(id=item.id, include_ext_alt_text=True, tweet_mode="extended")
|
|
||||||
# pub.sendMessage("sent-tweet", data=new_item, user=self.session.db["user_name"])
|
|
||||||
else:
|
|
||||||
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()
|
|
||||||
|
|
||||||
def _direct_retweet(self, id):
|
def _direct_retweet(self, id):
|
||||||
item = self.session.api_call(call_name="retweet", _sound="retweet_send.ogg", id=id)
|
item = self.session.api_call(call_name="retweet", _sound="retweet_send.ogg", id=id)
|
||||||
# We will no longer will reuse the sent item from here as Streaming API should give us the new and correct item.
|
|
||||||
# but in case we'd need it, just uncomment the following couple of lines and make sure we reduce the item correctly.
|
|
||||||
# if item != None:
|
|
||||||
# Retweets are returned as non-extended tweets, so let's get the object as extended
|
|
||||||
# just before sending the event message. See https://github.com/manuelcortez/TWBlue/issues/253
|
|
||||||
# item = self.session.twitter.get_status(id=item.id, include_ext_alt_text=True, tweet_mode="extended")
|
|
||||||
# pub.sendMessage("sent-tweet", data=item, user=self.session.db["user_name"])
|
|
||||||
|
|
||||||
def onFocus(self, *args, **kwargs):
|
def onFocus(self, *args, **kwargs):
|
||||||
tweet = self.get_tweet()
|
tweet = self.get_tweet()
|
||||||
|
@ -122,10 +122,9 @@ class basicTweet(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class tweet(basicTweet):
|
class tweet(basicTweet):
|
||||||
def __init__(self, session, title, caption, text, max=280, messageType="tweet", *args, **kwargs):
|
def __init__(self, session, title, caption, text="", max=280, messageType="tweet", *args, **kwargs):
|
||||||
self.thread = []
|
self.thread = []
|
||||||
super(tweet, self).__init__(session, title, caption, text, messageType, max, *args, **kwargs)
|
super(tweet, self).__init__(session, title, caption, text, messageType, max, *args, **kwargs)
|
||||||
self.image = None
|
|
||||||
widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users)
|
widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users)
|
||||||
if hasattr(self.message, "add_tweet"):
|
if hasattr(self.message, "add_tweet"):
|
||||||
widgetUtils.connect_event(self.message.add_tweet, widgetUtils.BUTTON_PRESSED, self.add_tweet)
|
widgetUtils.connect_event(self.message.add_tweet, widgetUtils.BUTTON_PRESSED, self.add_tweet)
|
||||||
|
Loading…
Reference in New Issue
Block a user