mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-19 00:40:42 -06:00
Removed old compose_dm and compose_event
This commit is contained in:
parent
bfad5b82f0
commit
b44e30ed28
@ -75,35 +75,6 @@ def compose_tweet(tweet, db, relative_times, show_screen_names=False, session=No
|
|||||||
if config.app['app-settings']['handle_longtweets']: pass
|
if config.app['app-settings']['handle_longtweets']: pass
|
||||||
return [user+", ", text, ts+", ", source]
|
return [user+", ", text, ts+", ", source]
|
||||||
|
|
||||||
def compose_dm(tweet, db, relative_times, show_screen_names=False, session=None):
|
|
||||||
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
|
||||||
if system == "Windows":
|
|
||||||
original_date = arrow.get(tweet["created_at"], "ddd MMM DD H:m:s Z YYYY", locale="en")
|
|
||||||
if relative_times == True:
|
|
||||||
ts = original_date.humanize(locale=languageHandler.getLanguage())
|
|
||||||
else:
|
|
||||||
ts = original_date.replace(seconds=db["utc_offset"]).format(_(u"dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.getLanguage())
|
|
||||||
else:
|
|
||||||
ts = tweet["created_at"]
|
|
||||||
text = StripChars(tweet["text"])
|
|
||||||
source = "DM"
|
|
||||||
if db["user_name"] == tweet["sender"]["screen_name"]:
|
|
||||||
if show_screen_names:
|
|
||||||
user = _(u"Dm to %s ") % (tweet["recipient"]["screen_name"],)
|
|
||||||
else:
|
|
||||||
user = _(u"Dm to %s ") % (tweet["recipient"]["name"],)
|
|
||||||
else:
|
|
||||||
if show_screen_names:
|
|
||||||
user = tweet["sender"]["screen_name"]
|
|
||||||
else:
|
|
||||||
user = tweet["sender"]["name"]
|
|
||||||
if text[-1] in chars: text=text+"."
|
|
||||||
urls = utils.find_urls_in_text(text)
|
|
||||||
for url in range(0, len(urls)):
|
|
||||||
try: text = text.replace(urls[url], tweet["entities"]["urls"][url]["expanded_url"])
|
|
||||||
except IndexError: pass
|
|
||||||
return [user+", ", text, ts+", ", source]
|
|
||||||
|
|
||||||
def compose_direct_message(item, db, relative_times, show_screen_names=False, session=None):
|
def compose_direct_message(item, db, relative_times, show_screen_names=False, session=None):
|
||||||
# for a while this function will be together with compose_dm.
|
# for a while this function will be together with compose_dm.
|
||||||
# this one composes direct messages based on events (new API Endpoints).
|
# this one composes direct messages based on events (new API Endpoints).
|
||||||
@ -193,58 +164,6 @@ def compose_followers_list(tweet, db, relative_times=True, show_screen_names=Fal
|
|||||||
ts2 = _("Unavailable")
|
ts2 = _("Unavailable")
|
||||||
return [_(u"%s (@%s). %s followers, %s friends, %s tweets. Last tweeted %s. Joined Twitter %s") % (tweet["name"], tweet["screen_name"], tweet["followers_count"], tweet["friends_count"], tweet["statuses_count"], ts2, ts)]
|
return [_(u"%s (@%s). %s followers, %s friends, %s tweets. Last tweeted %s. Joined Twitter %s") % (tweet["name"], tweet["screen_name"], tweet["followers_count"], tweet["friends_count"], tweet["statuses_count"], ts2, ts)]
|
||||||
|
|
||||||
def compose_event(data, username, show_screen_names=False, session=None):
|
|
||||||
if show_screen_names:
|
|
||||||
value = "screen_name"
|
|
||||||
else:
|
|
||||||
value = "name"
|
|
||||||
if data["event"] == "block":
|
|
||||||
event = _("You've blocked %s") % (data["target"][value])
|
|
||||||
elif data["event"] == "unblock":
|
|
||||||
event = _(u"You've unblocked %s") % (data["target"][value])
|
|
||||||
elif data["event"] == "follow":
|
|
||||||
if data["target"]["screen_name"] == username:
|
|
||||||
event = _(u"%s(@%s) has followed you") % (data["source"]["name"], data["source"]["screen_name"])
|
|
||||||
elif data["source"]["screen_name"] == username:
|
|
||||||
event = _(u"You've followed %s(@%s)") % (data["target"]["name"], data["target"]["screen_name"])
|
|
||||||
elif data["event"] == "unfollow":
|
|
||||||
event = _(u"You've unfollowed %s (@%s)") % (data["target"]["name"], data["target"]["screen_name"])
|
|
||||||
elif data["event"] == "favorite":
|
|
||||||
if data["source"]["screen_name"] == username:
|
|
||||||
event = _(u"You've liked: %s, %s") % (data["target"][value], data["target_object"]["text"])
|
|
||||||
else:
|
|
||||||
event = _(u"%s(@%s) has liked: %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["text"])
|
|
||||||
elif data["event"] == "unfavorite":
|
|
||||||
if data["source"]["screen_name"] == username: event = _(u"You've unliked: %s, %s") % (data["target"][value], data["target_object"]["text"])
|
|
||||||
else: event = _(u"%s(@%s) has unliked: %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["text"])
|
|
||||||
elif data["event"] == "list_created":
|
|
||||||
event = _(u"You've created the list %s") % (data["target_object"]["name"])
|
|
||||||
elif data["event"] == "list_destroyed":
|
|
||||||
event = _("You've deleted the list %s") % (data["target_object"]["name"])
|
|
||||||
elif data["event"] == "list_updated":
|
|
||||||
event = _("You've updated the list %s") % (data["target_object"]["name"])
|
|
||||||
elif data["event"] == "list_member_added":
|
|
||||||
if data["source"]["screen_name"] == username: event = _(u"You've added %s(@%s) to the list %s") % (data["target"]["name"], data["target"]["screen_name"], data["target_object"]["name"])
|
|
||||||
else: event = _(u"%s(@%s) has added you to the list %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["name"])
|
|
||||||
elif data["event"] == "list_member_removed":
|
|
||||||
if data["source"]["screen_name"] == username: event = _(u"You'be removed %s(@%s) from the list %s") % (data["target"]["name"], data["target"]["screen_name"], data["target_object"]["name"])
|
|
||||||
else: event = _(u"%s(@%s) has removed you from the list %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["name"])
|
|
||||||
elif data["event"] == "list_user_subscribed":
|
|
||||||
if data["source"]["screen_name"] == username: event = _(u"You've subscribed to the list %s, which is owned by %s(@%s)") % (data["target_object"]["name"], data["target"]["name"], data["target"]["screen_name"])
|
|
||||||
else: event = _(u"%s(@%s) has subscribed you to the list %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["name"])
|
|
||||||
elif data["event"] == "list_user_unsubscribed":
|
|
||||||
if data["source"]["screen_name"] == username: event = _(u"You've unsubscribed from the list %s, which is owned by %s(@%s)") % (data["target_object"]["name"], data["target"]["name"], data["target"]["screen_name"])
|
|
||||||
else: event = _("You've been unsubscribed from the list %s, which is owned by %s(@%s)") % (data["target_object"]["name"], data["source"]["name"], data["source"]["screen_name"])
|
|
||||||
elif data["event"] == "retweeted_retweet":
|
|
||||||
if data["source"]["screen_name"] == username: event = _(u"You have retweeted a retweet from %s(@%s): %s") % (data["target"]["name"], data["target"]["screen_name"], data["target_object"]["retweeted_status"]["text"])
|
|
||||||
else: event = _(u"%s(@%s) has retweeted your retweet: %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["retweeted_status"]["text"])
|
|
||||||
elif data["event"] == "quoted_tweet":
|
|
||||||
event = _(u"@{0} quoted your tweet: {1}").format(data["source"]["screen_name"], data["target_object"]["text"])
|
|
||||||
else:
|
|
||||||
event = _("Unknown")
|
|
||||||
log.error("event: %s\n target: %s\n source: %s\n target_object: %s" % (data["event"], data["target"], data["source"], data["target_object"]))
|
|
||||||
return [time.strftime("%I:%M %p"), event]
|
|
||||||
|
|
||||||
def compose_list(list):
|
def compose_list(list):
|
||||||
name = list["name"]
|
name = list["name"]
|
||||||
if list["description"] == None: description = _(u"No description available")
|
if list["description"] == None: description = _(u"No description available")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user