def send_reddit_post(recipient_id, microarticle, microarticle_type): #sends user the text message provided via input response parameter print("[i] Formatting Article...") response = article_Service.format_article(microarticle, microarticle_type) print("[i] " + microarticle_type + " SRC:\t" + str(microarticle.domain)) if microarticle_type == "image": image_formats = ['.gif','.jpg','.jpeg','.png'] if microarticle.url[-4:] in image_formats: page.send(recipient_id, Attachment.Image(str(microarticle.url))) elif microarticle.url[-4:] == ".gifv": page.send(recipient_id, Attachment.Video(str(microarticle.url))) else: page.send(recipient_id, Attachment.Image(str(microarticle.url))) elif microarticle_type == "video": page.send(recipient_id, Attachment.Video(str(microarticle.url))) elif microarticle_type == "article": print("[i] Response:") pprint.pprint(response) page.send(recipient_id, Template.Generic([ Template.GenericElement(microarticle.title, subtitle= response[0].get('subtitle'), item_url= microarticle.url, image_url= microarticle.thumbnail, buttons=[ Template.ButtonShare(), Template.ButtonWeb("Open Web URL", microarticle.url) ]), ])) print("[i] Response sent...") return "success"
def send_prize(event, previous=None): "send a prize" sender_id = event.sender_id message = event.message_text page.typing_on(sender_id) page.send(sender_id, _("Wow, you're on a nice streak. Here's a prize!")) for p in quizprizes: app.logger.debug('Prize: {!r}: {} is_embargoed: {}'.format( p.url, p.embargo, p.is_embargoed)) # Send a gif prize try: prize = random.choice([q for q in quizprizes if not q.is_embargoed]) except IndexError: app.logger.warning('No prizes that are not embargoed!') page.send(sender_id, '8)') if prize.media_type == 'image': att = Attachment.Image(prize.url) elif prize.media_type == 'video': att = Attachment.Video(prize.url) elif prize.media_type == 'text': att = prize.url page.send(sender_id, att)
def bot_send_attachment(self, user_model, file_url, file_type, keyboard=None): if file_type and file_type.startswith('image'): return self._service.send(user_model.conversation_id, Attachment.Image(file_url), quick_replies=keyboard) if file_type and file_type.startswith('video'): return self._service.send(user_model.conversation_id, Attachment.Video(file_url), quick_replies=keyboard) if file_type and file_type.startswith('audio'): return self._service.send(user_model.conversation_id, Attachment.Audio(file_url), quick_replies=keyboard) return self._service.send(user_model.conversation_id, Attachment.File(file_url), quick_replies=keyboard)
def send_video(recipient): page.send(recipient, Attachment.Video(CONFIG['SERVER_URL'] + "/assets/allofus480.mov"))