Exemple #1
0
def template_cart_products(sender_id):
    cart = Cart.get_cart(sender_id)
    products = cart.get_products()
    pprint(products)
    templates = []
    if len(products) == 0:
        navigation = [QuickReply("explore categories", "SHOW_CATEGORIES")]
        print("template_cart_products()")
        page.send(sender_id,
                  "your cart is empty, continue exploring",
                  quick_replies=navigation)

    else:
        for product in products:
            print(product.product_id)
            print(product.quantity)

            # refactor it :'(
            product_ = Product.query.filter_by(id=product.product_id).first()
            payload = "REMOVE_FROM_CART|" + str(product.product_id)
            print("========>", payload)
            template = Template.GenericElement(
                product_.name,
                subtitle=str(product_.price) + "৳ (x" + str(product.quantity) +
                ")",
                image_url=product_.img_url,
                buttons=[
                    Template.ButtonPostBack("Remove From Cart", payload),
                    Template.ButtonPostBack("Checkout!", "CHECKOUT")
                ])
            templates.append(template)

        page.send(sender_id, Template.Generic(templates))
Exemple #2
0
def callback_picked_genre(payload, event):
    global profile
    sender_id = event.sender_id
    count = 1
    cartSum = 0
    text = ''
    if len(profile[sender_id].orderDetail):
        for i in profile[sender_id].orderDetail:
            item = i.split(',')
            text += str(count) + ".\n商品名稱:" + item[1] + "\n顏色尺寸:" + item[
                2] + "\n數量:" + item[3] + "\n金額小計:" + str(
                    int(item[3]) * int(item[4]))
            text += '\n-------------\n'
            count = count + 1
            cartSum += int(item[3]) * int(item[4])
        text += '運費:$60\n總金額:' + str(60 + cartSum)
    page.send(sender_id, text)
    page.send(
        sender_id,
        Template.Generic([
            Template.GenericElement(
                '商品清單',
                buttons=[
                    Template.ButtonPostBack('商品詢問', "query1"),
                    Template.ButtonPostBack('送出訂單', "deal")
                ])
        ]))
Exemple #3
0
def show_persistent_menu():
    page.show_persistent_menu([
        Template.ButtonPostBack('Subscriptions', 'MENU_PAYLOAD/subscriptions'),
        Template.ButtonPostBack('Current Features',
                                'MENU_PAYLOAD/GET_STARTED'),
        Template.ButtonPostBack('Health and Wellness', 'MENU_PAYLOAD/health')
    ])
    return "Done with persistent menu section"
Exemple #4
0
def webhook():
    payload = request.get_data(as_text=True)
    print(payload)
    page.show_persistent_menu([Template.ButtonPostBack('SUB_LIST1', 'MENU_PAYLOAD/1'),
                           Template.ButtonPostBack('SUB_LIST2', 'MENU_PAYLOAD/2')])
    page.handle_webhook(payload,message = message_handler)

    return "ok"
def fb_receive_message():
    message_entries = json.loads(request.data.decode('utf8'))['entry']
    for entry in message_entries:
        for message in entry['messaging']:
            if message.get('message'):
                user_id = "{sender[id]}".format(**message)
                text = "{message[text]}".format(**message)
                res = bt.response(text, user_id)
                if res == "De rien":
                    client.send_image(user_id, conf.deRien)
                elif res == "merci":
                    client.send_image(user_id, conf.happy)
                elif res == "no":
                    client.send_image(user_id, conf.angry)
                elif res == "ah":
                    client.send_image(user_id, conf.bored)
                elif res == "quoi":
                    client.send_image(user_id, conf.busy)
                elif res == "lol":
                    client.send_image(user_id, conf.grand)
                elif (res == "ok"):
                    page.send(
                        user_id,
                        Template.Generic([
                            Template.GenericElement(
                                "rift",
                                subtitle="Next-generation virtual reality",
                                item_url="https://www.oculus.com/en-us/rift/",
                                image_url=conf.deRien,
                                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=conf.deRien,
                                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")
                                ])
                        ]))
                else:
                    client.send_text(user_id, res)
    return "Ok"
Exemple #6
0
def init():
    global page
    TABOT_ACCESS_TOKEN = "EAANbYW2bhcwBAHprKcgSrs86S3MFVdVv37auFZBAo4EPzAMTjKNDQuLj9227ai1Agbryvs2QXcHQgf7vHs2Xv0YynvT7XDo4wPAjSHabFyvbJVQfkUkZCJP7PZBRZBcLctaT7MG0aDSJDFZCBbnxcfR8KB48i9YAWLiIAmSmRevoiIfLGWUIY"
    page = Page(TABOT_ACCESS_TOKEN)
    page.show_starting_button("GET_START")
    page.greeting(
        "Hi {{user_first_name}}! TaBot is Messenger Bot to help you know more about Celcom Prepaid Package. Let's Get Started!"
    )
    page.show_persistent_menu([
        Template.ButtonPostBack("Available command ⚛️", 'COMMAND'),
        Template.ButtonWeb("Celcom website 📱", "https://www.celcom.com.my"),
        Template.ButtonPostBack("tabot", 'START')
    ])
def send_Aguascalientes(recipient):
    page.send(recipient, "¿En cuál de nuestros hoteles te gustaría hospedarte?")
    page.send(recipient, Template.Generic([
        Template.GenericElement("Hotel Ibis",
                                subtitle="Haz tu reservación en Hotel Ibis",
                                image_url=CONFIG['SERVER_URL'] + "/assets/hotel_ibis_aguascalientes.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "hotel_ibis")
                                ]),
        Template.GenericElement("Hotel Francia Aguascalientes",
                                subtitle="Haz tu reservación en Hotel Francia",
                                image_url=CONFIG['SERVER_URL'] + "/assets/hotel_francia_aguascalientes.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "hotel_francia")
                                ])
    ]))
def callback_picked_dept(payload, event, data, raw_data, page):
    sender_id = event.sender_id
    message = payload.split('_')[1]
    print(message)
    tech_idx = data[0].index('technical')
    if message.lower() in [dept for dept in data[1][tech_idx]]:
        dept_idx = data[1][tech_idx].index(message)
        generic_template = []
        for event in data[2][dept_idx]:
            generic_template.append(
                Template.GenericElement(
                    event,
                    subtitle=data[1][tech_idx][dept_idx] + ' - ' +
                    raw_data['technical'][dept_idx]['alis'],
                    image_url=get_icon_from_name(
                        raw_data['technical'][dept_idx]['events'][
                            data[2][dept_idx].index(event)]['name']),
                    buttons=[
                        Template.ButtonPhoneNumber(
                            "Contact", '+91' + raw_data['technical'][dept_idx]
                            ['events'][data[2][dept_idx].index(
                                event)]['managers'][0]['phone']),
                        Template.ButtonPostBack('Details', "TECH_" + event)
                    ]))
        page.send(sender_id, Template.Generic(generic_template))
Exemple #9
0
def challenge(turn, total_turn, mark, sender_id):
    if turn == 0:
        with open("resource/questions.json") as f:
            questions = json.load(f)
    else:
        with open("questions.pickle", 'rb') as pinfile:
            questions = pickle.load(pinfile)
    random_question = sample(questions, 1)

    question = random_question[0]["question"]
    choices = random_question[0]["choices"]
    answer = random_question[0]["answer"]
    print("question: ", question)
    for i in questions:
        if i["question"] == question:
            questions.remove(i)
    with open("questions.pickle", "wb") as poutfile:
        pickle.dump(questions, poutfile)
    print("questions: ", questions)
    buttons = []
    for i in range(len(choices)):
        buttons.append(
            Template.ButtonPostBack(
                choices[i],
                str(turn) + "_" + str(total_turn) + "_" + str(i) + "_" +
                str(answer) + "_" + str(mark)))
    g_page.send(sender_id, Template.Buttons(question, buttons))
Exemple #10
0
def template_cart_items(user_id):
    cart_id = Cart.query.filter_by(user_id=user_id).first().id
    cart_item_query = Cart_item.query.filter_by(cart_id=cart_id).all()

    elements = []

    for item in cart_item_query:
        item_id = item.item_id
        quantity = item.quantity

        print(item_id)
        print(quantity)

        item = Item.query.filter_by(id=item_id).first()

        payload = "REMOVE_FROM_CART_|" + str(cart_id) + "|" + str(item.id)
        print("------->", payload)
        element = Template.GenericElement(
            item.name,
            subtitle=str(item.price) + "৳ (x" + str(quantity) + ")\r\n" +
            item.description,
            image_url=item.thumb_urls,
            buttons=[Template.ButtonPostBack("Remove from cart", payload)])
        elements.append(element)

    isNull = False
    if not elements: isNull = True

    return [Template.Generic(elements, True), isNull]
Exemple #11
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")
        ]))
Exemple #12
0
def callback_picked_genre(payload, event):
    global profile
    sender_id = event.sender_id
    user_profile = page.get_user_profile(event.sender_id)
    count = 1
    cartSum = 0
    text = ''
    if len(profile[sender_id].orderDetail):
        for i in profile[sender_id].orderDetail:
            item = i.split(',')
            text += str(count) + ".\n商品名稱:" + item[1] + "\n顏色尺寸:" + item[
                2] + "\n數量:" + item[3] + "\n金額小計:" + str(
                    int(item[3]) * int(item[4]))
            text += '\n-------------\n'
            count = count + 1
            cartSum += int(item[3]) * int(item[4])
        text += '運費:$60\n總金額:' + str(60 + cartSum)
        page.send(sender_id, text)
        page.send(
            sender_id,
            Template.Generic([
                Template.GenericElement(
                    '是否購買',
                    buttons=[
                        Template.ButtonPostBack('送出訂單', "deal"),
                        Template.ButtonPostBack('繼續購物', "continueBuy")
                    ])
            ]))
    else:
        text = '購物車還是空的呢~\n快去購物吧!!'
        page.send(
            sender_id,
            Template.Generic([
                Template.GenericElement(
                    text,
                    buttons=[
                        Template.ButtonPostBack('商品詢問', "query1"),
                        Template.ButtonPostBack('訂購商品', "order1"),
                        Template.ButtonPostBack('查看購物車', "Cart")
                    ])
            ]))
def build_template(image, title, subtitle, url=None, postback=None):
    buttons = []
    if url:
        buttons.append(Template.ButtonWeb(url["text"], url["content"]))
    if postback:
        buttons.append(
            Template.ButtonPostBack(postback["text"], postback["content"]))
    return Template.GenericElement(title,
                                   subtitle=subtitle,
                                   image_url=image,
                                   item_url=url,
                                   buttons=buttons)
Exemple #14
0
def callback_clicked_button(payload, event):
    sender_id = event.sender_id
    message = payload.replace('product', '')
    if profile[sender_id].query_price == True or profile[sender_id].buy == True:
        if message in allProduct.keys():
            profile[sender_id].product_price = allProduct[message][3]
            page.send(sender_id, "商品敘述:" + allProduct[message][7])
            page.send(
                sender_id,
                Template.Generic([
                    Template.GenericElement(
                        message,
                        subtitle="商品價格:" + profile[sender_id].product_price,
                        buttons=[
                            Template.ButtonPostBack("我要訂購", "wantToBuy"),
                            Template.ButtonPostBack("我考慮一下", "ddd")
                        ])
                ]))
            # page.send(sender_id, "這個商品的價格為:"+allProduct[message][3])
            # text = '是否購買此商品~'
            profile[sender_id].product_Name = message
Exemple #15
0
def template_items(category):
    items = Item.query.filter_by(cat_id=category)
    elements = []
    for item in items:
        payload = "ADD_CART_|" + str(item.id)
        print("------->", payload)
        element = Template.GenericElement(
            item.name,
            subtitle=str(item.price) + "৳\r\n" + item.description,
            image_url=item.thumb_urls,
            buttons=[Template.ButtonPostBack("Add to Cart", payload)])
        elements.append(element)
    return Template.Generic(elements, True)
Exemple #16
0
def template_products(category_id):
    category = Category.query.get(category_id)
    products = category.products

    templates = []
    for product in products:
        single_template = Template.GenericElement(
            product.name,
            subtitle=str(product.price),
            image_url=product.img_url,
            buttons=[
                Template.ButtonPostBack("View Description",
                                        payload="PRODUCT_DESCRIPTION|" +
                                        str(product.id)),
                Template.ButtonPostBack("Purchase",
                                        payload="ADD_TO_CART|" +
                                        str(product.id))
            ])
        templates.append(single_template)

    # below one is different from products`
    return templates  # TODO: TRUE OF FALSE for square image, need to check what that is
Exemple #17
0
def template_categories():
    categories = Category.query.all()
    elements = []
    for category in categories:
        payload = "SHOW_ITEM_|" + str(category.id)
        print("------->", payload)
        element = Template.GenericElement(
            category.name,
            subtitle=category.description,
            image_url=category.thumb_urls,
            buttons=[Template.ButtonPostBack("Show Products", payload)])
        elements.append(element)
    return Template.Generic(elements)
Exemple #18
0
def received_postback(event):
    global profile
    sender_id = event.sender_id
    payload = event.postback_payload
    user_profile = page.get_user_profile(event.sender_id)  # return dict

    ## 讓機器人在使用者傳送訊息後立刻已讀訊息並開啟輸入指示器(點點點符號)
    page.mark_seen(sender_id)
    page.typing_on(sender_id)

    ## 當使用者第一次打開機器人按下'開始使用'時
    if payload == 'START':
        text = 'Hi ' + user_profile[
            'first_name'] + ' 歡迎來到 龜 婦 の 生 活 😊\n您今天來到這裡有什麼能替您服務的嗎?'
        profile[sender_id] = User(sender_id, user_profile)
        page.send(
            sender_id,
            Template.Generic([
                Template.GenericElement(
                    "歡迎來到 龜 婦 の 生 活 😊\n您今天來到這裡有什麼能替您服務的嗎?",
                    buttons=[
                        Template.ButtonPostBack('商品詢問', "query1"),
                        Template.ButtonPostBack('訂購商品', "order1"),
                        Template.ButtonPostBack('查看購物車', "Cart")
                    ])
            ]))
    ## 當使用者按下選單中的'重新查詢'時
    elif payload == 'REFRESH':
        text = 'Hi ' + user_profile[
            'first_name'] + ' 歡迎來到 龜 婦 の 生 活 😊\n您今天來到這裡有什麼能替您服務的嗎?'
        page.send(sender_id,
                  text,
                  quick_replies=[{
                      'title': '商品詢問',
                      'payload': 'Y'
                  }, {
                      'title': '訂購商品',
                      'payload': 'Y'
                  }])
Exemple #19
0
def show_previous_orders(payload, event):
    a = []
    for i in previous_orders:
        a.append(
            Template.GenericElement(
                i['title'],
                subtitle=i['price'],
                #item_url=i["link"],
                image_url=i["image_url"],
                buttons=[
                    Template.ButtonPostBack('Check Receipt', 'RECEIPT'),
                    #Template.ButtonPostBack('Bookmark', "ADDTOBOOKMARK"),
                ]))
    page.send(event.sender_id, Template.Generic(a))
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")
    ]))
def send_menu(recipient_id):
    print('-----------------------------------------HOLI------SEND_MENU------------------------------------------------------')
    page.send(recipient_id, "Hola, soy hotelbot y estoy para servirte ;)")
    page.send(recipient_id, "Estos son los servicios con los que puedo ayudarte:")
    page.send(recipient_id, Template.Generic([
        Template.GenericElement("Promociones hoteles playa",
                                subtitle="Disfruta de unas vacaciones en el mar",
                                image_url=CONFIG['SERVER_URL'] + "/assets/playa5.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "hoteles_playa")
                                ]),
        Template.GenericElement("Promociones hoteles ciudad",
                                subtitle="Goza de un tour por la ciudad",
                                image_url=CONFIG['SERVER_URL'] + "/assets/city3.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "hoteles_ciudad")
                                ]),
        Template.GenericElement("Reservar una habitación",
                                subtitle="Descansa en una habitación de lujo",
                                image_url=CONFIG['SERVER_URL'] + "/assets/habitacion.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "reservar_habitacion")
                                ]),
        Template.GenericElement("Conocer hoteles cerca de ti",
                                subtitle="Encuentra un hotel a la medida",
                                image_url=CONFIG['SERVER_URL'] + "/assets/hotel.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "hoteles_cercanos")
                                ]),
        Template.GenericElement("Solicitar servicios dentro del hotel",
                                subtitle="Disfruta de nuestros servicios",
                                image_url=CONFIG['SERVER_URL'] + "/assets/servicioshotel.jpg",
                                buttons=[
                                    Template.ButtonPostBack("seleccionar", "servicios_hotel")
                                ])
    ]))
Exemple #22
0
def generate_summaries(name,sentences):
    # NOTE : we don't need to store summary , instead storing the links would be enough .

    articles = subscribe.subscribe_model(name)      # link , headline , date==None , image_url , sentences(list)
    if articles == None :
        return False
    results = []
    '''
    Set a "View More Articles" Option Over here instead of max_articles
    '''
    for article in articles:
        # breakpoint tests
        '''
        Issue : Default use of Generic Template <subtitle section> 60chars, <title section> 60 chars ,List view( No - Image ) 640 chars

        '''
        article_url = article[0]
        headline = article[1]
        publish_date = article[2]
        top_image_url  = article[3]
        summary_list = []
        concate_news = headline
        if len(article)==5:
            concate_news = article[4]

        # recheck TODO
        sum_keys = sorted(SUMMARIES.keys())

        if len(sum_keys) > max_local_summaries :
            del SUMMARIES[sum_keys[0]]

        if not len(sum_keys):
            hash_index = 0
        else:
            hash_index = sum_keys[-1]

        results.append(Template.GenericElement(headline,
                subtitle = name ,
                image_url = top_image_url,
                buttons=[
                        Template.ButtonWeb("Read More", article_url),
                        Template.ButtonPostBack("Summarize", "DEVELOPED_DEFINED_PAYLOAD" + str(hash_index+1)),    #     maybe a SHARE button ?
                            # Template.ButtonPhoneNumber("Call Phone Number", "+16505551234")
                        ])
                )
        SUMMARIES[hash_index+1] = [top_image_url,concate_news]
    print("reached Line:227")
    return results
Exemple #23
0
def show_hotel_room(recipient):
    page.send(
        recipient,
        Template.Generic([
            Template.GenericElement(
                "Seven Suns Hotel Template",
                subtitle="Basic Suite",
                item_url="https://sevensuns.com",
                image_url=
                "http://www.vhotel.sg/Bencoolen/scripts/images/accomodations/rooms/b_twin_display.jpg",
                buttons=[
                    # Template.ButtonWeb("Open Web URL", "https://www.oculus.com/en-us/rift/"),
                    Template.ButtonPostBack("Select Room", "SELECT_ROOM")
                    # Template.ButtonPhoneNumber("Call Branch", "+16505551234")
                ]),
            Template.GenericElement(
                "Seven Suns Hotel Template",
                subtitle="Deluxe Suite",
                item_url="https://sevensuns.com",
                image_url=
                "http://www.vhotel.sg/Bencoolen/scripts/images/accomodations/rooms/b_premier_display.jpg",
                buttons=[
                    # {'type': 'web_url', 'title': 'Open Web URL',
                    #  'value': 'https://www.oculus.com/en-us/rift/'},
                    {
                        'type': 'postback',
                        'title': 'Select Room',
                        'value': 'SELECT_ROOM'
                    },
                    # {'type': 'phone_number', 'title': 'Call Branch', 'value': '+16505551234'},
                ]),
            Template.GenericElement(
                "Seven Suns Hotel Template",
                subtitle="Premium Suite",
                item_url="https://sevensuns.com",
                image_url=
                "http://www.vhotel.sg/Bencoolen/scripts/images/accomodations/rooms/b_patio_display.jpg",
                buttons=[
                    # {'type': 'web_url', 'title': 'Open Web URL',
                    #  'value': 'https://www.oculus.com/en-us/rift/'},
                    {
                        'type': 'postback',
                        'title': 'Select Room',
                        'value': 'SELECT_ROOM'
                    },
                    # {'type': 'phone_number', 'title': 'Call Branch', 'value': '+16505551234'},
                ])
        ]))
Exemple #24
0
def callback_footwear(payload, event):
    a = []
    for i in footwear:
        a.append(
            Template.GenericElement(
                i['name'],
                subtitle=i['price'],
                item_url=i["link"],
                image_url=i["image"],
                buttons=[
                    Template.ButtonWeb("Open Web URL", i["link"]),
                    Template.ButtonWeb("Share", i["link"]),
                    #Template.ButtonPostBack('Bookmark', "ADDTOBOOKMARK"),
                    Template.ButtonPostBack('Buy', "BUY")
                ]))
    page.send(event.sender_id, Template.Generic(a))
Exemple #25
0
def show_shirts(result, sender_id):
    a = []
    for i in shirts:
        a.append(
            Template.GenericElement(
                i['name'],
                subtitle=i['price'],
                item_url=i["link"],
                image_url=i["image"],
                buttons=[
                    Template.ButtonWeb("Open Web URL", i["link"]),
                    Template.ButtonWeb("Share", i["link"]),
                    #Template.ButtonPostBack('Bookmark', "ADDTOBOOKMARK"),
                    Template.ButtonPostBack('Buy', "BUY")
                ]))
    page.send(sender_id, Template.Generic(a))
Exemple #26
0
def template_categories():
    categories = Category.query.all()
    templates = []
    print("is it working?")
    for category in categories:
        # FIXME: regex needs to be checked on double digit
        payload = "SHOW_PRODUCTS|" + str(category.id)
        print("PAYLOAAAAD: ", payload)
        single_template = Template.GenericElement(
            category.name,
            subtitle=category.description,
            image_url=category.img_url,
            buttons=[Template.ButtonPostBack("Show Products", payload)])
        templates.append(single_template)

    templates.reverse()

    return templates
Exemple #27
0
def matches_to_message(matches, recipient_id):
    message = []
    for match in matches:
        match_started = match.is_started
        title = str(match)
        if not match.subscriber_set.filter(subscriber_id=recipient_id).exists():
            subscribe_btn_title = "Theo dõi"
            subscribe_btn_payload = "SUBSCRIBE_MATCH_{}"
            subtitle = "Chọn nút \"Theo dõi\" để nhận cập nhật kết quả" if not match_started else match.statistics()
        else:
            subscribe_btn_title = "Bỏ theo dõi"
            subscribe_btn_payload = "UNSUBSCRIBE_MATCH_{}"
            subtitle = "Bạn đang theo dõi trận đấu này" if not match_started else match.statistics()

        subscribe_btn = Template.ButtonPostBack(subscribe_btn_title, subscribe_btn_payload.format(match.id))
        message.append(Template.GenericElement(title=title,
                                               subtitle=subtitle,
                                               buttons=[
                                                   subscribe_btn,
                                               ] if not match.is_ended else None))
    return Template.Generic(message)
Exemple #28
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("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'
                    },
                ])
        ]))
Exemple #29
0
def message_handler(event):
    """:type event: fbmq.Event"""
    sender_id = event.sender_id
    message = event.message_text

    # try Menu
    buttons = [
        Template.ButtonWeb("Open Web URL", "https://www.codeforces.com"),
        Template.ButtonPostBack("Subscribe", "www.nytimes.com"),
        Template.ButtonPhoneNumber("Call Phone Number", "+91")
    ]

    user_profile = page.get_user_profile(sender_id)

    page.typing_on(sender_id)
    page.typing_off(sender_id)

    #print(user_profile)
    if bot(message,sender_id):
        print("Bot results")
    else:
        page.send(sender_id,"Didn't get you ")
Exemple #30
0
def show_branch(recipient):
    page.send(
        recipient,
        Template.Generic([
            Template.GenericElement(
                "Seven Suns Hotel Template",
                subtitle="Nairobi Branch",
                item_url="https://sevensuns.com",
                image_url=
                "https://taj.tajhotels.com/content/dam/luxury/hotels/Taj_Mahal_Delhi/images/4x3/HotelFacade4x3.jpg",
                buttons=[
                    # Template.ButtonWeb("Open Web URL", "https://www.oculus.com/en-us/rift/"),
                    Template.ButtonPostBack("Select Branch", "SELECT_BRANCH"),
                    Template.ButtonPhoneNumber("Call Branch", "+16505551234")
                ]),
            Template.GenericElement(
                "Seven Suns Hotel Template",
                subtitle="Mombasa Branch",
                item_url="https://sevensuns.com",
                image_url=
                "https://www.safarihotelsnamibia.com/wp-content/uploads/2014/11/Safari-Court-Hotel-Pool.jpg",
                buttons=[
                    # {'type': 'web_url', 'title': 'Open Web URL',
                    #  'value': 'https://www.oculus.com/en-us/rift/'},
                    {
                        'type': 'postback',
                        'title': 'Select Branch',
                        'value': 'SELECT_BRANCH'
                    },
                    {
                        'type': 'phone_number',
                        'title': 'Call Branch',
                        'value': '+16505551234'
                    },
                ])
        ]))