Esempio n. 1
0
def get_match_info():
	matches = api.get_updates()['matches']
	name_dict = {}
	for match in matches[:len(matches) - 2]:
		try:
			PERSON = match['person']
			name = PERSON['name']
			person_id = PERSON['_id'] # for looking up profile
			match_id = match['id'] # for sending messages
			person_json = api.get_person(person_id)
			ping_time = PERSON['ping_time']
			message_count = match['message_count']
			photos = get_photos_by_person_id(person_json)
			bio = PERSON['bio']
			gender = PERSON['gender']
			distance = person_json['results']['distance_mi']
			name_dict[person_id] = {
			"name": name,
			"ping_time": ping_time,
			"match_id": match_id,
			"message_count": message_count,
			"photos": photos,
			"bio": bio,
			"gender": gender,
			"distance": distance
			}
		except:
			continue
	return name_dict
Esempio n. 2
0
def get_match_info():
    matches = api.get_updates()['matches']
    now = datetime.utcnow()
    match_info = {}
    for match in matches[:len(matches)]:
        try:
            person = match['person']
            person_id = person['_id']  # This ID for looking up person
            match_info[person_id] = {
                "name": person['name'],
                "match_id": match['id'],  # This ID for messaging
                "message_count": match['message_count'],
                "photos": get_photos(person),
                "bio": person['bio'],
                "gender": person['gender'],
                "avg_successRate": get_avg_successRate(person),
                "messages": match['messages'],
                "age": calculate_age(match['person']['birth_date']),
                "distance":
                api.get_person(person_id)['results']['distance_mi'],
                "last_activity_date": match['last_activity_date'],
            }
        except Exception as ex:
            template = "An exception of type {0} occurred. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            print(message)
            # continue
    print("All data stored in variable: match_info")
    return match_info
Esempio n. 3
0
def get_match_info():
    matches = api.get_updates()['matches']
    now = datetime.utcnow()
    match_info = {}
    n = len(matches)
    print('\nDownloading match info...', end='')
    for i, match in enumerate(matches[:n]):

        try:
            person = match['person']
            if 'bio' not in person:
                person['bio'] = ''

            match_info[i] = {
                "name": person['name'],
                "person_id": person['_id'],  # This ID for looking up person
                "match_id": match['id'],  # This ID for messaging
                "message_count": match['message_count'],
                "photos": get_photos(person),
                "bio": person['bio'],
                "gender": person['gender'],
                "avg_successRate": get_avg_successRate(person),
                "messages": match['messages'],
                "age": calculate_age(match['person']['birth_date']),
                "distance":
                0,  # api.get_person(person_id)['results']['distance_mi'], # very slow
                "last_activity_date": match['last_activity_date'],
            }
        except Exception as ex:
            template = "An exception of type {0} occurred. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            print(message)
            # continue
    print(' %g matches... Done.' % n)
    return match_info
Esempio n. 4
0
def send_messages(fb_user_data, late_time):
    tinder_api.authverif(fb_user_data['fb_access'], fb_user_data['fb_user'])
    matches = tinder_api.get_updates()['matches']
    for match in matches[:10]:
        tinder_api.send_msg(
            match, u"""Hey babe, just letting you know I’m the
        kind of person who turns up to things {}
        minutes late. Hope you’re okay with that 😉""".format(late_time /
                                                                  60))
        pause()
Esempio n. 5
0
 def find_matches(self, results):
     starting_time = util.get_time()
     for idx, rec in enumerate(results):
         tinder_api.like(rec['_id'])
         print('Liked ' + rec['name'])
         event_emitter.emit_like(rec['_id'])
         if idx % 5 == 0:
             matches = tinder_api.get_updates(starting_time)
             print(matches)
         self.socketSleep(2)
Esempio n. 6
0
def get_match_info():
    matches = api.get_updates()['matches']
    now = datetime.utcnow()
    match_info = {}
    for match in matches[:len(matches) - 2]:
        try:

            person = match['person']
            name = person['name']
            person_id = person['_id']  # for looking up profile
            match_id = match['id']  # for sending messages
            message_count = match['message_count']
            photos = get_photos(person)
            # bio = person['bio']
            gender = person['gender']
            messages = match['messages']
            birthday = match['person']['birth_date']
            avg_successRate = get_avg_successRate(person)
            last_activity_date = match['last_activity_date']
            # Takes too long...
            distance = api.get_person(person_id)['results']['distance_mi']

            match_info[person_id] = {
                "name": name,
                "match_id": match_id,
                "message_count": message_count,
                "photos": photos,
                # "bio": bio,
                "gender": gender,
                "avg_successRate": avg_successRate,
                "messages": messages,
                "age": calculate_age(birthday),
                "distance": distance,
                "last_activity_date": last_activity_date,
                # "readable_activity_date": get_last_activity_date(now, last_activity_date)
            }

        except Exception as ex:
            template = "An exception of type {0} occurred. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            print(message)
    print("All data stored in: match_info")
    return match_info
Esempio n. 7
0
 def update(self):
     try:
         matches = tinder_api.get_updates()['matches']
     except:
         print('COULD NOT UPDATE')
     time.sleep(1)
     self.statistics['cur_matches'] = len(matches)
     for match in matches:
         match_id = match['_id']
         if match_id not in self.matches:  # new match!
             self.onMatch(match)
         else:
             new_messages = [
                 message_obj['message'] for message_obj in match['messages']
             ]
             old_messages = self.matches[match_id]['messages']
             if self.matches[
                     match_id] and old_messages != new_messages:  # new message!
                 self.onNewMessage(new_messages, match_id)
Esempio n. 8
0
def get_matches_and_messages():
    tinder_matches = {}  # { person_id : match_id }
    tinder_messages = {
    }  # { message_id : { 'from': person_id, 'to': person_id, 'message': message } }
    updates = api.get_updates()
    for match in updates["matches"]:
        match_id = match["id"]
        person_id = match["participants"][0]
        tinder_matches[person_id] = match_id
        messages = match["messages"]
        for message in messages:
            message_id = message["_id"]
            info = {
                'from': message["from"],
                'to': message["to"],
                'message': message["message"]
            }

            tinder_messages[message_id] = info
    return (tinder_matches, tinder_messages)
Esempio n. 9
0
def main():
    updates = api.get_updates()
    dumps(updates, "Updates:")