Fixed reply to single user in tweets with multiple users

This commit is contained in:
Manuel Cortez 2016-10-04 03:37:12 -05:00
parent 378d277a98
commit 6f5ef6d3f1
3 changed files with 7 additions and 5 deletions

View File

@ -479,11 +479,13 @@ class baseBufferController(bufferController):
tweet = self.get_right_tweet()
screen_name = tweet["user"]["screen_name"]
id = tweet["id"]
users = len(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,), "", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"], users=users)
if message.message.get_response() == widgetUtils.OK:
self.session.settings["mysc"]["twishort_enabled"] = message.message.long_tweet.GetValue()
text = message.message.get_text()
if message.message.mentionAll.GetValue() == False:
text = u"@{0} {1}".format(screen_name, 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)

View File

@ -148,7 +148,7 @@ class reply(tweet):
def __init__(self, session, title, caption, text, twishort_enabled, users=None):
super(reply, self).__init__(session, title, caption, text, twishort_enabled, messageType="reply")
self.message.mentionAll.SetValue(True)
if users > 1:
if len(users) > 1:
# widgetUtils.connect_event(self.message.mentionAll, widgetUtils.CHECKBOX, self.mention_all)
self.message.enable_button("mentionAll")
self.message.mentionAll.SetValue(False)

View File

@ -69,10 +69,10 @@ def is_geocoded(tweet):
def get_all_mentioned(tweet, conf):
""" Gets all users that has been mentioned."""
string = []
for i in tweet["entities"]["user_mentions"]:
for i in tweet["entities"]["user_mentions"][1:]:
if i["screen_name"] != conf["user_name"] and i["screen_name"] != tweet["user"]["screen_name"]:
if "@"+i["screen_name"] not in string:
string.append("@"+i["screen_name"])
if i["id"] not in string:
string.append(i["id_str"])
return " ".join(string)+" "
def get_all_users(tweet, conf):