Beispiel #1
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 #2
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 #3
0
class BetsThread(Thread):
    def __init__(self, irc, chan, delay):
        Thread.__init__(self, target=self.main)
        self.daemon = True
        self.delay = delay
        self.now = time.time()
        self.chan = chan
        self.channel = self.chan.lstrip("#")
        self.irc = irc
        self.db = Database()

    def main(self):
        begin_resp = "Bets will close in {0} seconds!".format(self.delay)
        end_resp = "Bets are now closed!"
        time_left = "{0} seconds of betting remains!".format(self.delay / 2)
        self.irc.send_message(self.chan, begin_resp)
        time.sleep(float(self.delay / 2))
        self.irc.send_message(self.chan, time_left)
        time.sleep(float(self.delay / 2))
        self.irc.send_message(self.chan, end_resp)
        self.db.set_bets(self.channel, 0)

        sys.exit()
Beispiel #4
0
class BetsThread(Thread):

    def __init__(self, irc, chan, delay):
        Thread.__init__(self, target=self.main)
        self.daemon = True
        self.delay = delay
        self.now = time.time()
        self.chan = chan
        self.channel = self.chan.lstrip("#")
        self.irc = irc
        self.db = Database()

    def main(self):
        begin_resp = "Bets will close in {0} seconds!".format(self.delay)
        end_resp = "Bets are now closed!"
        time_left = "{0} seconds of betting remains!".format(self.delay / 2)
        self.irc.send_message(self.chan, begin_resp)
        time.sleep(float(self.delay / 2))
        self.irc.send_message(self.chan, time_left)
        time.sleep(float(self.delay / 2))
        self.irc.send_message(self.chan, end_resp)
        self.db.set_bets(self.channel, 0)
        
        sys.exit()