コード例 #1
0
def enter_the_raffle(user):
    global CURRENT_RAFFLE
    raffle_dict = bot_xp.load_obj(RAFFLE_FILE)
    if not raffle_dict:
        raffle_dict = {}
    if user in raffle_dict.keys():
        if raffle_dict[user] >= 1:
            CURRENT_RAFFLE.append(user)
            raffle_dict[user] = raffle_dict[user] - 1
            bot_xp.save_obj(raffle_dict, RAFFLE_FILE)
        else:
            message('%s has no raffle tickets' % user)
            return
    else:
        message('%s has no raffle tickets' % user)
        return
    return
コード例 #2
0
def enter_the_raffle(user):
    global CURRENT_RAFFLE
    raffle_dict = bot_xp.load_obj(RAFFLE_FILE)
    if not raffle_dict:
        raffle_dict = {}
    if user in raffle_dict.keys():
        if raffle_dict[user] >= 1:
            CURRENT_RAFFLE.append(user)
            raffle_dict[user] = raffle_dict[user] - 1
            message('%s has joined the Raffle!' % user)
            bot_xp.save_obj(raffle_dict, RAFFLE_FILE)
        else:
            message('%s has no raffle tickets' % user)
            return
    else:
        message('%s has no raffle tickets' % user)
        return
    return
コード例 #3
0
def buy_ticket(user):
    xp_dict = bot_xp.load_obj(XP_FILE)
    raffle_dict = bot_xp.load_obj(RAFFLE_FILE)
    try:
        if not raffle_dict:
            raffle_dict = {}
        if xp_dict[user] >= int(RAFFLE_COST):
            xp_dict[user] = xp_dict[user] - int(RAFFLE_COST)
            if user in raffle_dict.keys():
                raffle_dict[user] = raffle_dict[user] + 1
            else:
                raffle_dict[user] = 1
            message('Thats %sxp, enjoy your raffle ticket![Current Count: %s]' % (RAFFLE_COST, raffle_dict[user]))
            bot_xp.save_obj(xp_dict, XP_FILE)
            bot_xp.save_obj(raffle_dict, RAFFLE_FILE)
        else:
            message('Raffle Tickets cost %sxp, you only have %s' % (RAFFLE_COST, xp_dict[user]))
    except Exception:
        pass
    return
コード例 #4
0
def buy_ticket(user):
    xp_dict = bot_xp.load_obj(XP_FILE)
    raffle_dict = bot_xp.load_obj(RAFFLE_FILE)
    try:
        if not raffle_dict:
            raffle_dict = {}
        if xp_dict[user] >= RAF_COST:
            xp_dict[user] = xp_dict[user] - RAF_COST
            if user in raffle_dict.keys():
                raffle_dict[user] = raffle_dict[user] + 1
            else:
                raffle_dict[user] = 1
            message(
                'Thats %sxp, enjoy your raffle ticket![Current Count: %s]' %
                (RAF_COST, raffle_dict[user]))
            bot_xp.save_obj(xp_dict, XP_FILE)
            bot_xp.save_obj(raffle_dict, RAFFLE_FILE)
        else:
            message('Raffle Tickets cost %sxp, you only have %s' %
                    (RAF_COST, xp_dict[user]))
    except Exception:
        pass
    return