Example #1
0
    def make_change(sender):
        responses = list()

        responses.append(Components.typing(responses, sender))
        template = GenericTemplate(elements=[
            Element(
                title="El Dolar Cotiza a 6,929 Bs.",
                subtitle="1 USD = 6,929 Bs.",
                default_action=URLButton(
                    url=
                    "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                ),
                buttons=[
                    URLButton(
                        title="VER OTRAS MONEDAS",
                        url=
                        "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                    )
                ])
        ])
        attachment = TemplateAttachment(template=template)
        component = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, component))
        return responses
Example #2
0
 def insufficient_balance(sender):
     responses = list()
     responses.append(Components.typing(responses, sender))
     template = GenericTemplate(elements=[
         Element(
             title="Saldo insuficiente para recargar",
             subtitle="Advertencia",
             buttons=[
                 URLButton(
                     title="OTRA RECARGA",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 ),
                 URLButton(
                     title="CANCELAR",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 )
             ])
     ])
     attachment = TemplateAttachment(template=template)
     component = Message(attachment=attachment)
     responses.append(Components.typing(responses, sender))
     responses.append(MessageRequest(sender, component))
     return responses
Example #3
0
 def make_recharge(sender):
     responses = list()
     responses.append(Components.typing(responses, sender))
     template = GenericTemplate(elements=[
         Element(
             title="Se Recargo con exito 50 Bs al 73053045",
             subtitle="Gracias por usar el servicio",
             buttons=[
                 URLButton(
                     title="INICIO",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 ),
                 URLButton(
                     title="HACER OTRA RECARGA",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 )
             ])
     ])
     attachment = TemplateAttachment(template=template)
     component = Message(attachment=attachment)
     responses.append(Components.typing(responses, sender))
     responses.append(MessageRequest(sender, component))
     return responses
Example #4
0
    def make_promotions(sender):
        """
        Envia la lista de promociones
        """
        promotions = None
        responses = list()
        elements = []

        # Mensaje
        message = Message(
            text="Esta es la lista de promociones esta semana :)", )
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))

        # Componente
        for promotion in promotions:
            element = Element(
                title=promotion.name,
                item_url=promotion.url,
                image_url=SERVER_URL + promotion.cover.url,
                subtitle=promotion.description,
                buttons=[URLButton(title="VER", url=promotion.url)])
            elements.append(element)
        template = GenericTemplate(elements=elements)

        attachment = TemplateAttachment(template=template)
        component = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, component))
        return responses
Example #5
0
    def make_own_tickets(sender):
        # tickets = Ticket.objects.all()
        tickets = list()
        responses = list()
        elements = []
        if tickets.count() > 0:
            # Mensaje
            message = Message(text="Estos son tus tickets", )
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))

            # Componente
            for ticket in tickets:
                lat, lng = Components.get_position(ticket.branch)
                if ticket.type == "CASH":
                    tty = "CAJA"
                else:
                    tty = "PLATAFORMA"

                element = Element(
                    title="%s: %s" % (tty, ticket.code),
                    subtitle="%s: %s" % (ticket.branch.bank.name, ticket.branch.name),
                    default_action=URLButton(
                        url=Components.get_map_url(lat, lng)
                    ),
                    buttons=[
                        PostbackButton(
                            title="CANCELAR",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "CANCEL_TICKET",
                                "id": ticket.id
                            }
                        ),
                        PostbackButton(
                            title="RENOVAR",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "REGENERATE_TICKET",
                                "id": ticket.id
                            }
                        )
                    ]
                )
                elements.append(element)
            template = GenericTemplate(
                elements=elements
            )

            attachment = TemplateAttachment(template=template)
            component = Message(attachment=attachment)
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, component))

        else:
            message = Message(text="No tienes tickets")
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))
        return responses
Example #6
0
def get_generic_template(sender):
    template = GenericTemplate(
        elements=[
            Element(
                title="Welcome to Peter\'s Hats",
                item_url="https://oepbolivia.xyz/",
                image_url="https://upload.wikimedia.org/wikipedia/en/5/5e/Avatar(Neytiri).jpg",
                subtitle="Weve got the right hat for everyone.",
                buttons=[
                    URLButton(
                        url="https://oepbolivia.xyz/",
                        title="View Website"
                    ),
                    PostbackButton(
                        title="Start Chatting",
                        payload="PAYLOAD"
                    )
                ]
            ),
            Element(
                title="HOLA MUNDO",
                item_url="https://oepbolivia.xyz/",
                image_url="https://goo.gl/wODF4W",
                subtitle="Weve got the right hat for everyone.",
                buttons=[
                    URLButton(
                        url="https://oepbolivia.xyz/",
                        title="View Website"
                    ),
                ]
            ),
            Element(
                title="TERCERA PARTE",
                item_url="https://oepbolivia.xyz/",
                image_url="https://goo.gl/wODF4W",
                subtitle="Weve got the right hat for everyone.",
            )

        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Example #7
0
def get_button_template(sender):

    template = ButtonTemplate(
        text='Que quieres hacer?',
        buttons=[
            URLButton(
                title='Show website',
                url='https://oepbolivia.xyz/'
            ),
            PostbackButton(
                title='Start chatting',
                payload='USER_DEFINED_PAYLOAD'
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Example #8
0
def get_list_template(sender):
    template = ListTemplate(
        style="large",
        elements=[
            ListElement(
                title="Classic T-Shirt Collection",
                image_url="https://goo.gl/tqQNHV",
                subtitle="See all our colors",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/shop_collection",
                    webview_height_ratio=URLButton.RATIO_TALL,
                ),
                buttons=[
                    URLButton(
                        title="View",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic T-Shirt Collection",
                image_url="https://goo.gl/JYkzoW",
                subtitle="100% Cotton, 200% Comfortable",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=100",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/shop?item=100",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic Blue T-Shirt",
                image_url="https://goo.gl/tqQNHV",
                subtitle="100% Cotton, 200% Comfortable",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=101",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic Black T-Shirt",
                image_url="https://goo.gl/W2J5rE",
                subtitle="See all our colors",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=102",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
        ],
        buttons=[
            PostbackButton(
                title="Ver mas",
                payload="UNDEFINED_PAYLOAD"
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)