Example #1
0
    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>')
Example #2
0
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, mention['id'])

        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)
Example #3
0
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)
Example #4
0
def main():
    oauth = twitter.init()

    since_id = None

    while True:
        mentions = twitter.get_mentions(oauth, since_id)
        if mentions:
            since_id = mentions[0]["id"]
        option_mentions = select_option_mentions(mentions)
        pass_mentions = select_pass_mentions(option_mentions)
        results = get_results(pass_mentions)
        twitter.result_reply(oauth, results)

        time.sleep(15)
Example #5
0
def process_mentions():
	f = open(get_chemin('sinceID'), 'rb')
	sinceID = f.read()
	print("ID : " + sinceID)
	f.close()

	mentions = twitter.get_mentions(sinceID)
	mentions.reverse()

	for mention in mentions:
		if "#waifu" in mention['text'].lower() :
			print("Ca contient waifu") #Debug
			dessert_waifu(mention)
		elif "#pd" in mention['text'].lower() or "#dessertsays" in mention['text'].lower() :
			print("Ca contient dessertSays")
			parle_avec_dessert(mention)
		print ("Fin") #Debug

		fout = file(get_chemin('sinceID'), "w+b")
		fout.seek(0)
		fout.truncate()
		fout.write(str(mention['id']))
		fout.close()
Example #6
0
import twitter

print twitter.get_rate_limit_status()

mentions = twitter.get_mentions()
assert len(mentions) > 1

tweets = twitter.get_tweets('markovator_dev')
assert len(tweets) > 1

print("Tests passed")