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()
screen_name = tweet["user"]["screen_name"]
id = tweet["id"]
twishort = tweet.has_key("twishort")
users = utils.get_all_mentioned(tweet, self.session.db, field="screen_name")
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)
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"]["mention_all"] = message.message.mentionAll.GetValue()
excluded_ids = message.get_ids()
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 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)
params["status"] = text
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:
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()
@_tweets_exist

View File

@ -175,6 +175,13 @@ class reply(tweet):
excluded_ids = excluded_ids + "{0},".format(self.ids[i],)
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):
def __init__(self, session, title, caption, text):
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'):
output.speak(_("%s failed. Reason: %s") % (action, e.message))
finished = True
except:
tries = tries + 1
time.sleep(5)
# except:
# tries = tries + 1
# time.sleep(5)
if report_success:
output.speak(_("%s succeeded.") % action)
if _sound != None: self.sound.play(_sound)
@ -454,8 +454,5 @@ class Session(object):
long = twishort.is_long(tweet)
if long != False and config.app["app-settings"]["handle_longtweets"]:
tweet["message"] = twishort.get_full_text(long)
mentions = ""
for i in tweet["entities"]["user_mentions"]:
mentions = mentions+"@{0} ".format(i["screen_name"],)
tweet["message"] = mentions+tweet["message"]
tweet["twishort"] = True
return tweet