From efafb95f5a09b8d825500e54726b88aa574c51b3 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Thu, 16 Dec 2010 15:23:35 -0600 Subject: [PATCH] ability to look up tweets for a user, relative to the latest --- modules/Twitter.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/Twitter.py b/modules/Twitter.py index 7ad78d9..4839531 100644 --- a/modules/Twitter.py +++ b/modules/Twitter.py @@ -87,11 +87,19 @@ class Twitter(Module): return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet, print_source=True)) except twitter.TwitterError as e: return self.reply(connection, replypath, 'Couldn\'t obtain status: ' + str(e)) - elif whats[1] == 'user' and len(whats) == 3: + elif whats[1] == 'user' and len(whats) >= 3: + if len(whats) >= 4: + index = int(whats[3]) + if index < 0: + index = 0 + else: + index = 0 + + count = (-1*index) + 1 try: - tweets = self.twit.GetUserTimeline(screen_name=whats[2], count=30, include_rts=True) + tweets = self.twit.GetUserTimeline(screen_name=whats[2], count=count, include_rts=True) if tweets: - tweet = tweets[0] + tweet = tweets[-1*index] return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet)) except twitter.TwitterError as e: return self.reply(connection, replypath, 'Couldn\'t obtain status: ' + str(e))