Skip to content

Commit

Permalink
moved tweet string formatting to new function to consolidate duplicat…
Browse files Browse the repository at this point in the history
…ed code
  • Loading branch information
katycat5e committed Nov 7, 2017
1 parent bd8569a commit c385195
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions plugins/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,7 @@ def twitter_url(match):
except tweepy.error.TweepError:
return

# Format the return the text of the tweet
text = " ".join(tweet.text.split())

if user.verified:
prefix = "\u2713"
else:
prefix = ""

time = timeformat.time_since(tweet.created_at, datetime.utcnow())

return "{}@\x02{}\x02 ({}): {} ({} ago)".format(prefix, user.screen_name, user.name, html.unescape(text), time)
return format_tweet(tweet, user)


@hook.command("twitter", "tw", "twatter")
Expand Down Expand Up @@ -130,7 +120,11 @@ def twitter(text):
# ???
return "Invalid Input"

# Format the return the text of the tweet
return format_tweet(tweet, user)


# Format the return the text of the tweet
def format_tweet(tweet, user):
text = " ".join(tweet.text.split())

if user.verified:
Expand Down

0 comments on commit c385195

Please sign in to comment.