Beispiel #1
0
def stop():
    channel = globals.CURRENT_CHANNEL
    chan = "#" + channel
    db = Database()
    bets = db.are_bets(channel)[0]
    if bets:
        delay = 30
        initialize(chan, delay)
        
    else:
        return "You haven't started a bet yet!"
    
    return "You have started the countdown"
Beispiel #2
0
def stop():
    channel = globals.CURRENT_CHANNEL
    chan = "#" + channel
    db = Database()
    bets = db.are_bets(channel)[0]
    if bets:
        delay = 30
        initialize(chan, delay)

    else:
        return "You haven't started a bet yet!"

    return "You have started the countdown"
Beispiel #3
0
def start():
    db = Database()
    channel = globals.CURRENT_CHANNEL
    bets = db.are_bets(channel)[0]
    if not bets:
        chan = "#" + channel
        irc = globals.irc
        
        db.set_bets(channel, 1)
        date = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
        db.set_bets_started(channel, date)
        
        msg = "Bets are open! Type !win or !lose with the amount of points you want to bet, example: !win 200"
        irc.send_message(chan, msg)
        return "You have opened the bets"
        
    else:
        return "First, resolve current bets"
Beispiel #4
0
def start():
    db = Database()
    channel = globals.CURRENT_CHANNEL
    bets = db.are_bets(channel)[0]
    if not bets:
        chan = "#" + channel
        irc = globals.irc

        db.set_bets(channel, 1)
        date = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
        db.set_bets_started(channel, date)

        msg = "Bets are open! Type !win or !lose with the amount of points you want to bet, example: !win 200"
        irc.send_message(chan, msg)
        return "You have opened the bets"

    else:
        return "First, resolve current bets"
Beispiel #5
0
def win(args):
    db = Database()
    channel = globals.CURRENT_CHANNEL
    bets = db.are_bets(channel)[0]

    if bets:
        username = globals.CURRENT_USER

        if db.get_user(username) == None:
            db.add_user([username])
            db.modify_points(username, 1000)

        current_points = db.get_points(username)[0]

        if (args[0][-1] == "%"):
            try:
                percentage = int(args[0].strip("%"))
            except Exception as error:
                print error
                return "Sorry, but your betting amount should be a number or a percentage"
            if percentage > 100:
                return "Sorry, but you can't bet more than a 100%"
            else:
                multiply = float(percentage) / 100
                amount = int(current_points * multiply)

        else:
            try:
                amount = int(args[0])
            except Exception as error:
                print error
                return "Sorry, but your betting amount should be a number or a percentage"
            if amount > current_points:
                return "You currently have {0} points, use them wisely.".format(
                    current_points)

        date = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
        db.add_bidder(channel, username, amount, "win", date)
        db.modify_points(username, -amount)
        return "Bet successfully placed! You bet {0} that {1} will win".format(
            amount, channel)

    else:
        return "Sorry, bets were not started yet"
Beispiel #6
0
def lose(args):
    db = Database()
    channel = globals.CURRENT_CHANNEL
    bets = db.are_bets(channel)[0]
    
    if bets:
        username = globals.CURRENT_USER
        
        if db.get_user(username) == None:
            db.add_user([username])
            db.modify_points(username, 1000)
        
        current_points = db.get_points(username)[0]
        
        if (args[0][-1] == "%"):
            try:
                percentage = int(args[0].strip("%"))
            except Exception as error:
                print error
                return "Sorry, but your betting amount should be a number or a percentage"
            if percentage > 100:
                return "Sorry, but you can't bet more than a 100%"
            else:
                multiply = float(percentage) / 100
                amount = int(current_points * multiply)
           
        else:
            try:
               amount = int(args[0])
            except Exception as error:
                print error
                return "Sorry, but your betting amount should be a number or a percentage"
            if amount > current_points:
                return "You currently have {0} points, use them wisely.".format(current_points)
        
        date = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S") 
        db.add_bidder(channel, username, amount, "lose", date)
        db.modify_points(username, -amount)
        return "Bet successfully placed! You bet {0} that {1} will lose".format(amount, channel)
        
    else:
        return "Sorry, bets were not started yet"
Beispiel #7
0
def outcome(args):
    result = args[0]

    if result != "win" and result != "lose":
        return "Sorry, but you didn't specified the outcome. You should write !outcome win/lose"

    else:
        db = Database()
        channel = globals.CURRENT_CHANNEL
        bets = db.are_bets(channel)[0]
        if not bets:
            bts = Bets()
            bts.distribute_profit(result)
            db.set_last_result(channel, result)
            date = datetime.strftime(datetime.utcnow(), "%Y %m %d %H %M %S")
            #So the outcome won't be used twice for same bets
            db.set_bets_started(channel, date)
        else:
            return "The bets are still going on!"

    return "You have distributed the profit"