Today's Tweets

Display the tweets you've posted today.

Image preview of Today's Tweets plugin.

todays_tweets.30m.py

Edit
Open on GitHub
#!/usr/bin/env PYTHONIOENCODING=UTF-8 /usr/local/bin/python3

# <xbar.title>Today's Tweets</xbar.title>
# <xbar.version>v1.2.1</xbar.version>
# <xbar.author>Luke C.D. Stein</xbar.author>
# <xbar.author.github>lukestein</xbar.author.github>
# <xbar.desc>Display the tweets you've posted today.</xbar.desc>
# <xbar.image>https://raw.githubusercontent.com/lukestein/bitbar_todays_tweets/master/todays_tweets.png</xbar.image>
# <xbar.dependencies>python3,tweepy</xbar.dependencies>
# <xbar.abouturl>https://github.com/lukestein/bitbar_todays_tweets</xbar.abouturl>

# See advice at
# https://github.com/matryer/xbar#writing-plugins
# http://docs.tweepy.org/en/v3.8.0/api.html
# https://www.iconfinder.com/
# https://onlinepngtools.com/convert-png-to-base64

import tweepy
import datetime
import time


# %% Twitter API keys
consumer_key        = "KEY"
consumer_secret     = "SECRET"
access_token        = "TOKEN"
access_token_secret = "TOKENSECRET"


# %% Parameters
showmentions = True
maxmentions  = 50


# %% Setup

def is_reply(t):
    return (t.in_reply_to_screen_name != None) and (t.in_reply_to_screen_name != screen_name)

twitterlogo = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8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UxSfuMaZ0Qzt+IsVLH1V9SGkFFqhjdnlWHscSCH4sgJtvU1Hy9epLjjSEID5sD7pPcI2KvAzFeFD8XPc6/jd7Ng1jIGNSVjYC+SbxP2/JIgnvMz5K/FblZvlWdkrlx3WKXCOIYYrFt9wQq4MmZZED0aifafqGx/Ad7XxD3mqD9IpW5ItYl9pds34lbxcWiEWNZ19K6Ai3Kig5biC/vk8EDt1B8QpyZlbzSF0S289eso+G8kLyPAbr7AraRVbazEHzwHe/wy9yK29ifdQTt0q0RAAAAAElFTkSuQmCC"

# %% Authenticate to Twitter:
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)


# %% Create API object
api = tweepy.API(auth)

while True:
    try:
        screen_name = api.me().screen_name
        pass
        break
    except:
        time.sleep(20)


#print("User @%s successfully authorized the app." % screen_name)


# %% Get timeline
tweets = []

for i in tweepy.Cursor(api.user_timeline).items():
    if ((i.created_at.replace(tzinfo=datetime.timezone.utc).astimezone(tz=None).month == datetime.datetime.now().month) and
        (i.created_at.replace(tzinfo=datetime.timezone.utc).astimezone(tz=None).day   == datetime.datetime.now().day)):
        tweets.append(i)
    else:
        break

tweetcount   = sum(1 for t in tweets if not t.retweeted and not is_reply(t))
retweetcount = sum(1 for t in tweets if     t.retweeted)
replycount   = sum(1 for t in tweets if not t.retweeted and     is_reply(t))


# %% Get mentions
if showmentions:
    mentions = []
    mentioncount = 0

    for i in tweepy.Cursor(api.mentions_timeline).items():
        if ((i.created_at.replace(tzinfo=datetime.timezone.utc).astimezone(tz=None).month == datetime.datetime.now().month) and
            (i.created_at.replace(tzinfo=datetime.timezone.utc).astimezone(tz=None).day   == datetime.datetime.now().day)   and
            mentioncount < maxmentions):

            mentioncount += 1
            mentions.append(i)
        else:
            break



### %% Get quote-tweets
#qtquery = "twitter.com%%2F%s%%2Fstatus%%20-(from%%3A%s)" % (screen_name, screen_name)
#print(qtquery)
#qts = api.search(qtquery, results_type="recent")
#for t in qts:
#    print(t.text)


# %% Format menu items, including colors if above daily tweet quota
prefix = ""
total_color   = "color=red" if (tweetcount + retweetcount >= 10) else ""
tweet_color   = "color=red" if (tweetcount >= 10)                else ""
retweet_color = "color=red" if (retweetcount >= 5)               else ""
reply_color   = "color=red" if (replycount >= 10)                else ""

# %% Print counts
print(prefix + "%d+%d+%d (💕%d) | templateImage=%s %s" % (tweetcount, retweetcount, replycount, sum(t.favorite_count for t in tweets), twitterlogo, total_color))

# %% Print tweets
print("---")

print(prefix + "%d Tweets (💕%d) | href=https://twitter.com/%s image=%s %s" % (tweetcount, sum(t.favorite_count for t in tweets if not t.retweeted and not is_reply(t)), screen_name, tweetlogo, tweet_color))
for t in tweets:
    if not t.retweeted and not is_reply(t):
        print("--%d💕 %s | size=12 length=60 href=https://twitter.com/%s/status/%d" % (t.favorite_count, t.text.replace('\n', ' ').replace('\r', ''), t.user.screen_name, t.id))

print(prefix + "%d Retweets | href=https://twitter.com/%s image=%s %s" % (retweetcount, screen_name, retweetlogo, retweet_color))
for t in tweets:
    if t.retweeted:
        print("--%s | size=12 length=60 href=https://twitter.com/%s/status/%d" % (t.text[3:].replace('\n', ' ').replace('\r', ''), t.user.screen_name, t.id))

print(prefix + "%d Replies (💕%d) | href=https://twitter.com/%s/with_replies image=%s %s"  % (replycount, sum(t.favorite_count for t in tweets if not t.retweeted and is_reply(t)), screen_name, replylogo, reply_color))
for t in tweets:
    if not t.retweeted and is_reply(t):
        print("--%d💕 %s | size=12 length=60 href=https://twitter.com/%s/status/%d" % (t.favorite_count, t.text.replace('\n', ' ').replace('\r', ''), t.user.screen_name, t.id))

mentionprefix = "≥" if (mentioncount == maxmentions) else ""

if showmentions:
    print("---")
    print(prefix + mentionprefix + "%d Mentions | href=https://twitter.com/notifications/mentions image=%s" % (mentioncount, mentionlogo))
    for t in mentions:
        print("--%d💕 %s: %s | size=12 length=60 href=https://twitter.com/%s/status/%d" % (t.favorite_count, t.user.screen_name, t.text.replace('\n', ' ').replace('\r', ''), t.user.screen_name, t.id))


print("---")
print("Analytics | href=https://analytics.twitter.com/user/%s/tweets" % screen_name)
print("%d Followers| href=https://twitter.com/%s/followers" % (api.me().followers_count, screen_name))
print("%d Following | href=https://twitter.com/%s/following" % (api.me().friends_count, screen_name))