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
def points(): username = globals.CURRENT_USER db = Database() try: points = int(db.get_points(username)[0]) except Exception as error: print error return "Couldn't show your points, sorry!" return "You have {0} points!".format(points)
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"
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"
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"
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"