Esempio n. 1
0
def send_receipt(recipient):
    receipt_id = "order1357"
    element = Template.ReceiptElement(title="Oculus Rift",
                                      subtitle="Includes: headset, sensor, remote",
                                      quantity=1,
                                      price=599.00,
                                      currency="USD",
                                      image_url=CONFIG['SERVER_URL'] + "/assets/riftsq.png"
                                      )

    address = Template.ReceiptAddress(street_1="1 Hacker Way",
                                      street_2="",
                                      city="Menlo Park",
                                      postal_code="94025",
                                      state="CA",
                                      country="US")

    summary = Template.ReceiptSummary(subtotal=698.99,
                                      shipping_cost=20.00,
                                      total_tax=57.67,
                                      total_cost=626.66)

    adjustment = Template.ReceiptAdjustment(name="New Customer Discount", amount=-50)

    page.send(recipient, Template.Receipt(recipient_name='Peter Chang',
                                          order_number=receipt_id,
                                          currency='USD',
                                          payment_method='Visa 1234',
                                          timestamp="1428444852",
                                          elements=[element],
                                          address=address,
                                          summary=summary,
                                          adjustments=[adjustment]))
Esempio n. 2
0
def received_authentication(event):
    sender_id = event.sender_id
    recipient_id = event.recipient_id
    time_of_auth = event.timestamp

    pass_through_param = event.optin.get("ref")

    print("Received authentication for user %s and page %s with pass "
          "through param '%s' at %s" % (sender_id, recipient_id, pass_through_param, time_of_auth))

    page.send(sender_id, "Authentication successful")
Esempio n. 3
0
def received_postback(event):
    sender_id = event.sender_id
    recipient_id = event.recipient_id
    time_of_postback = event.timestamp

    payload = event.postback_payload

    print("Received postback for user %s and page %s with payload '%s' at %s"
          % (sender_id, recipient_id, payload, time_of_postback))

    page.send(sender_id, "Postback called")
Esempio n. 4
0
def send_quick_reply(recipient):
    """
    shortcuts are supported
    page.send(recipient, "What's your favorite movie genre?",
                quick_replies=[{'title': 'Action', 'payload': 'PICK_ACTION'},
                               {'title': 'Comedy', 'payload': 'PICK_COMEDY'}, ],
                metadata="DEVELOPER_DEFINED_METADATA")
    """
    page.send(recipient, "What's your favorite movie genre?",
              quick_replies=[QuickReply(title="Action", payload="PICK_ACTION"),
                             QuickReply(title="Comedy", payload="PICK_COMEDY")],
              metadata="DEVELOPER_DEFINED_METADATA")
Esempio n. 5
0
def send_message(recipient_id, text):

	#Esta sección es para la programación del lenguaje antes del quick_reply
    V1 = reg.N1
    V2 = reg.N2
    if re.match(V1, text):
    	send_button(recipient_id)
    	#send_read_receipt(recipient_id)
    	#send_typing_on(recipient_id)
    	#enviar_reglamento(recipient_id)
    	#send_typing_on(recipient_id)
    	#enviar_boton(recipient_id)
    if re.match(V2, text):
    	send_read_receipt(recipient_id)
    	send_typing_on(recipient_id)
    	page.send(recipient_id, "¡Gracias por utilizar nuestro servicio!\n¡Qué la fuerza lo acompañe!")
    	send_typing_on(recipient_id)
    	send_gif(recipient_id)
Esempio n. 6
0
def send_generic(recipient):
    page.send(recipient, Template.Generic([
        Template.GenericElement("rift",
                                subtitle="Next-generation virtual reality",
                                item_url="https://www.oculus.com/en-us/rift/",
                                image_url=CONFIG['SERVER_URL'] + "/assets/rift.png",
                                buttons=[
                                    Template.ButtonWeb("Open Web URL", "https://www.oculus.com/en-us/rift/"),
                                    Template.ButtonPostBack("Opción de tránsito", "DEVELOPED_DEFINED_PAYLOAD"),
                                    Template.ButtonPhoneNumber("Call Phone Number", "+16505551234")
                                ]),
        Template.GenericElement("touch",
                                subtitle="Your Hands, Now in VR",
                                item_url="https://www.oculus.com/en-us/touch/",
                                image_url=CONFIG['SERVER_URL'] + "/assets/touch.png",
                                buttons=[
                                    {'type': 'web_url', 'title': 'Open Web URL',
                                     'value': 'https://www.oculus.com/en-us/rift/'},
                                    {'type': 'postback', 'title': 'Opción de tránsito',
                                     'value': 'DEVELOPED_DEFINED_PAYLOAD'},
                                    {'type': 'phone_number', 'title': 'Call Phone Number', 'value': '+16505551234'},
                                ])
    ]))
Esempio n. 7
0
def received_message(event):
    sender_id = event.sender_id
    recipient_id = event.recipient_id
    time_of_message = event.timestamp
    message = event.message
    print("Received message for user %s and page %s at %s with message:"
          % (sender_id, recipient_id, time_of_message))
    print(message)

    seq = message.get("seq", 0)
    message_id = message.get("mid")
    app_id = message.get("app_id")
    metadata = message.get("metadata")

    message_text = message.get("text")
    message_attachments = message.get("attachments")
    quick_reply = message.get("quick_reply")

    seq_id = sender_id + ':' + recipient_id
    if USER_SEQ.get(seq_id, -1) >= seq:
        print("Ignore duplicated request")
        return None
    else:
        USER_SEQ[seq_id] = seq

    if quick_reply:
        quick_reply_payload = quick_reply.get('payload')
        print("quick reply for message %s with payload %s" % (message_id, quick_reply_payload))

        #Esta sección es la acción del botón quick_reply
        page.send(sender_id, "Te encuentras en la sección de: ")
        V1 = re.compile('Seguridad|SEGURIDAD|seguridad')
        if re.match(V1, message_text):
        	page.send(sender_id, message_text)
        #Aquí termina la sección de la acción del botón quick_reply

    if message_text:
        send_message(sender_id, message_text)
    elif message_attachments:
        page.send(sender_id, "Message with attachment received")
Esempio n. 8
0
def send_text_message(recipient, text):
    page.send(recipient, text, metadata="DEVELOPER_DEFINED_METADATA")
Esempio n. 9
0
def send_account_linking(recipient):
    page.send(recipient, Template.AccountLink(text="Welcome. Link your account.",
                                              account_link_url=CONFIG['SERVER_URL'] + "/authorize",
                                              account_unlink_button=True))
Esempio n. 10
0
def send_image(recipient):
    page.send(recipient, Attachment.Image(CONFIG['SERVER_URL'] + "/assets/rift.png"))
Esempio n. 11
0
def callback_clicked_button(payload, event):
    page.send(event.sender_id, "que tal")
Esempio n. 12
0
def send_button(recipient):
    page.send(recipient, Template.Buttons(".", [
        Template.ButtonWeb("Open Web URL", "https://www.oculus.com/en-us/rift/"),
        Template.ButtonPostBack("Opción de tránsito", "OPCION_DE_TRANSITO"),
        Template.ButtonPhoneNumber("Call Phone Number", "+16505551234")
    ]))
Esempio n. 13
0
def enviar_boton(recipient):
	page.send(recipient, "¿En cuál de estos se encuentra tu caso?",
              quick_replies=[QuickReply(title="Seguridad", payload="PICK_SEGURIDAD"),
                             QuickReply(title="Multa", payload="PICK_MULTA"),
                             QuickReply(title="Acceso", payload="PICK_ACCESO")],
              metadata="DEVELOPER_DEFINED_METADATA")
Esempio n. 14
0
def enviar_reglamento(recipient):
	page.send(recipient, Template.Buttons("¡Hola "+page.get_user_profile(recipient)["first_name"]+" "+page.get_user_profile(recipient)["last_name"]+"! Bienvenido a TransiBot" ,[
        Template.ButtonWeb("Reglamento de tránsito CDMX", "http://data.ssp.cdmx.gob.mx/reglamentodetransito/documentos/nuevo_reglamento_transito.pdf"),
    ]))
Esempio n. 15
0
def send_file(recipient):
    page.send(recipient, Attachment.File(CONFIG['SERVER_URL'] + "/assets/test.txt"))
Esempio n. 16
0
def send_video(recipient):
    page.send(recipient, Attachment.Video(CONFIG['SERVER_URL'] + "/assets/allofus480.mov"))
Esempio n. 17
0
def send_audio(recipient):
    page.send(recipient, Attachment.Audio(CONFIG['SERVER_URL'] + "/assets/sample.mp3"))
Esempio n. 18
0
def send_gif(recipient):
    page.send(recipient, Attachment.Image(CONFIG['SERVER_URL'] + "/assets/despedida.gif"))