Beispiel #1
0
def trigger_less_than_200_for_all(chan):
    try:
        db = Database()
        channel = chan.lstrip("#")
        str_last_time = db.get_last_time_points_reset(channel)[0]
        if str_last_time:
            now = datetime.utcnow()
            last_time = datetime.strptime(str_last_time, "%Y %m %d %H %M %S")
            if now - last_time >= timedelta(1):
                usernames = db.get_all_usernames()
                
                for username in usernames:
                    points = db.get_points(username)[0]
                    if points < 200:
                        db.set_points(username, 200)
                
                strnow = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
                db.set_last_time_points_reset(channel, strnow)
                return "Points have been reloaded for users who have less than 200!"
                   
        else:
            strnow = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
            db.set_last_time_points_reset(channel, strnow)
    
    except Exception as error:
        print error
Beispiel #2
0
def trigger_less_than_200_for_all(chan):
    try:
        db = Database()
        channel = chan.lstrip("#")
        str_last_time = db.get_last_time_points_reset(channel)[0]
        if str_last_time:
            now = datetime.utcnow()
            last_time = datetime.strptime(str_last_time, "%Y %m %d %H %M %S")
            if now - last_time >= timedelta(1):
                usernames = db.get_all_usernames()

                for username in usernames:
                    points = db.get_points(username)[0]
                    if points < 200:
                        db.set_points(username, 200)

                strnow = datetime.strftime(datetime.utcnow(),
                                           "%Y %m %d %H %M %S")
                db.set_last_time_points_reset(channel, strnow)
                return "Points have been reloaded for users who have less than 200!"

        else:
            strnow = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
            db.set_last_time_points_reset(channel, strnow)

    except Exception as error:
        print error
Beispiel #3
0
def claim():
    username = globals.CURRENT_USER
    channel = globals.CURRENT_CHANNEL
    db = Database()
    points = db.get_points(channel, username)[0]
    if points < 200:
        now = datetime.utcnow()
        str = db.get_last_changed_below_200(channel, username)[0]
        last_changed = datetime.strptime(str, "%Y %m %d %H %M %S")
        
        if now - last_changed >= timedelta(1):
            db.set_points(channel, username, 200)
            strnow = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
            db.set_last_changed_below_200(channel, username, strnow)
            return "Your points have been reloaded from {0} to 200 points. Points reload once every 24h".format(points)
            
        else:
            return "Sorry, but 24h have not yet passed"
            
    else:
        return "Sorry, but you have more than 200 points"
Beispiel #4
0
def claim():
    username = globals.CURRENT_USER
    channel = globals.CURRENT_CHANNEL
    db = Database()
    points = db.get_points(channel, username)[0]
    if points < 200:
        now = datetime.utcnow()
        str = db.get_last_changed_below_200(channel, username)[0]
        last_changed = datetime.strptime(str, "%Y %m %d %H %M %S")

        if now - last_changed >= timedelta(1):
            db.set_points(channel, username, 200)
            strnow = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
            db.set_last_changed_below_200(channel, username, strnow)
            return "Your points have been reloaded from {0} to 200 points. Points reload once every 24h".format(
                points)

        else:
            return "Sorry, but 24h have not yet passed"

    else:
        return "Sorry, but you have more than 200 points"