def get(self): self.response.out.write('<html><body>') app_status = status.load() since_id = app_status.get('reply_since_id', -1) if since_id: mentions = twitter.get_mentions(since_id) else: mentions = twitter.get_mentions() self.response.out.write("<pre>" + str(since_id) + ":" + str(mentions) + "</pre>") if not mentions: return for mention in reversed(mentions): self.response.out.write("<p>" + str(mention['id']) + " | " + mention['user']['screen_name'] + " protected("+ str(mention['user']['protected']) + "): " + mention['text'] +"</p>") self.reply_to_user(mentions[-1]['user'], app_status) twitter.follow_user(mentions[-1]['user']['screen_name']) app_status['reply_since_id'] = mentions[-1]['id'] app_status['latest_user_replied_to'] = mentions[-1]['user']['screen_name'] status.save(app_status) self.response.out.write('</body></html>')
def process_replies(): app_status = status.load() since_id = app_status.get('reply_since_id', -1) if since_id: mentions = twitter.get_mentions(since_id) else: mentions = twitter.get_mentions() print(str(len(mentions))+" mentions since "+str(since_id)) mentions.reverse() for mention in mentions: twitter.follow_user(mentions[-1]['user']['screen_name']) reply_to_user(mention['user'], app_status) app_status['reply_since_id'] = mention['id'] app_status['latest_user_replied_to'] = mention['user']['screen_name'] # Save after each one so if we crash we don't resend replies status.save(app_status)
def process_replies(): app_status = status.load() since_id = app_status.get('reply_since_id', -1) if since_id: mentions = twitter.get_mentions(since_id) else: mentions = twitter.get_mentions() print(str(len(mentions)) + " mentions since " + str(since_id)) mentions.reverse() for mention in mentions: twitter.follow_user(mentions[-1]['user']['screen_name']) reply_to_user(mention['user'], app_status) app_status['reply_since_id'] = mention['id'] app_status['latest_user_replied_to'] = mention['user']['screen_name'] # Save after each one so if we crash we don't resend replies status.save(app_status)