Esempio n. 1
0
def checkAiloveVenues(threadName="") :

    timestamp = str(int(time.time()) - 60*60) 
     
    while True :
    
        print "[CHECK AILOVE CHECKINS]"
        
        for venue in ailoveVenues :
            print "[VENUE %s]" % venue
            herenow = foursquare.venueHereNow(venue, timestamp)
            try:
                if herenow :
                    print "here now", herenow['response']['hereNow']['count']
                    for item in herenow['response']['hereNow']['items']:
                        print item['user']['id']
                        print 'relationship' in item['user'] 
                        if 'relationship' not in item['user'] :
                            foursquare.sendFriendRequest(item['user']['id'])
            except Exception:
                f = open("Ailove.Error.log", "a")
                f.write(str(herenow))
                f.close()

        timestamp = str(int(time.time()) - 30)
        sys.stdout.flush()
        # sleep 5 mins
        time.sleep(60)
Esempio n. 2
0
def findNewPlaceToCheckin(threadName=""):
    
    global lat, lng
    global checkinedAlready
    global startTime

    while True:
        print "[FIND NEW PLACE CHECKINS]"
        # SEARCHING TREND CHEKCIN AND FIENDING   
        try:
            trending = foursquare.venuesTrending(lat, lng)
        except Exception:
            trending = False
        
        if trending:
            for venue in trending['response']['venues']:
                lat = str(venue['location']['lat'])
                lng = str(venue['location']['lng'])
                print venue['id'], venue['hereNow']['count'], lat, lng  
            
                if venue['id'] not in checkinedAlready :
                
                    checkin = foursquare.checkinsAdd(venue['id'])
                    checkinedAlready.append(venue['id'])
                
                    # 10% chance to find new friend
                    if searchFriends and random.randint(0, 100) > 90 : 
                        herenow = foursquare.venueHereNow(venue['id'])
                        if herenow :
                            print "here now",herenow['response']['hereNow']['count']
                
                            for item in herenow['response']['hereNow']['items']:
                                print item['id'], item['type'], item['user']['id'], item['user']['firstName'] 
                                foursquare.sendFriendRequest(item['user']['id'])
                                break          
                    break # from venues 
        
        # reset day
        if (int(time.time()) - startTime) > 60*60*24 :
            checkinedAlready = []
            startTime = int(time.time())

        print "sleeping 15-60 min"
        time.sleep(random.randint(300,1800))