Ejemplo n.º 1
0
    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'
Ejemplo n.º 2
0
    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'
Ejemplo n.º 3
0
def time_ago_timespan_seconds(t, format='long'):
    return time_since(t, 0, format)
Ejemplo n.º 4
0
def time_diff(t1, t2, format='long'):
    return time_since(t1.timestamp(), t2.timestamp(), format)
Ejemplo n.º 5
0
def time_ago(t, format='long'):
    return time_since(datetime.datetime.now().timestamp(), t.timestamp(), format)
Ejemplo n.º 6
0
def time_ago_timespan_seconds(t, format='long'):
    v = time_since(t, 0, format)
    return 'None' if len(v) == 0 else v
Ejemplo n.º 7
0
def time_diff(t1, t2, format='long'):
    return time_since(t1.timestamp(), t2.timestamp(), format)
Ejemplo n.º 8
0
def time_ago(t, format='long'):
    return time_since(datetime.datetime.now().timestamp(), t.timestamp(),
                      format)