コード例 #1
0
def offcampus_dining_request_msg(result,
                                 latitude=40.806209,
                                 longitude=-73.961733):
    """Interface function"""
    try:
        term = result['parameters']['off_campus_food']
    except:
        term = "boba"
    food_recs = get_recommendation_type(term, latitude, longitude)
    response = Template.List(elements=food_recs, top_element_style='large')
    return response
コード例 #2
0
def callback_clicked_tech(payload, event, data, raw_data, page):
    sender_id = event.sender_id
    message = payload.split('_')[1]
    print(message)
    category_idx = -1
    event_idx = -1

    for event_list in data[2]:
        for event_name in event_list:
            if event_name == message:
                category_idx = data[2].index(event_list)
                event_idx = event_list.index(event_name)

    if category_idx == -1:
        return

    event_raw_data = raw_data['technical'][category_idx]['events'][event_idx]
    print(event_raw_data)
    round_str = ''
    for n, my_round in enumerate(event_raw_data['rounds'], 1):
        round_str += 'Round ' + str(n) + ':'
        round_str += '\n' + str(my_round) + '\n\n'

    generic_list = [
        Template.GenericElement(title=event_raw_data['name'],
                                subtitle=event_raw_data['tagline'],
                                image_url=get_icon_from_name(
                                    event_raw_data['name'])),
        Template.GenericElement(title='Entry Fee: ',
                                subtitle=event_raw_data['fees'])
    ]

    if len(event_raw_data['managers']) == 0:  # If no manager exists
        managers = None
    else:
        managers = [
            Template.ButtonPhoneNumber(
                "Call Manager",
                "+91" + str(event_raw_data['managers'][i]['phone']))
            for i in range(0, len(event_raw_data['managers'])) if i < 1
        ]
    send_str = round_str

    page.send(
        sender_id,
        Template.List(elements=generic_list,
                      top_element_style='large',
                      buttons=managers))
    page.send(sender_id, send_str)
コード例 #3
0
ファイル: news.py プロジェクト: CesarERamosMedina/lionbot
def news_msg(result):
    """Interface Function for news intent"""
    campus_publication = ""
    news_result = []
    try:
        campus_publication = result['parameters']['club']
        campus_publication = campus_publication.lower()
    except:
        campus_publication = ""
        return "I couldn't get any news from the publication requested."

    if "bwog" in campus_publication:
        news_result = make_bwog_feed()
    elif "spectator" in campus_publication:
        news_result = make_spec_feed()
    else:
        news_result = make_lion_feed()
    #if no results returned
    if news_result == []:
        news_result = "I couldn't get any news updates from the publication requested."
    response = Template.List(elements=news_result, top_element_style='large')
    return response
コード例 #4
0
def send_active_resources(recipient_id="1491985787521789"):
    page = Page(FACEBOOK_TOKEN_3)
    news = []
    template = build_template(
        image="https://rapidpro.datos.gob.mx/media/FECHA_DE_PAGO.png",
        title="Proxima fecha de pago",
        subtitle="Te recordaremos cuando sea tu proxima fecha de pago",
        postback={
            "text": "Fecha de pago",
            "content": "PAYDAY"
        })
    news.append(template)
    template = build_template(
        image="https://rapidpro.datos.gob.mx/media/AHORRO.png",
        title="Ahorra",
        subtitle="Recibe informacion que te ayudara a ahorrar",
        postback={
            "text": "Ahorra",
            "content": "SAVING"
        })
    news.append(template)
    template = build_template(
        image="https://rapidpro.datos.gob.mx/media/BANSEFI.png",
        title="Bansefi mas cercano?",
        subtitle="Consulta tu banco mas cercano",
        postback={
            "text": "Conoce",
            "content": "BANSEFI"
        })
    news.append(template)
    page.send(
        recipient_id,
        Template.List(elements=news,
                      buttons=[{
                          "title": "No, gracias",
                          "type": "postback",
                          "payload": "ss"
                      }]))
コード例 #5
0
from fbmq import Template, QuickReply, ButtonPostBack

intro_reply = Template.List(elements=[
    Template.GenericElement("Columbia and Barnard Dining",
                          subtitle="I know dining halls menus and even special Dining events",
                          image_url="http://columbialion.com/wp-content/uploads/2017/04/diningbot.jpg"),
    Template.GenericElement("Campus News",
                          subtitle="News updates direct from The Lion, Bwog, and Spec",
                          image_url="http://columbialion.com/wp-content/uploads/2017/04/newsbot.png"),
    Template.GenericElement("Recommend places to eat",
                          subtitle="I can get you the perfect off-campus meal",
                          image_url="http://columbialion.com/wp-content/uploads/2017/04/offcampusdiningbot.jpg"),
    Template.GenericElement("Broadway Rush Policies",
                          subtitle="Want to find cheap Hamilton tickets? I have tips for that",
                          image_url="http://columbialion.com/wp-content/uploads/2017/04/broadwaybot.png")
], top_element_style='large', buttons=[])


mental_health_resources = Template.List(elements=[
    Template.GenericElement("Columbia Health Resources",
                          subtitle="Here are helpful resources for counseling at Columbia",
                          image_url="http://columbialion.com/wp-content/uploads/2017/04/wellnessbot.png"),
    Template.GenericElement("Counseling and Psychological Services",
                          subtitle="CPS offers counseling, consulation, and crisis intervention ",
                          item_url="https://health.columbia.edu/counseling-and-psychological-services",
                          image_url="https://mundaylab.umd.edu/wp-content/uploads/logo-columbia.png"),
    Template.GenericElement("Furman Counseling",
                          subtitle="Barnard's counseling center for its students",
                          item_url="https://barnard.edu/counsel",
                          image_url="https://barnard.edu/sites/default/files/styles/top_news_view__325x240_/public/barnard-b-blue-square-01.png?itok=tjdz2rnb")
], top_element_style='large', buttons=[])