Twishort shouldn't be added in some replies. Fix #90

This commit is contained in:
Manuel Cortez 2016-12-19 11:43:32 -06:00
parent fe7a69f490
commit 53388696b6
3 changed files with 26 additions and 10 deletions

View File

@ -479,23 +479,35 @@ class baseBufferController(bufferController):
tweet = self.get_right_tweet() tweet = self.get_right_tweet()
screen_name = tweet["user"]["screen_name"] screen_name = tweet["user"]["screen_name"]
id = tweet["id"] id = tweet["id"]
twishort = tweet.has_key("twishort")
users = utils.get_all_mentioned(tweet, self.session.db, field="screen_name") users = utils.get_all_mentioned(tweet, self.session.db, field="screen_name")
ids = utils.get_all_mentioned(tweet, self.session.db, field="id_str") ids = utils.get_all_mentioned(tweet, self.session.db, field="id_str")
message = messages.reply(self.session, _(u"Reply"), _(u"Reply to %s") % (screen_name,), "", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"], users=users, ids=ids) message = messages.reply(self.session, _(u"Reply"), _(u"Reply to %s") % (screen_name,), "", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"], users=users, ids=ids)
if message.message.get_response() == widgetUtils.OK: if message.message.get_response() == widgetUtils.OK:
params = {"_sound": "reply_send.ogg", "in_reply_to_status_id": id,}
self.session.settings["mysc"]["twishort_enabled"] = message.message.long_tweet.GetValue() self.session.settings["mysc"]["twishort_enabled"] = message.message.long_tweet.GetValue()
self.session.settings["mysc"]["mention_all"] = message.message.mentionAll.GetValue() self.session.settings["mysc"]["mention_all"] = message.message.mentionAll.GetValue()
excluded_ids = message.get_ids()
text = message.message.get_text() text = message.message.get_text()
if twishort == False:
excluded_ids = message.get_ids()
params["exclude_reply_user_ids"] =excluded_ids
params["auto_populate_reply_metadata"] =True
else:
mentioned_people = message.get_people()
text = "@"+screen_name+" "+mentioned_people+u" "+text
if len(text) > 140 and message.message.get("long_tweet") == True: if len(text) > 140 and message.message.get("long_tweet") == True:
if message.image == None: if message.image == None:
text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text) text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text)
else: else:
text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text, 1) text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text, 1)
params["status"] = text
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=text, auto_populate_reply_metadata=True, exclude_reply_user_ids=excluded_ids) params["call_name"] = "update_status"
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=text, media=message.file, auto_populate_reply_metadata=True, exclude_reply_user_ids=excluded_ids) params["call_name"] = "update_status_with_media"
params["media"] = message.file
call_threaded(self.session.api_call, **params)
#call_name="update_status_with_media", _sound="reply_send.ogg", in_reply_to_status_id=id, status=text, media=message.file, exclude_reply_user_ids=excluded_ids)
if hasattr(message.message, "destroy"): message.message.destroy() if hasattr(message.message, "destroy"): message.message.destroy()
@_tweets_exist @_tweets_exist

View File

@ -175,6 +175,13 @@ class reply(tweet):
excluded_ids = excluded_ids + "{0},".format(self.ids[i],) excluded_ids = excluded_ids + "{0},".format(self.ids[i],)
return excluded_ids return excluded_ids
def get_people(self):
people = ""
for i in xrange(0, len(self.message.checkboxes)):
if self.message.checkboxes[i].GetValue() == True:
people = people + "{0} ".format(self.message.checkboxes[i].GetLabel(),)
return people
class dm(basicTweet): class dm(basicTweet):
def __init__(self, session, title, caption, text): def __init__(self, session, title, caption, text):
super(dm, self).__init__(session, title, caption, text, messageType="dm", max=10000) super(dm, self).__init__(session, title, caption, text, messageType="dm", max=10000)

View File

@ -190,9 +190,9 @@ class Session(object):
elif report_failure and hasattr(e, 'message'): elif report_failure and hasattr(e, 'message'):
output.speak(_("%s failed. Reason: %s") % (action, e.message)) output.speak(_("%s failed. Reason: %s") % (action, e.message))
finished = True finished = True
except: # except:
tries = tries + 1 # tries = tries + 1
time.sleep(5) # time.sleep(5)
if report_success: if report_success:
output.speak(_("%s succeeded.") % action) output.speak(_("%s succeeded.") % action)
if _sound != None: self.sound.play(_sound) if _sound != None: self.sound.play(_sound)
@ -454,8 +454,5 @@ class Session(object):
long = twishort.is_long(tweet) long = twishort.is_long(tweet)
if long != False and config.app["app-settings"]["handle_longtweets"]: if long != False and config.app["app-settings"]["handle_longtweets"]:
tweet["message"] = twishort.get_full_text(long) tweet["message"] = twishort.get_full_text(long)
mentions = "" tweet["twishort"] = True
for i in tweet["entities"]["user_mentions"]:
mentions = mentions+"@{0} ".format(i["screen_name"],)
tweet["message"] = mentions+tweet["message"]
return tweet return tweet