ability to look up tweets for a user, relative to the latest
This commit is contained in:
parent
57ddba744e
commit
efafb95f5a
|
@ -87,11 +87,19 @@ class Twitter(Module):
|
||||||
return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet, print_source=True))
|
return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet, print_source=True))
|
||||||
except twitter.TwitterError as e:
|
except twitter.TwitterError as e:
|
||||||
return self.reply(connection, replypath, 'Couldn\'t obtain status: ' + str(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:
|
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:
|
if tweets:
|
||||||
tweet = tweets[0]
|
tweet = tweets[-1*index]
|
||||||
return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet))
|
return self.reply(connection, replypath, self.tweet_or_retweet_text(tweet=tweet))
|
||||||
except twitter.TwitterError as e:
|
except twitter.TwitterError as e:
|
||||||
return self.reply(connection, replypath, 'Couldn\'t obtain status: ' + str(e))
|
return self.reply(connection, replypath, 'Couldn\'t obtain status: ' + str(e))
|
||||||
|
|
Loading…
Reference in New Issue