def config_to_alert(alert, info, test=False): if alert.blacklist: blacklist_strings = map(lambda x: x.strip(), alert.blacklist.split(",")) else: blacklist_strings = [] for s in blacklist_strings: if s and s.lower() in info['name'].lower(): return text = alert.alert_text text = text.replace("[[name]]", info['name']) text = text.replace("[[amount]]", str(info['amount'])) text = text.replace("[[comment]]", str(info['comment'])) style = AlertStyle(image=alert.image_url, sound=alert.sound_url, font=alert.font, font_size=alert.font_size, font_color=alert.font_color) style.save() a = Alert(text=text, time=timezone.now(), user=alert.user, style=style, test=test, config=alert) a.save()
def config_to_alert(alert, info, test=False): if alert.blacklist: blacklist_strings = map(lambda x: x.strip(), alert.blacklist.split(",")) else: blacklist_strings = [] for s in blacklist_strings: if s and s.lower() in info['name'].lower(): return text = alert.alert_text.encode("utf-8") text = text.replace("[[name]]", info['name'].encode("utf-8")) text = text.replace("[[amount]]", info['amount'].encode("utf-8")) text = text.replace("[[comment]]", info['comment'].encode("utf-8")) sound_url = alert.sound_url if alert.text_to_speech and info['comment']: try: do_it(alert.sound_url, info['comment'], str(info['id'])) sound_url = "https://www.livestreamalerts.com/static/sounds/%s.wav" % info[ 'id'] except: print "Failed text to speech on %s" % info['id'] style = AlertStyle(image=alert.image_url, sound=sound_url, font=alert.font, font_size=alert.font_size, font_color=alert.font_color) style.save() a = Alert(text=text, time=timezone.now(), user=alert.user, style=style, test=test, config=alert) a.save()
def config_to_alert(alert, info, test=False): if alert.blacklist: blacklist_strings = map(lambda x: x.strip(), alert.blacklist.split(",")) else: blacklist_strings = [] for s in blacklist_strings: if s and s.lower() in info['name'].lower(): return text = alert.alert_text text = text.replace("[[name]]", info['name']) style = AlertStyle(image=alert.image_url, sound=alert.sound_url, font=alert.font, font_size=alert.font_size, font_color=alert.font_color) style.save() a = Alert(text=text, time=timezone.now(), user=alert.user, style=style, test=test, config=alert) a.save()
def config_to_alert(alert, info, test=False): if alert.blacklist: blacklist_strings = map(lambda x: x.strip(), alert.blacklist.split(",")) else: blacklist_strings = [] for s in blacklist_strings: if s and s.lower() in info['name'].lower(): return text = alert.alert_text text = text.replace("[[name]]", info['name']) text = text.replace("[[amount]]", info['amount']) text = text.replace("[[comment]]", info['comment']) sound_url = alert.sound_url if alert.text_to_speech and info['comment']: try: do_it(alert.sound_url, info['comment'], str(info['id'])) sound_url = "https://www.livestreamalerts.com/static/sounds/%s.wav" % info['id'] except: print "Failed text to speech on %s" % info['id'] style = AlertStyle(image=alert.image_url, sound=sound_url, font=alert.font, font_size=alert.font_size, font_color=alert.font_color) style.save() a = Alert(text=text, time=timezone.now(), user=alert.user, style=style, test=test, config=alert) a.save()