Exemple #1
0
def matched(userid, matchid):
    m = User.objects.get(userid=matchid)
    matchname = m.firstname
    u = User.objects.get(userid=userid)
    username = u.firstname
    gender = u.gender
    if gender == "female":
        text = itsamatch1 + str(matchname) + itsamatch2
        simple_message(userid, text)
        gtext = itsamatchg1 + str(matchname) + "?"
        b1 = "WhatsApp"
        p1 = "whatsapp"
        b2 = "Snapchat"
        p2 = "instagram"
        b3 = itsamatchg2
        p3 = "otherapp"
        three_button_message(userid, gtext, b1, p1, b2, p2, b3, p3)
        u.matchtrigger = "female"
        u.save()
    elif gender == "male":
        g = User.objects.get(userid=matchid)
        text = nomatchyet
        simple_message(userid, text)
        matching(userid)
        male_triggered_match(userid, matchid)
Exemple #2
0
def process_quiz_payload(fbid, payload):
    user = User.objects.get(userid=fbid)
    if payload == "smoker" or payload == "nonsmoker":
        question2(fbid)
        user.quiz1 = payload
        user.save()
    elif payload == "petsyes" or payload == "petsno":
        question3(fbid)
        user.quiz2 = payload
        user.save()
    elif payload == "uni" or payload == "nouni":
        question4(fbid)
        user.quiz3 = payload
        user.save()
    elif payload == "tattoos" or payload == "notattoos":
        question5(fbid)
        user.quiz4 = payload
        user.save()
    elif payload == "long" or payload == "short" or payload == "fun":
        user.quiz5 = payload
        user.quizstatus = "completed"
        user.save()
        text = qend
        simple_message(fbid, text)
        start_message(fbid, qf1, qf2, qf3)
Exemple #3
0
def record_no_interest(fbid, interest):
    u = User.objects.get(userid=fbid)
    pid = u.lastshownpmid
    #save that the user dit not like the pm
    p = PotentialMatches.objects.update_or_create(
        pmid=pid, user=u, defaults={'userisinterestedinpm': interest})
    text = nointerest
    simple_message(fbid, text)
    matching(fbid)
Exemple #4
0
def notify_newuser(usr, notyetshownuser):
    u = User.objects.get(userid=usr)
    city = u.city
    text = newusers + city + "!"
    simple_message(usr, text)
    show_pm_profile(usr, notyetshownuser)
    u.lastshownpmid = notyetshownuser
    u.save()
    pprint("hello from notify_newuser")
Exemple #5
0
def matchingquery2(uid, ucity, ugender, ulookingfor):
    for person in User.objects.filter(region=ucity,
                                      gender=ulookingfor,
                                      picturestatus="completed"):
        pmid = person.userid
        interest = PotentialMatches.objects.filter(pmid=pmid, user__userid=uid)
        if not interest:
            show_pm_profile(uid, pmid)
            user = User.objects.get(userid=uid)
            user.lastshownpmid = pmid
            user.save()
            pprint("we have somebody to show here")
            break
    else:
        statustext = nomoreusers + ucity + "!"
        simple_message(uid, statustext)
        pprint("nothin to show")
Exemple #6
0
def process_status(fbid, incoming_message):
    u = User.objects.get(userid=fbid)
    status = u.messagestatus
    trigger = u.matchtrigger
    if trigger == "female":
        boy = u.lastshownpmid
    elif trigger == "male":
        boy = u.lastmatchid
    b = User.objects.get(userid=boy)
    boyname = b.firstname
    b1 = imbutton1
    b2 = imbutton2
    b3 = imbutton3
    p1 = "msend"
    p2 = "mchange"
    p3 = "mcancel"
    if status == "MW":
        u.whatsappnr = incoming_message
        u.messagestatus = "1a"
        u.save()
        text = itsamatchsend + "WhatsApp" + itsamatchsend2 + "(" + incoming_message + ")" + itsamatchsend3 + str(
            boyname)
        three_button_message(fbid, text, b1, p1, b2, p2, b3, p3)
    elif status == "MI":
        u.instauser = incoming_message
        u.messagestatus = "1a"
        u.save()
        text = itsamatchsend + "Snapchat" + itsamatchsend2 + "(" + incoming_message + ")" + itsamatchsend3 + str(
            boyname)
        three_button_message(fbid, text, b1, p1, b2, p2, b3, p3)
    elif status == "MO":
        u.otherappname = incoming_message
        u.messagestatus = "MO2"
        u.save()
        text = otherapp2 + str(boyname) + otherapp3
        simple_message(fbid, text)
    elif status == "MO2":
        appname = u.otherappname
        u.otherappdetails = incoming_message
        u.messagestatus = "1a"
        u.save()
        text = itsamatchsend + appname + itsamatchsend2 + "(" + incoming_message + ")" + itsamatchsend3 + str(
            boyname)
        three_button_message(fbid, text, b1, p1, b2, p2, b3, p3)
Exemple #7
0
def receive_payload(userid, payload):
    u = User.objects.get(userid=userid)
    #part 1
    if payload == "whatsapp":
        text = whatsapp
        u.messagestatus = "MW"
        u.preferredapp = "whatsapp"
        u.save()
        #update user.messagestatus to Mwhatsapp
        simple_message(userid, text)
    elif payload == "instagram":
        text = insta
        u.messagestatus = "MI"
        u.preferredapp = "insta"
        u.save()
        simple_message(userid, text)
    elif payload == "otherapp":
        text = otherapp
        u.messagestatus = "MO"
        u.preferredapp = "other"
        u.save()
        simple_message(userid, text)
    #part2
    elif payload == "msend":
        text = msent
        simple_message(userid, text)
        app = u.preferredapp
        mid = u.lastshownpmid
        share_contact(userid, mid, app)
        #check if more users are available and act accordingly
    elif payload == "mchange":
        text = mchange
        b1 = "WhatsApp"
        p1 = "whatsapp"
        b2 = "Snapchat"
        p2 = "instagram"
        b3 = itsamatchg2
        p3 = "otherapp"
        three_button_message(userid, text, b1, p1, b2, p2, b3, p3)
    elif payload == "mcancel":
        text = mcancel
        simple_message(userid, text)
Exemple #8
0
def male_triggered_match(uid, mid):
    pprint("mtrigger function")
    u = User.objects.get(userid=uid)
    #u is man
    m = User.objects.get(userid=mid)
    #m is woman
    m.matchtrigger = "male"
    m.lastmatchid = uid
    m.save()
    uname = u.firstname
    mname = m.firstname
    text = contact1 + mname + "! " + contact2 + uname + contact3 + contact4 + uname + " " + contact5
    simple_message(mid, text)
    recall_profile(mid, uid)
    gtext = itsamatchg1 + uname + "?"
    b1 = "WhatsApp"
    p1 = "whatsapp"
    b2 = "Snapchat"
    p2 = "instagram"
    b3 = itsamatchg2
    p3 = "otherapp"
    three_button_message(mid, gtext, b1, p1, b2, p2, b3, p3)
Exemple #9
0
def share_contact(uid, mid, app):
    u = User.objects.get(userid=uid)
    m = User.objects.get(userid=mid)
    uname = u.firstname
    mname = m.firstname
    text = contact1 + mname + "! " + contact2 + uname + contact3 + contact4 + uname + " " + contact5
    simple_message(mid, text)
    recall_profile(mid, uid)
    if app == "whatsapp":
        phone = u.whatsappnr
        text2 = contact6 + uname + "! " + contact7 + uname + contact8 + "WhatsApp! " + contact9 + phone + "! " + contact11
        simple_message(mid, text2)
    elif app == "insta":
        instagram = u.instauser
        text2 = contact6 + uname + "! " + contact7 + uname + contact8 + "Snapchat! " + contact10 + instagram + "! " + contact11
        simple_message(mid, text2)
    elif app == "other":
        appname = u.otherappname
        appdetails = u.otherappdetails
        text2 = contact6 + uname + "! " + contact7 + uname + contact8 + appname + "! " + contact12 + appdetails + "! " + contact11
        simple_message(mid, text2)
Exemple #10
0
def show_pm_profile(uid, pmid):
    pprint("made it until here")
    user = User.objects.get(userid=pmid)
    user_details_url = "https://graph.facebook.com/v2.6/%s" % pmid
    user_details_params = {
        'fields': 'first_name,last_name,profile_pic',
        'access_token': PAGE_ACCESS_TOKEN
    }
    user_details = requests.get(user_details_url, user_details_params).json()
    text = matchintro + user_details['first_name'] + "!"
    simple_message(uid, text)
    introtext1 = user.intro1
    introtext2 = user.intro2
    introtext3 = user.intro3
    imageurl1 = "https://s3.amazonaws.com/eimagestorage/" + pmid + "image1.jpg"
    imageurl2 = "https://s3.amazonaws.com/eimagestorage/" + pmid + "image2.jpg"
    #imageurl3 = "https://storage.cloud.google.com/eimagestorage/rob1.jpg?_ga=2.9924277.-1862101233.1513003688"
    imageurl3 = "https://s3.amazonaws.com/eimagestorage/" + pmid + "image3.jpg"
    pprint(imageurl1)
    city = user.city
    intro1 = himynameis + user_details[
        'first_name'] + ", " + iamcurrentlyin + " " + city + " " + andiam + " " + introtext1 + " " + yearsold
    intro2 = myclosestfriends + introtext2
    intro3 = iampassionateabout + introtext3

    post_message_url = 'https://graph.facebook.com/v2.6/me/messages?access_token=%s' % PAGE_ACCESS_TOKEN
    response_msg = json.dumps({
        "recipient": {
            "id": uid
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type":
                    "generic",
                    "image_aspect_ratio":
                    "square",
                    "elements": [{
                        "title":
                        user_details['first_name'],
                        "image_url":
                        imageurl1,
                        "subtitle":
                        intro1,
                        "buttons": [{
                            "type": "postback",
                            "title": interestedbutton,
                            "payload": "interested"
                        }, {
                            "type": "postback",
                            "title": notinterestedbutton,
                            "payload": "notinterested"
                        }]
                    }, {
                        "title":
                        user_details['first_name'],
                        "image_url":
                        imageurl2,
                        "subtitle":
                        intro2,
                        "buttons": [{
                            "type": "postback",
                            "title": interestedbutton,
                            "payload": "interested"
                        }, {
                            "type": "postback",
                            "title": notinterestedbutton,
                            "payload": "notinterested"
                        }]
                    }, {
                        "title":
                        user_details['first_name'],
                        "image_url":
                        imageurl3,
                        "subtitle":
                        intro3,
                        "buttons": [{
                            "type": "postback",
                            "title": interestedbutton,
                            "payload": "interested"
                        }, {
                            "type": "postback",
                            "title": notinterestedbutton,
                            "payload": "notinterested"
                        }]
                    }]
                }
            }
        }
    })
    status = requests.post(post_message_url,
                           headers={"Content-Type": "application/json"},
                           data=response_msg)
    pprint(status.json())
    pprint("wip")
Exemple #11
0
def no_match_yet(fbid, pid):
    text = nomatchyet
    simple_message(fbid, text)
    matching(fbid)
Exemple #12
0
def question1(fbid):
    simple_message(fbid, quiz0)
    p1 = "smoker"
    p2 = "nonsmoker"
    two_button_message(fbid, quiz1, qa, p1, qb, p2)