Added full Twishort support

This commit is contained in:
Manuel Cortez 2015-07-13 04:45:06 -05:00
parent 64fce8fb54
commit 74bcc36968
3 changed files with 24 additions and 3 deletions

View File

@ -130,6 +130,11 @@ class bufferController(object):
tweet = messages.tweet(self.session, title, caption, "") tweet = messages.tweet(self.session, title, caption, "")
if tweet.message.get_response() == widgetUtils.OK: if tweet.message.get_response() == widgetUtils.OK:
text = tweet.message.get_text() text = tweet.message.get_text()
if len(text) > 140 and tweet.message.get("long_tweet") == True:
if tweet.image == None:
text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text)
else:
text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text, 1)
if tweet.image == None: if tweet.image == None:
call_threaded(self.session.api_call, call_name="update_status", status=text) call_threaded(self.session.api_call, call_name="update_status", status=text)
else: else:
@ -371,10 +376,16 @@ class baseBufferController(bufferController):
users = utils.get_all_mentioned(tweet, self.session.db) users = utils.get_all_mentioned(tweet, self.session.db)
message = messages.reply(self.session, _(u"Reply"), _(u"Reply to %s") % (screen_name,), "@%s " % (screen_name,), users) message = messages.reply(self.session, _(u"Reply"), _(u"Reply to %s") % (screen_name,), "@%s " % (screen_name,), users)
if message.message.get_response() == widgetUtils.OK: if message.message.get_response() == widgetUtils.OK:
text = message.message.get_text()
if len(text) > 140 and message.message.get("long_tweet") == True:
if message.image == None:
text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text)
else:
text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text, 1)
if message.image == None: if message.image == None:
call_threaded(self.session.api_call, call_name="update_status", _sound="reply_send.ogg", in_reply_to_status_id=id, status=message.message.get_text()) call_threaded(self.session.api_call, call_name="update_status", _sound="reply_send.ogg", in_reply_to_status_id=id, status=text)
else: else:
call_threaded(self.session.api_call, call_name="update_status_with_media", _sound="reply_send.ogg", in_reply_to_status_id=id, status=message.message.get_text(), media=message.file) call_threaded(self.session.api_call, call_name="update_status_with_media", _sound="reply_send.ogg", in_reply_to_status_id=id, status=text, media=message.file)
if hasattr(message.message, "destroy"): message.message.destroy() if hasattr(message.message, "destroy"): message.message.destroy()
@_tweets_exist @_tweets_exist

View File

@ -36,3 +36,11 @@ def get_full_text(uri):
return r.json()["text"] return r.json()["text"]
# except: # except:
# return False # return False
def create_tweet(user_token, user_secret, text, media=0):
data = {"user_token": user_token,
"user_secret": user_secret,
"text": text.encode("utf-8"),
"media": media}
response = requests.post("http://twblue.es/twishort.php", data=data)
return response.json()["text_to_tweet"]

View File

@ -73,6 +73,8 @@ class tweet(textLimited):
self.mainBox = wx.BoxSizer(wx.VERTICAL) self.mainBox = wx.BoxSizer(wx.VERTICAL)
self.createTextArea(message, text) self.createTextArea(message, text)
self.mainBox.Add(self.textBox, 0, wx.ALL, 5) self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
self.long_tweet = wx.CheckBox(self.panel, -1, _(u"Long tweet"))
self.long_tweet.SetValue(True)
self.upload_image = wx.Button(self.panel, -1, _(u"Upload image..."), size=wx.DefaultSize) self.upload_image = wx.Button(self.panel, -1, _(u"Upload image..."), size=wx.DefaultSize)
self.spellcheck = wx.Button(self.panel, -1, _("Check spelling..."), size=wx.DefaultSize) self.spellcheck = wx.Button(self.panel, -1, _("Check spelling..."), size=wx.DefaultSize)
self.attach = wx.Button(self.panel, -1, _(u"Attach audio..."), size=wx.DefaultSize) self.attach = wx.Button(self.panel, -1, _(u"Attach audio..."), size=wx.DefaultSize)