Beispiel #1
0
def stageTwo(messageTypeContent, senderID, usr):
    if messageTypeContent["type"] == "location" or messageTypeContent[
            "type"] == "text":
        loc = getGeocodeAndText(messageTypeContent["content"])

        if loc == None:
            postSendLocationQuickReply(
                senderID, "locatia nu e valida, mai incearca o data")

        else:
            usr.dest_loc_address = loc["text"]
            usr.dest_loc_lat = loc["geocode"][0]
            usr.dest_loc_lng = loc["geocode"][1]
            postFacebookMessage(
                senderID, "Ai setat %s ca destinatie" % (usr.dest_loc_address))
            if len(usr.origin_loc_address) > 0:
                postAskForLocGetNearbyLocGetRoute(
                    senderID,
                    "Schimba locatia de origine, vezi ce localuri sunt imprejur, sau obtine o ruta pentru locatiile curente"
                )
            else:
                postAskForLocGetNearbyLoc(
                    senderID,
                    "Schimba locatia de origine sau vezi ce localuri sunt imprejur"
                )

            usr.stage = 3
    return
Beispiel #2
0
def stageOne(messageTypeContent, senderID, usr):  #sets the origin location
    if messageTypeContent["type"] == "location" or messageTypeContent[
            "type"] == "text":
        loc = getGeocodeAndText(messageTypeContent["content"])
        if loc == None:
            postSendLocationQuickReply(
                senderID, "locatia nu e valida, mai incearca o data")
        else:
            usr.origin_loc_address = loc["text"]
            usr.origin_loc_lat = loc["geocode"][0]
            usr.origin_loc_lng = loc["geocode"][1]
            print str((usr.origin_loc_lat, usr.origin_loc_lng))
            postFacebookMessage(
                senderID,
                "Ai setat %s ca adresa de pornire" % (usr.origin_loc_address))
            if len(usr.dest_loc_address) > 0:
                postAskForLocGetNearbyLocGetRoute(
                    senderID,
                    "Trimite-mi o noua locatie unde vrei sa ajungi, sau vezi ce localuri sunt imprejur, sau obtine o ruta pentru locatiile curente"
                )
            else:
                postAskForLocGetNearbyLoc(
                    senderID,
                    "Trimite-mi o locatie unde vrei sa ajungi, sau vezi ce localuri sunt imprejur"
                )
            usr.stage = 2
    return
Beispiel #3
0
def resolveLocation(messageTypeContent, senderID, usr):
    if messageTypeContent["type"] != "location_setter":
        postAskWhatToDoWithLocation(
            senderID,
            "Nu ma ajuti, ce ai vrea sa faci cu ultima locatie trimisa?")
    elif usr.temporary_loc_address != None:
        if messageTypeContent["content"] == "origin":
            usr.origin_loc_address = usr.temporary_loc_address
            usr.origin_loc_lat = usr.temporary_loc_lat
            usr.origin_loc_lng = usr.temporary_loc_lng

            usr.temporary_loc_address = ""
            usr.temporary_loc_lat = usr.temporary_loc_lng = None

            postTemplateTextButtons(senderID, usr.origin_loc_address,
                                    (usr.origin_loc_lat, usr.origin_loc_lng),
                                    usr.dest_loc_address,
                                    (usr.dest_loc_lat, usr.dest_loc_lng))
            usr.stage = 3

        elif messageTypeContent["content"] == "dest":
            usr.dest_loc_address = usr.temporary_loc_address
            usr.dest_loc_lat = usr.temporary_loc_lat
            usr.dest_loc_lng = usr.temporary_loc_lng

            usr.temporary_loc_address = ""
            usr.temporary_loc_lat = usr.temporary_loc_lng = None

            postTemplateTextButtons(senderID, usr.origin_loc_address,
                                    (usr.origin_loc_lat, usr.origin_loc_lng),
                                    usr.dest_loc_address,
                                    (usr.dest_loc_lat, usr.dest_loc_lng))
            usr.stage = 3

        elif messageTypeContent["content"] == "nearby":
            pass
    else:
        if messageTypeContent["content"] == "origin":
            postSendLocationQuickReply(senderID, "Trimite-mi locatia ta")

        elif messageTypeContent["content"] == "dest":
            postSendLocationQuickReply(
                senderID, "Trimite-mi locatia unde vrei sa ajungi")

        elif messageTypeContent["content"] == "nearby":
            pass
    return
Beispiel #4
0
def setStageTwo(senderID, usr):
    postSendLocationQuickReply(senderID,
                               "Trimite-mi locatia unde vrei sa ajungi")
    usr.stage = 2
Beispiel #5
0
def setStageOne(senderID, usr):
    postSendLocationQuickReply(senderID, "Trimite-mi locatia de pornire")
    usr.stage = 1