示例#1
0
 def get(self):
     try:
         # TODO: Still need some optimisation to search right tweets
         tweets_to_retweet = Tweet.search_for_required_tweets('%23giveaway+-filter:links', 10)
         now = datetime.now()
         retweet_in = 0
         for tweet in tweets_to_retweet[-10:]:
             also_follow = False
             if ' follow ' in tweet.tweet_text.lower() or ' #follow ' in tweet.tweet_text.lower():
                 also_follow = True
             also_favorite = False
             if ' favorite ' in tweet.tweet_text.lower() or ' #favorite ' in tweet.tweet_text.lower() or ' fav ' in\
                     tweet.tweet_text.lower() or ' #fav ' in tweet.tweet_text.lower():
                 also_favorite = True
             tweet_to_db = tweet.put()
             # if we need to retweet, follow and favorite
             if also_follow and also_favorite:
                 pass
             # if we need to retweet and favorite
             elif also_favorite:
                 pass
             # if we need retweet and follow
             elif also_follow:
                 account_to_db = Account(id_on_twitter=tweet.tweeted_by_id).put()
                 taskqueue.add(url='/twitter/retweet_and_follow_worker/'+str(tweet_to_db.id()) + '/' +
                               str(account_to_db.id()),
                               eta=now+timedelta(minutes=retweet_in))
             # if we just need to retweet
             else:
                 taskqueue.add(url='/twitter/retweet_worker/'+str(tweet_to_db.id()),
                               eta=now+timedelta(minutes=retweet_in))
             retweet_in += 1
         self.response.out.write('Fifteen tweets successfully scheduled to be retweeted in next fifteen minutes.')
     except Exception, msg:
         self.response.out.write(msg)
示例#2
0
 def get(self):
     try:
         # TODO: Still need some optimisation to search right tweets
         tweets_to_retweet = Tweet.search_for_required_tweets('%23giveaway+-filter:links', 10)
         now = datetime.now()
         retweet_in = 0
         for tweet in tweets_to_retweet[-15:]:  # as we can't add more that 15 tasks in default queue
             # TODO: Check if we need to follow account that tweeted
             also_follow = False
             tweet_to_db = tweet.put()
             if also_follow:
                 account_to_db = Account(id_on_twitter=tweet.tweeted_by_id).put()
                 taskqueue.add(url='/twitter/retweet_and_follow_worker/'+str(tweet_to_db.id()) + '/' +
                               str(account_to_db.id()),
                               eta=now+timedelta(minutes=retweet_in))
             else:
                 taskqueue.add(url='/twitter/retweet_worker/'+str(tweet_to_db.id()),
                               eta=now+timedelta(minutes=retweet_in))
             retweet_in += 1
         self.response.out.write('Fifteen tweets successfully scheduled to be retweeted in next fifteen minutes.')
     except Exception, msg:
         self.response.out.write(msg)