def get_last_tweet(self, username): if self.twitter_client: try: public_tweets = self.twitter_client.user_timeline(username) for tweet in public_tweets: if not tweet.text.startswith('RT ') and tweet.in_reply_to_screen_name is None: tw = tweet_prettify_urls(tweet) return '{0} ({1} ago)'.format(tw.replace("\n", " "), time_since(datetime.now().timestamp(), tweet.created_at.timestamp(), format='short')) except Exception: log.exception('Exception caught while getting last tweet') return 'FeelsBadMan' else: return 'Twitter not set up FeelsBadMan' return 'FeelsBadMan'
def get_last_tweet(self, username): if self.twitter_client: try: public_tweets = self.twitter_client.user_timeline(username) for tweet in public_tweets: if not tweet.text.startswith( 'RT ') and tweet.in_reply_to_screen_name is None: tw = tweet_prettify_urls(tweet) return '{0} ({1} ago)'.format( tw.replace("\n", " "), time_since(datetime.now().timestamp(), tweet.created_at.timestamp(), format='short')) except Exception: log.exception('Exception caught while getting last tweet') return 'FeelsBadMan' else: return 'Twitter not set up FeelsBadMan' return 'FeelsBadMan'
def time_ago_timespan_seconds(t, format='long'): return time_since(t, 0, format)
def time_diff(t1, t2, format='long'): return time_since(t1.timestamp(), t2.timestamp(), format)
def time_ago(t, format='long'): return time_since(datetime.datetime.now().timestamp(), t.timestamp(), format)
def time_ago_timespan_seconds(t, format='long'): v = time_since(t, 0, format) return 'None' if len(v) == 0 else v