Example #1
0
def event(instance, **kwargs):
    user = instance.updater.credentials.user
    details = json.loads(instance.details)
    info = instance.as_dict()
    info['id'] = instance.id
    alerts = AlertConfig.objects.filter(user=user).order_by(
        "filter_type", "-filter_amount")
    amount_micros = info['amount_micros']
    alerts = []
    for alert in alerts:
        if alert.filter_type == "1equal" and alert.filter_amount:
            if alert.filter_amount * 1000000 == amount_micros:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "2gt" and alert.filter_amount:
            if alert.filter_amount * 1000000 < amount_micros:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "3default":
            alerts.append(alert)
    if len(alerts):
        chosen_config = random.choice(alerts)
        config_to_alert(chosen_config, info)

    add_donation(instance.as_dict(), user, "fanfunding")
Example #2
0
def event(instance, **kwargs):
    user = instance.updater.user
    alerts = StreamtipAlertConfig.objects.filter(user=user).order_by("filter_type", "-filter_amount")
    info = instance.as_dict()
    for alert in alerts:
        if alert.filter_type == "1equal":
            if alert.filter_amount == info['donation_amount']:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "2gt":
            if alert.filter_amount < info['donation_amount']:
                config_to_alert(alert, info)
                break
        else:
            config_to_alert(alert, info)
    add_donation(instance.as_dict(), user, "streamtip")
Example #3
0
def event(instance, **kwargs):
    user = instance.updater.user
    alerts = StreamjarAlertConfig.objects.filter(user=user).order_by("filter_type", "-filter_amount")
    info = instance.as_dict()
    for alert in alerts:
        if alert.filter_type == "1equal":
            if alert.filter_amount == info['donation_amount']:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "2gt":
            if alert.filter_amount < info['donation_amount']:
                config_to_alert(alert, info)
                break
        else:
            config_to_alert(alert, info)
    add_donation(instance.as_dict(), user, "streamjar")
Example #4
0
def event(instance, **kwargs):
    user = instance.updater.credentials.user
    details = json.loads(instance.details)
    info = instance.as_dict()
    alerts = AlertConfig.objects.filter(user=user).order_by("filter_type", "-filter_amount")
    amount_micros = info['amount_micros']
    for alert in alerts:
        if alert.filter_type == "1equal" and alert.filter_amount:
            if alert.filter_amount * 1000000 == amount_micros:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "2gt" and alert.filter_amount:
            if alert.filter_amount * 1000000 < amount_micros:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "3default":
            config_to_alert(alert, info)
    add_donation(instance.as_dict(), user, "fanfunding")
Example #5
0
def event(instance, **kwargs):
    user = instance.updater.user
    details = json.loads(instance.details)
    info = instance.as_dict()
    info['id'] = instance.id
    alerts = ExtralifeAlertConfig.objects.filter(user=user).order_by("filter_type", "-filter_amount")
    #amount_micros = info['amount_micros']
    for alert in alerts:
        if alert.filter_type == "1equal" and alert.filter_amount:
            if alert.filter_amount == info['donation_amount']:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "2gt" and alert.filter_amount:
            if alert.filter_amount < amount_info['donation_amount']:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "3default":
            config_to_alert(alert, info)
    add_donation(instance.as_dict(), user, "extralife")
Example #6
0
def event(instance, **kwargs):
    user = instance.updater.user
    details = json.loads(instance.details)
    info = instance.as_dict()
    info['id'] = instance.id
    alerts = ExtralifeAlertConfig.objects.filter(user=user).order_by(
        "filter_type", "-filter_amount")
    #amount_micros = info['amount_micros']
    for alert in alerts:
        if alert.filter_type == "1equal" and alert.filter_amount:
            if alert.filter_amount == info['donation_amount']:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "2gt" and alert.filter_amount:
            if alert.filter_amount < amount_info['donation_amount']:
                config_to_alert(alert, info)
                break
        elif alert.filter_type == "3default":
            config_to_alert(alert, info)
    add_donation(instance.as_dict(), user, "extralife")
Example #7
0
    def setUp(self):
        u = User(username="******")
        u.save()
        add_donation({
            'name': 'foo',
            'timestamp': timezone.now() - timedelta(seconds=60),
            'comment': '',
            'donation_amount': 1.00,
            'currency': 'USD'
        }, user=u, type="fanfunding")
        
        add_donation({
            'name': 'foo',
            'timestamp': timezone.now() - timedelta(days=5),
            'comment': '',
            'donation_amount': 1.00,
            'currency': 'USD'
        }, user=u, type="fanfunding")

        top = TopList(user=u, type="limited", days=1)
        top.save()

        self.top = top
Example #8
0
    def setUp(self):
        u = User(username="******")
        u.save()
        add_donation({
            'name': '😇',
            'timestamp': timezone.now() - timedelta(seconds=60),
            'comment': '',
            'donation_amount': 1.00,
            'currency': 'USD'
        }, user=u, type="fanfunding")

        add_donation({
            'name': '😇',
            'timestamp': timezone.now() - timedelta(seconds=120),
            'comment': '',
            'donation_amount': 4.00,
            'currency': 'USD'
        }, user=u, type="fanfunding")
        
        session = Session(user=u,
            session_start = timezone.now() - timedelta(seconds=90))
        session.save()    

        top = TopList(user=u, type="session")
        top.save()

        self.top = top
    
        u = User(username="******")
        u.save()
        add_donation({
            'name': '😇',
            'timestamp': timezone.now() - timedelta(seconds=60),
            'comment': '',
            'donation_amount': 4.00,
            'currency': 'USD'
        }, user=u, type="fanfunding")
        
        top = TopList(user=u, type="session")
        top.save()

        self.top_no_session = top