Esempio n. 1
0
def showShopStyleResults(chat_id,from_user,context):
    api_json = context['text_query_result']
    result_image_urls = [value['image']['sizes']['IPhone']['url'] for value in api_json['products']]
    
    text_query_result_index = int(context['text_query_result_index'])
    i = 0
    if text_query_result_index+SHOW_THIS_MANY >= len(result_image_urls):
        message = "Well, maybe not. Gosh, you're hard to please :/ Try sending me back a pic of something I've showed you already to keep looking."
        sendSuggestedResponseHowTo(chat_id,from_user,message,context)
        return api_json
    urls=[]
    titles=[]
    for an_image in result_image_urls[text_query_result_index:]:
        if i >= SHOW_THIS_MANY:
            break
        title = api_json['products'][i]['brandedName']
        urls.append(an_image)
        titles.append(title)
        if context['platform'] == 'KIK':
            picture_message = PictureMessage(to=from_user, chat_id=chat_id, pic_url=an_image)
            picture_message.attribution = CustomAttribution(name=title)
            kik.send_messages([picture_message])

        i +=1
    if context['platform'] == 'FB':
        dispatchMessage(context,'image',chat_id,from_user,urls,suggested_responses=titles)
    context['text_query_result_index'] = i + text_query_result_index # remember which results we've showed
    context['text_query_result'] = api_json
    storeContext(chat_id,from_user,context,action='showShopStyleResults')
    if context['platform'] == 'KIK':
        selectAnImageMsg(chat_id,context)
        return api_json
Esempio n. 2
0
    def send_image_response(to, chat_id, album_art, album, keyboards=None):
        message = PictureMessage(to=to, chat_id=chat_id, pic_url=album_art)

        message.attribution = CustomAttribution(name=album)

        if keyboards:
            message.keyboards.append(
                SuggestedResponseKeyboard(hidden=True, responses=keyboards))

        kik.send_messages([message])
Esempio n. 3
0
    def send_image_response(to, chat_id, album_art, album, keyboards=None):
        message = PictureMessage(to=to, chat_id=chat_id, pic_url=album_art)

        message.attribution = CustomAttribution(
            name=album
        )

        if keyboards:
            message.keyboards.append(
                SuggestedResponseKeyboard(
                    hidden=True,
                    responses=keyboards
                )
            )

        kik.send_messages([
            message
        ])
Esempio n. 4
0
def showShopStyleResults(chat_id, from_user, context):
    api_json = context['text_query_result']
    result_image_urls = [
        value['image']['sizes']['IPhone']['url']
        for value in api_json['products']
    ]

    text_query_result_index = int(context['text_query_result_index'])
    i = 0
    if text_query_result_index + SHOW_THIS_MANY >= len(result_image_urls):
        message = "Well, maybe not. Gosh, you're hard to please :/ Try sending me back a pic of something I've showed you already to keep looking."
        sendSuggestedResponseHowTo(chat_id, from_user, message, context)
        return api_json
    urls = []
    titles = []
    for an_image in result_image_urls[text_query_result_index:]:
        if i >= SHOW_THIS_MANY:
            break
        title = api_json['products'][i]['brandedName']
        urls.append(an_image)
        titles.append(title)
        if context['platform'] == 'KIK':
            picture_message = PictureMessage(to=from_user,
                                             chat_id=chat_id,
                                             pic_url=an_image)
            picture_message.attribution = CustomAttribution(name=title)
            kik.send_messages([picture_message])

        i += 1
    if context['platform'] == 'FB':
        dispatchMessage(context,
                        'image',
                        chat_id,
                        from_user,
                        urls,
                        suggested_responses=titles)
    context[
        'text_query_result_index'] = i + text_query_result_index  # remember which results we've showed
    context['text_query_result'] = api_json
    storeContext(chat_id, from_user, context, action='showShopStyleResults')
    if context['platform'] == 'KIK':
        selectAnImageMsg(chat_id, context)
        return api_json