Print tweets in reverse order, improve track

This commit is contained in:
Klaus-Uwe Mitterer 2017-03-25 16:21:55 +01:00
parent 1f0b754b1f
commit f309a854c6

View file

@ -345,7 +345,14 @@ def search(bot, update, args):
try:
two = bottools.methods.getTwo(update.message)
lt = []
for tweet in two.api.search(q=query, rpp=count, result_type="recent")[:count]:
lt += [tweet]
lt.reverse()
for tweet in lt:
tweetMessage(tweet, update.message.chat_id, bot)
except tweepy.error.TweepError as e:
@ -360,7 +367,14 @@ def user(bot, update, args):
try:
two = bottools.methods.getTwo(update.message)
lt = []
for status in two.api.user_timeline(args[0], count = count):
lt += [status]
lt.reverse()
for status in lt:
tweetMessage(status, update.message.chat_id, bot)
except tweepy.error.TweepError as e:
@ -386,8 +400,14 @@ def timeline(bot, update, args = [10]):
try:
two = bottools.methods.getTwo(update.message)
lt = []
for status in two.api.home_timeline(count=count):
lt += [status]
lt.reverse()
for status in lt:
tweetMessage(status, update.message.chat_id, bot)
except tweepy.error.TweepError as e:
@ -400,7 +420,7 @@ mentionstreams = {}
def makeStream(bot, cid):
two = twitools.twoBotHelper(cid)
stream = tweepy.Stream(auth = two.auth, listener = twitools.streaming.BotStreamListener(bot, cid))
stream.filter(track=[two.whoami()], async=True)
stream.filter(track=["@%s" % two.whoami().strip("@")], async=True)
return stream
try: