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))