コード例 #1
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
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]))
コード例 #2
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))
コード例 #3
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))

        page.send(sender_id, "Quick reply tapped")

    if message_text:
        send_message(sender_id, message_text)
    elif message_attachments:
        page.send(sender_id, "Message with attachment received")
コード例 #4
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_message(recipient_id, text):
    # If we receive a text message, check to see if it matches any special
    # keywords and send back the corresponding example. Otherwise, just echo
    # the text we received.
    special_keywords = {
        "image": send_image,
        "gif": send_gif,
        "audio": send_audio,
        "video": send_video,
        "file": send_file,
        "button": send_button,
        "generic": send_generic,
        "receipt": send_receipt,
        "quick reply": send_quick_reply,
        "read receipt": send_read_receipt,
        "typing on": send_typing_on,
        "typing off": send_typing_off,
        "account linking": send_account_linking
    }

    if text in special_keywords:
        print("send_message: special type %s" % text)
        special_keywords[text](recipient_id)
    else:
        page.send(recipient_id, text, callback=send_text_callback, notification_type=NotificationType.REGULAR)
コード例 #5
0
def send_reddit_post(recipient_id, microarticle, microarticle_type):
    #sends user the text message provided via input response parameter
    print("[i] Formatting Article...")
    response = article_Service.format_article(microarticle, microarticle_type)

    print("[i] " + microarticle_type + " SRC:\t" + str(microarticle.domain))
    if microarticle_type == "image":
        image_formats = ['.gif','.jpg','.jpeg','.png']
        if microarticle.url[-4:] in image_formats:
            page.send(recipient_id, Attachment.Image(str(microarticle.url)))
        elif microarticle.url[-4:] == ".gifv":
            page.send(recipient_id, Attachment.Video(str(microarticle.url)))
        else:
            page.send(recipient_id, Attachment.Image(str(microarticle.url)))

    elif microarticle_type == "video":
        page.send(recipient_id, Attachment.Video(str(microarticle.url)))

    elif microarticle_type == "article":
        print("[i] Response:")
        pprint.pprint(response)
        page.send(recipient_id, Template.Generic([
            Template.GenericElement(microarticle.title,
                                    subtitle= response[0].get('subtitle'),
                                    item_url= microarticle.url,
                                    image_url= microarticle.thumbnail,
                                    buttons=[
                                        Template.ButtonShare(),
                                        Template.ButtonWeb("Open Web URL", microarticle.url)
                                    ]),
        ]))

    print("[i] Response sent...")
    return "success"
コード例 #6
0
def send_generic_program(recipient, data):
    data = urllib.parse.quote_plus(data)
    response = requests.get('https://uos.edu.pk/about/bot_program/' + data)
    result = response.json()
    if result:
        send_message(recipient, 'Duration : ' + result[0]['duration'])
        send_message(recipient, 'Credit Hours ' + result[0]['credit_hour'])
        send_message(recipient, 'Eligibility ' + result[0]['requirement'])
        page.send(
            recipient,
            Template.Buttons(result[0]['name'], [
                Template.ButtonWeb(
                    "See More Detail",
                    "https://uos.edu.pk/department/academic_programs/" +
                    result[0]['dpartment']),
                Template.ButtonWeb(
                    "Prospectus Jump",
                    "https://uos.edu.pk/uploads/faculties/covers/" +
                    result[0]['scheme_file']),
                Template.ButtonWeb(
                    "Scheme of Study",
                    "https://uos.edu.pk/uploads/faculties/schemes/" +
                    result[0]['detail_scheme'])
            ]))
    else:
        send_message(recipient, 'Sorry, but i am unable to Find' + data)
        send_typing_off(recipient)
コード例 #7
0
def receipts(payload, event):
    for i in previous_orders:
        element = Template.ReceiptElement(title=i['title'],
                                          subtitle=i['subtitle'],
                                          quantity=i['quantity'],
                                          price=200,
                                          currency="USD",
                                          image_url=i['image_url'])

        address = Template.ReceiptAddress(street_1=i['street_1'],
                                          street_2=i['street_2'],
                                          city=i['city'],
                                          postal_code=i['postal_code'],
                                          state=i['state'],
                                          country=i['country'])

        summary = Template.ReceiptSummary(subtotal=200,
                                          shipping_cost=5,
                                          total_tax=10,
                                          total_cost=215)
        adjustment = Template.ReceiptAdjustment(name=i['name'], amount=1308)

        page.send(
            event.sender_id,
            Template.Receipt(recipient_name=i['receipt_name'],
                             order_number=i['order_number'],
                             currency="USD",
                             payment_method='visa',
                             timestamp="1428444852",
                             elements=[element],
                             address=address,
                             summary=summary,
                             adjustments=[adjustment]))
コード例 #8
0
def Intents_parser(receivedent, user):
    if receivedent['intent'][0]['value'] == "department_info":
        return department_info(receivedent, user)
    elif receivedent['intent'][0]['value'] == "faculty_profile":
        if first_entity_value(receivedent, 'department_name'):
            send_generic_faculty(user, receivedent['faculty_name'][0]['value'],
                                 receivedent['department_name'][0]['value'])
            return "Here you go"
        else:
            send_generic_faculty(user, receivedent['faculty_name'][0]['value'])
            return "Here you go"
    elif receivedent['intent'][0]['value'] == "admission_info":
        page.send(
            user,
            Template.Buttons('Admissions', [
                Template.ButtonWeb(
                    "Private Admissions",
                    "https://uos.edu.pk/examination/Admissions_Schedule"),
                Template.ButtonWeb(
                    "Regular Admissions",
                    "https://admissions.uos.edu.pk/importantdates")
            ]))
        return "Here you can Find All Admisison Related Info"
    elif receivedent['intent'][0]['value'] == "merit_info":
        page.send(
            user,
            Template.Buttons('Merit Info', [
                Template.ButtonWeb("Merit Lists",
                                   "https://uos.edu.pk/examination/merits")
            ]))
        return "Here you can Find All info Related To Merit"
    elif receivedent['intent'][0]['value'] == "junk":
        return "that was the junk"
    else:
        return "nothing but intents"
コード例 #9
0
def echo_messege(recipient):
    page.send(recipient,
              "Would you like to book a hotel room?",
              quick_replies=[
                  QuickReply(title=("Book a room"), payload="START_AGAIN"),
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #10
0
def send_message(recipient_id, text):
    # If we receive a text message, check to see if it matches any special
    # keywords and send back the corresponding example. Otherwise, just echo
    # the text we received.
    special_keywords = {
        "image": send_image,
        "gif": send_gif,
        "audio": send_audio,
        "video": send_video,
        "file": send_file,
        "button": send_button,
        "generic": send_generic,
        "receipt": send_receipt,
        "quick reply": send_quick_reply,
        "read receipt": send_read_receipt,
        "typing on": send_typing_on,
        "typing off": send_typing_off,
        "account linking": send_account_linking
    }

    if text in special_keywords:
        special_keywords[text](recipient_id)
    else:
        page.send(recipient_id,
                  text,
                  callback=send_text_callback,
                  notification_type=NotificationType.REGULAR)
コード例 #11
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]))
コード例 #12
0
def callback_clicked_subs(payload, event):
    sender_id = event.sender_id
    subs = db.get_subscriptions(sender_id)
    if subs:
        page.send(sender_id, "YOUR SUBS:\n" + "\n".join(subs))
    else:
        handle_unsub(sender_id)
コード例 #13
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

    send_typing_on(sender_id)
    send_read_receipt(sender_id)

    if message_text:
        print("Topic= ", bot.get_uservar(sender_id, "topic"))
        if quick_reply:
            entrada_usuario = event.quick_reply_payload.replace('PICK_', '')
        else:
            entrada_usuario = message_text
        res_bot = bot.reply(sender_id, elimina_tildes(entrada_usuario))
        res_ejem = re.search('¿[Qq]uieres.*', res_bot)
        res_topic = re.search(
            '[Cc]u[aá]l(?:es)? de los (?P<topico>.*) (?:te interesa|quieres) '
            'repasar', res_bot)
        res_tema = re.search(
            '[Cc]u[aá]l (?P<tema>.*) (?:(?:es el que\s?)?quieres|te interesan|'
            'saber m[aá]s)(?:\slos)? (?:ejemplos)?', res_bot)
        if res_topic:
            send_quick_reply(
                sender_id, res_bot,
                genera_quick_replies(topicos[elimina_tildes(
                    res_topic.group('topico').replace(' ', '_'))]))
        elif res_tema:
            send_quick_reply(
                sender_id, res_bot,
                genera_quick_replies(topicos[elimina_tildes(
                    res_tema.group('tema').replace(' ', '_'))]))
        elif res_ejem:
            send_quick_reply(sender_id, res_bot,
                             genera_quick_replies(["si", "no"]))
        else:
            page.send(sender_id, res_bot)
            entrada_usuario = message_text
        res_bot = bot.reply(sender_id, elimina_tildes(entrada_usuario))
コード例 #14
0
def send_generic_faculty(recipient, data, dep=""):
    data = urllib.parse.quote_plus(data)
    dep = urllib.parse.quote_plus(dep)
    if (dep):
        response = requests.get('https://uos.edu.pk/about/bot_faculty/' +
                                data + "/" + dep)
        result = response.json()
        if result:
            page.send(
                recipient,
                Template.Generic([
                    Template.GenericElement(
                        result[0]['name'],
                        subtitle=result[0]['designation'],
                        item_url="https://uos.edu.pk/faculty/profile/" +
                        result[0]['username'],
                        image_url="https://uos.edu.pk/uploads/faculty/profiles/"
                        + result[0]['picture'],
                        buttons=[
                            Template.ButtonWeb(
                                "Open Profile",
                                "https://uos.edu.pk/faculty/profile/" +
                                result[0]['username']),
                            Template.ButtonPhoneNumber("Contact",
                                                       '+92 48 9230879')
                        ])
                ]))
        else:
            send_message(
                recipient,
                'Sorry, but i am unable to Find' + data + " in " + dep)
            send_typing_off(recipient)
    else:
        response = requests.get('https://uos.edu.pk/about/bot_faculty/' + data)
        result = response.json()

        if result:
            page.send(
                recipient,
                Template.Generic([
                    Template.GenericElement(
                        result[0]['name'],
                        subtitle=result[0]['designation'],
                        item_url="https://uos.edu.pk/faculty/profile/" +
                        result[0]['username'],
                        image_url="https://uos.edu.pk/uploads/faculty/profiles/"
                        + result[0]['picture'],
                        buttons=[
                            Template.ButtonWeb(
                                "Open Profile",
                                "https://uos.edu.pk/faculty/profile/" +
                                result[0]['username']),
                            Template.ButtonPhoneNumber("Contact",
                                                       '+92 48 9230879')
                        ])
                ]))
        else:
            send_message(recipient, 'Sorry, but i am unable to Find' + data)
            send_typing_off(recipient)
コード例 #15
0
def purchase_item(recipient):
    page.send(recipient,
              "What item would you like to purchase?",
              quick_replies=[
                  QuickReply(title=("Sneakers 👟"), payload="BUY_SNEAKERS"),
                  QuickReply(title=("Jeans 👖"), payload="BUY_JEANS"),
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #16
0
def send_welcome_messege(recipient, event):
    user_profile = page.get_user_profile(event.sender_id)  # return dict
    print(user_profile)

    text1 = "Hello " + user_profile['first_name'] + "!"
    text2 = "Welcome to the Hotel Test Bot. We have a list of hotel branches below. Please choose one. 🙂"
    page.send(recipient, text1, metadata="DEVELOPER_DEFINED_METADATA")
    page.send(recipient, text2, metadata="DEVELOPER_DEFINED_METADATA")
コード例 #17
0
def select_room_message(recipient, event):
    user_profile = page.get_user_profile(event.sender_id)  # return dict
    print(user_profile)

    text1 = "Good Choice " + user_profile['first_name']
    text2 = "Please select your preferred room."
    page.send(recipient, text1, metadata="DEVELOPER_DEFINED_METADATA")
    page.send(recipient, text2, metadata="DEVELOPER_DEFINED_METADATA")
コード例 #18
0
ファイル: server.py プロジェクト: torst/Briefly
def start_callback(payload, event):
    sender_id = event.sender_id
    quick_replies = [
            QuickReply(title="Yeah !", payload="PICK_SYNC"),
            QuickReply(title="Nah ", payload="PICK_DSYNC")
            ]
    page.send(sender_id, "Would you like to sync this conversation ?\n you can subscribe etc. ",quick_replies=quick_replies,metadata="DEVELOPER_DEFINED_METADATA")
    print("Let's start!")
コード例 #19
0
def notify(new, restock):
    if new:
        for user in db.get_table("Users", "fb_id"):
            page.send(user, "NEW ITEMS\n"+"\n".join(new))
        print("Notified all users")
    
    for sub in restock.keys():
        page.send(sub, "RESTOCK:\n"+"\n".join(list(zip(*restock[sub]))[1]))
コード例 #20
0
def bot_ask_participation(recipient, question):
    page.send(recipient,
              question,
              quick_replies=[
                  QuickReply(title="OK", payload="PICK_OK"),
                  QuickReply(title="No thanks", payload="PICK_NO")
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #21
0
def start_again(recipient):
    page.send(recipient,
              "Would you like to view more items? 🙂",
              quick_replies=[
                  QuickReply(title=("Cancel"), payload="CANCEL"),
                  QuickReply(title=("View More"), payload="VIEW_MORE")
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #22
0
ファイル: server.py プロジェクト: team-anything/highOnBot
def callback_clicked_button(payload, event):
    sender_id = event.sender_id
    news_id = int(payload[25:])  # bug
    print(dummy)
    print(news_id)
    # do something with these text   -> To add Headline
    page.send(sender_id, Attachment.Image(image_url))
    page.send(sender_id, summ_ary)
コード例 #23
0
def view_more(recipient, event):
    user_profile = page.get_user_profile(event.sender_id)  # return dict
    print(user_profile)
    page.send(recipient,
              quick_replies=[
                  QuickReply(title=("Sneakers 👟"), payload="BUY_SNEAKERS"),
                  QuickReply(title=("Jeans 👖"), payload="BUY_JEANS"),
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #24
0
def callback_clicked_rem(payload, event):
    sender_id = event.sender_id
    if db.change_state(sender_id, 1):
        page.send(
            sender_id,
            "Insert product name. Make sure name is exact (Press 'Current Products' to see product list)"
        )
    else:
        handle_unsub(sender_id)
コード例 #25
0
def manejar_saludo(sender_id, nombre_usuario):
    if bot.get_uservar(sender_id, 'nombre') is None:
        mensaje = "Parece que es la primera vez que vienes por aquí.\n" \
                  "¡Te doy la bienvenida como tu asesor de inglés!"
    else:
        mensaje = "¡Qué gusto volver a verte!\n" \
                  "¿Cómo estás el día de hoy?"
    bot.set_uservar(sender_id, 'nombre', nombre_usuario)
    page.send(sender_id, "Hola, " + nombre_usuario + ".\n" + mensaje)
コード例 #26
0
def hello(recipient):
    page.send(recipient, "Hi! 😄")
    page.send(recipient,
              "What would you like to buy?",
              quick_replies=[
                  QuickReply(title=("Sneakers 👟"), payload="BUY_SNEAKERS"),
                  QuickReply(title=("Jeans 👖"), payload="BUY_JEANS"),
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #27
0
ファイル: server.py プロジェクト: team-anything/highOnBot
def callback_picked_genre(payload, event):
    sender_id = event.sender_id
    if payload == "PICK_CONF":
        page.send(
            sender_id,
            "Please Share your credentials \n ( format id: username hostname password ) "
        )  # TODO
    else:
        page.send(sender_id, "Go ahead ;) Play Around for some time ")
コード例 #28
0
ファイル: server.py プロジェクト: team-anything/highOnBot
def callback_picked_genre(payload, event):
    sender_id = event.sender_id
    if payload == "PICK_SSH":
        page.send(
            sender_id,
            "Please Share your credentials \n ( format id: username hostname password ) "
        )  # TODO
    else:
        page.send(sender_id, "That's just fine")
コード例 #29
0
def initiate_feedback():
    for p in models.select_participants():
        page.send(p.fb_id,
                  "We would appreciate your feedback!",
                  quick_replies=[
                      QuickReply(title="Okay", payload="PICK_OK"),
                      QuickReply(title="I'm busy", payload="PICK_NO")
                  ],
                  metadata="DEVELOPER_DEFINED_METADATA")
コード例 #30
0
def send_button(recipient):
    page.send(
        recipient,
        Template.Buttons("hello", [
            Template.ButtonWeb("Open Web URL",
                               "https://www.oculus.com/en-us/rift/"),
            Template.ButtonPostBack("trigger Postback",
                                    "DEVELOPED_DEFINED_PAYLOAD"),
            Template.ButtonPhoneNumber("Call Phone Number", "+16505551234")
        ]))
コード例 #31
0
def send_quick_reply_program(recipient):
    page.send(recipient,
              "Here are some suggestion, if you wanna choose",
              quick_replies=[
                  QuickReply(title="BSCS", payload="bscs"),
                  QuickReply(title="BSIT", payload="bsit"),
                  QuickReply(title="BSSE", payload="bsse"),
                  QuickReply(title="MSCS", payload="mscs")
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #32
0
def last_messege(recipient):
    page.send(recipient,
              "Would you like to continue?",
              quick_replies=[
                  QuickReply(title=("Book another room"),
                             payload="BOOK_ANOTHER_ROOM"),
                  QuickReply(title=("Cancel"), payload="CANCEL"),
                  QuickReply(title=("Start Again"), payload="START_AGAIN")
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #33
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
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")
コード例 #34
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
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")
コード例 #35
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_button(recipient):
    """
    Shortcuts are supported
    page.send(recipient, Template.Buttons("hello", [
        {'type': 'web_url', 'title': 'Open Web URL', 'value': 'https://www.oculus.com/en-us/rift/'},
        {'type': 'postback', 'title': 'tigger Postback', 'value': 'DEVELOPED_DEFINED_PAYLOAD'},
        {'type': 'phone_number', 'title': 'Call Phone Number', 'value': '+16505551234'},
    ]))
    """
    page.send(recipient, Template.Buttons("hello", [
        Template.ButtonWeb("Open Web URL", "https://www.oculus.com/en-us/rift/"),
        Template.ButtonPostBack("trigger Postback", "DEVELOPED_DEFINED_PAYLOAD"),
        Template.ButtonPhoneNumber("Call Phone Number", "+16505551234")
    ]))
コード例 #36
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def start_callback(payload, event):
    """Quick replies have a 20 character limit!
    """
    recipient = event.sender_id
    page.send(recipient, "i cant help with everything, but i can help you do something")
 
    # only 20 characters text in quick replies...
    page.send(recipient, "what is your particular shame today?",
              quick_replies=[
                  {'title': 'procrastination', 'payload': 'PICK/PROCRASTINATION'},
                  {'title': 'my mediocrity', 'payload': 'PICK/MY_MEDIOCRITY'},
                  {'title': 'just overwhelmed', 'payload': 'PICK/JUST_OVERWHELMED'},
                  {'title': 'so distracted', 'payload': 'PICK/SO_DISTRACTED'},
              ],
              metadata="DEVELOPER_DEFINED_METADATA")
コード例 #37
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
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("tigger Postback", "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': 'tigger Postback',
                                     'value': 'DEVELOPED_DEFINED_PAYLOAD'},
                                    {'type': 'phone_number', 'title': 'Call Phone Number', 'value': '+16505551234'},
                                ])
    ]))
コード例 #38
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
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("received_message: Ignore duplicated request, seq_id %s seq %s" % (seq_id, seq))
        print(USER_SEQ)
        return None
    else:
        USER_SEQ[seq_id] = seq

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

#        page.send(sender_id, "Quick reply tapped")

    if message_text:
 #       send_message(sender_id, message_text)
        pass
    elif message_attachments:
        page.send(sender_id, "Message with attachment received")
コード例 #39
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
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))
コード例 #40
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_image(recipient):
    page.send(recipient, Attachment.Image(CONFIG['SERVER_URL'] + "/assets/rift.png"))
コード例 #41
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_gif(recipient):
    page.send(recipient, Attachment.Image(CONFIG['SERVER_URL'] + "/assets/instagram_logo.gif"))
コード例 #42
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_audio(recipient):
    page.send(recipient, Attachment.Audio(CONFIG['SERVER_URL'] + "/assets/sample.mp3"))
コード例 #43
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_video(recipient):
    page.send(recipient, Attachment.Video(CONFIG['SERVER_URL'] + "/assets/allofus480.mov"))
コード例 #44
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_text_message(recipient, text):
    page.send(recipient, text, metadata="DEVELOPER_DEFINED_METADATA")
コード例 #45
0
ファイル: messenger.py プロジェクト: pfctdayelise/archy
def send_file(recipient):
    page.send(recipient, Attachment.File(CONFIG['SERVER_URL'] + "/assets/test.txt"))