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
def make_schedules(sender): # Mensaje responses = list() message = Message( text= "¿Deseas agendar una cita con un asesor?, (y) Estas son las fechas disponibles" ) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) template = ListTemplate( style="compact", elements=[ ListElement( title="21 de Diciembre del 2016", image_url="https://s14.postimg.org/hn996fblp/date.jpg", subtitle="15:00 Hrs", buttons=[ PostbackButton(title="AGENDAR", payload="AGENDA_1") ], ), ListElement( title="15 de Enero del 2017", image_url="https://s14.postimg.org/hn996fblp/date.jpg", subtitle="19:00 Hrs.", buttons=[ PostbackButton(title="AGENDAR", payload="AGENDA_2") ], ) ]) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def make_number_phones(sender): print("pase x aqui") telephone_numbers = None responses = list() elements = [] if telephone_numbers.count() > 0: for telephone_number in telephone_numbers: text = TextReply( title=telephone_number.number, payload="VIEW_BRANCHES", image_url= 'http://www.teslasrl.net/imagenes/trabajos/ENTEL.jpg') elements.append(text) numbers = QuickReplies(replies=elements) message = Message(text="Estos son tus numeros ... ", quick_replies=numbers) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses else: message = Message(text="No tienes numeros registrados :(") responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def make_start(sender): # Mensaje responses = list() message = Message(text="Ya no mas filas en el banco") responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) template = ListTemplate( style="compact", elements=[ ListElement( title="GENERAR UN TICKET", image_url="https://s14.postimg.org/u9ohxgqsd/obtener.png", subtitle="Ahorra tiempo con tickets electrónicos", buttons=[ PostbackButton(title="OBTENER TICKET", payload="GET_TICKET") ], ), ListElement( title="MIS TICKETS", image_url= "https://s14.postimg.org/ea5udwuql/mistickets.png", subtitle="Administra los tickets pendientes que tienes", buttons=[ PostbackButton(title="VER MIS TICKETS", payload="MY_TICKETS") ], ) ]) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
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
def make_cancel_ticket(sender): responses = list() message = Message( text="Se ha cancelado el ticket que solicitaste :'(", ) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def get_video(sender): message = Message( attachment=VideoAttachment( url="https://www.dropbox.com/s/v5k3jqjpkhccfg7/developer.mp4?dl=1" ) ) return MessageRequest(sender, message)
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
def get_audio(sender): message = Message( attachment=AudioAttachment( url="https://www.dropbox.com/s/ymoqe9bzgvdx8d9/developer.mp3?dl=1" ) ) return MessageRequest(sender, message)
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
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
def recharge_amount(sender): responses = list() replies = QuickReplies(replies=[ TextReply( title="10", payload="VIEW_BRANCHES", ), TextReply( title="20", payload="VIEW_BRANCHES", ), TextReply( title="30", payload="VIEW_BRANCHES", ), TextReply( title="50", payload="VIEW_BRANCHES", ), TextReply( title="100", payload="VIEW_BRANCHES", ) ]) message = Message(text="Cuanto Deseas Recargar?", quick_replies=replies) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def make_distance(sender): responses = list() responses.append(Components.typing(responses, sender)) message = Message( text="Estas a 5km/10min caminando de distancia de la sucursal") responses.append(MessageRequest(sender, message)) return responses
def get(sender, resource): if resource in HELP_RESOURCES: url = HELP_RESOURCES[resource]["url"] else: url = DEFAULT_VIDEO message = Message(attachment=VideoAttachment(url=url)) return MessageRequest(sender, message)
def make_atms(sender): """ Envia la lista de Suscripciones de un usuario o la peticion para registrar una suscripción """ branches = None responses = list() elements = [] if branches.count() > 0: # Mensaje message = Message(text="Esta es la lista de Cajeros cerca :)", ) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) # Componente for branch in branches: lat, lng = Components.get_position(branch) element = Element( title=branch.name, item_url=Components.get_map_url(lat, lng), image_url=Components.get_map_screen(lat, lng), subtitle=branch.address, buttons=[ PostbackButton( title="VER", payload="%(payload)s:%(id)s" % { "payload": "SELECT_BRANCH", "id": branch.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 hay cajeros registrados :(") responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def get_image(sender): message = Message( attachment=ImageAttachment( url="https://yoparticipo.oep.org.bo/img/logo.png" ) ) # http: // giphy.com / embed / l0HlO4vdchLBZNxYc return MessageRequest(sender, message)
def get_file(sender): message = Message( attachment=FileAttachment( url="https://yoparticipo.oep.org.bo/files/procesos-electorales/referendo-autonomico-2016/reglamentos/reglamento-referendo.pdf" ) ) return MessageRequest(sender, message)
def make_regenerate_ticket(sender): responses = list() message = Message( text= "Enviame tu ubicación para generar el ticket que mas te convenga ;)" ) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def get_receipt_template(sender): template = ReceiptTemplate( recipient_name="Stephane Crozatier", order_number="12345678902", currency="USD", payment_method="Visa 2345", order_url="http://petersapparel.parseapp.com/order?order_id=123456", timestamp="1428444852", elements=[ ReceiptElement( title="Classic White T-Shirt", subtitle="100% Soft and Luxurious Cotton", quantity=2, price=50, currency="USD", image_url="http://petersapparel.parseapp.com/img/whiteshirt.png" ), ReceiptElement( title="Classic Gray T-Shirt", subtitle="100% Soft and Luxurious Cotton", quantity=1, price=25, currency="USD", image_url="http://petersapparel.parseapp.com/img/grayshirt.png" ) ], address=ReceiptAddress( street_1="1 Hacker Way", street_2="", city="Menlo Park", postal_code="94025", state="CA", country="US", ), summary=Summary( subtotal=75.00, shipping_cost=4.95, total_tax=6.19, total_cost=56.14, ), adjustments=[ Adjustment( name="New Customer Discount", amount=20, ), Adjustment( name="$10 Off Coupon", amount=10, ) ] ) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) return MessageRequest(sender, message)
def make_ticket(sender, mode=None): # Mensaje # TODO cambiar las imagenes por tickets generados. responses = list() message = Message( text="Este es tu ticket, gracias por confiar en Chuspita") responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) if mode == "CASH": url = "https://s14.postimg.org/j8qdab43h/caja.png" elif mode == "PLATFORM": url = "https://s14.postimg.org/olf7ofrzx/plataforma.png" else: url = "https://s14.postimg.org/olf7ofrzx/plataforma.png" message = Message(attachment=ImageAttachment(url=url)) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def get_quick_location_reply(sender): replies = QuickReplies( replies=[ LocationReply() ] ) message = Message( text="Envianos tu ubicacion, muajajajaja", quick_replies=replies ) return MessageRequest(sender, message)
def get_call_button(sender): template = ButtonTemplate( text="Necesitas llamar al representante?", buttons=[ CallButton( title="Llamar al representante", payload="+591 73053045" ) ] ) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) return MessageRequest(sender, message)
def get_logout_button(sender): template = GenericTemplate( elements=[ Element( title="Cerrar Sesión", image_url="https://goo.gl/Lg2CHu", buttons=[ LogoutButton() ] ) ] ) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) return MessageRequest(sender, message)
def get_share_button(sender): template = GenericTemplate( elements=[ Element( title="Asi deben saber los humanos", subtitle="Mientras tanto en otro universo", image_url="https://goo.gl/Lg2CHu", buttons=[ ShareButton() ] ) ] ) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) return MessageRequest(sender, message)
def make_position_request(sender): # Mensaje y Componente responses = list() replies = QuickReplies(replies=[ LocationReply(), TextReply( title="VER CAJEROS", payload="VIEW_BRANCHES", ) ]) message = Message( text= "Por favor envianos tu ubicación para determinar que sucursales estan cerca de ti", quick_replies=replies) responses.append(Components.typing(responses, sender)) responses.append(MessageRequest(sender, message)) return responses
def get_login_button(sender): template = GenericTemplate( elements=[ Element( title="Iniciar Sesión en Chuspita", image_url="https://goo.gl/Lg2CHu", buttons=[ LoginButton( url="https://oepbolivia.xya/login" ) ] ) ] ) attachment = TemplateAttachment(template=template) message = Message(attachment=attachment) return MessageRequest(sender, message)
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)
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)
def get_quick_text_replies(sender): replies = QuickReplies( replies=[ TextReply( title="ROJO", payload="ROJO_PAYLOAD", image_url="https://goo.gl/Ce04uG" ), TextReply( title="VERDE", payload="VERDE_PAYLOAD", image_url="https://goo.gl/QCmVib" ) ] ) message = Message( text="Escoge un color", quick_replies=replies ) return MessageRequest(sender, message)
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)