async def bank_interest(): # Checking if client is ready and online await client.wait_until_ready() while not client.is_closed: # Day, time(s) days start @ 0 sleep_this = time_format_new(BANK_INTEREST_DAY, BANK_INTEREST_TIME) send(2, "Interest in {}".format(sleep_this)) await asleep(sleep_this) users = [] # Mode_id=10, time="604800", time_type="SECOND" bank_update = get_users_lowest_bank_amount(10, "604800") for row in bank_update: # Split users between (updated this week) users.append(row[0]) # If no money in bank do nothing if row[1] != 0: # Calculating interest add_this_memes = int(mceil(row[1] * interest / 100)) # Checking if worth of adding if add_this_memes != 0: # Add memes for user user_add_points_in_bank(add_this_memes, row[0]) # Add logging points_stats_insert(message.server.id, row[0], 11, "Interest", "", "", "+" + str(add_this_memes), "", "Interest", "", "", "", 0, add_this_memes, 0) # If bank not updated this week get users' bank amount bank_nonupdate = get_users_bank_amount(users) # For each user for kek in bank_nonupdate: # Calculating interest add_this_memes = int(mceil(kek[1] * interest / 100)) # Checking if worth of adding if add_this_memes != 0: # Add memes for user user_add_points_in_bank(add_this_memes, kek[0]) # Add logging points_stats_insert(message.server.id, kek[0], 11, "Interest", "", "", "+" + str(add_this_memes), "", "Interest", "", "", "", 0, add_this_memes, 0)
def aio_unlocker( rar_file: str, tracker: str, passwords: list, start_stamp, ): parts_per_5 = len(passwords) / 5 if parts_per_5 > 10_000: processes = 5 else: processes = 3 processes = 5 if parts_per_5 > 10_000 else 3 chunks = gen_list_chunks(passwords, mceil(len(passwords) / processes)) with open(tracker, 'a') as tfile: tfile.write( f'Testing with {len(passwords)} using {processes} concurrent processes\n\n\n' ) with ProcessPoolExecutor(max_workers=processes) as executor: ppool = { executor.submit(unlocker, rar_file, chunk, tracker, start_stamp): chunk for chunk in chunks } for future in as_completed(ppool): res = future.result() if res: executor.shutdown(wait=False) with open(f'{rar_file}.pwd', 'w') as pfile: pfile.write(str(res))
def ceil(num, denum, row): ''' Calculates quotient by rounding up and appends it to the list if the value is not present in the list. ''' # result = num//denum + bool(num%denum) result = mceil(num/denum) if result not in row: row.append(result)
def file_writer(combinations): factor = 1_000_000 unique_set = list(set(combinations)) number_of_files = mceil(len(unique_set) / factor) file_suffix = 'pwd_' for file_num in range(number_of_files): with open(f'{file_suffix}{file_num}.TXT', 'w') as wfile: for pwd in unique_set[file_num * factor:(file_num + 1) * factor]: wfile.write(pwd) wfile.write('\n')
def both(num, denum, row): ''' Calculates quotients by rounding up and down and appends they to the list if the values are not present in the list. ''' # result = num//denum + bool(num%denum) result = mceil(num/denum) if result not in row: row.append(result) result = num//denum # result = mfloor(num/denum) if result not in row: row.append(result)
def corrQ(n): if t_1 == self.__t_1 and t_2 == self.__t_2 and t_v == self.__t_v: # Якщо запитуванні температури однакові, як і табличні температури # при виборі даних, то перерахунок не проводиться. f_ = 1 Q_75_65_20 = Q_pr else: # Слід виконувати перерахунок. Q_75_65_20 = Q_pr / self.f(self.__t_1, self.__t_2, self.__t_v, n) f_ = self.f(t_1, t_2, t_v, n) return mceil(Q_75_65_20 * f_), f_
async def gender(message, client, arguments): #Starting to fetch a Catfact url = "https://api.genderize.io/?name={}".format(quote(arguments[0])) response = loads(rget(url).text) letter = ":alien: **| No data was found for {}!**".format(arguments[0]) # Checking if name is valid from response if response["gender"] != None: letter = ":alien: **| There's a {}% of {} being a {}!**".format(str(mceil(response["probability"] * 100)), response["name"].title(), response["gender"]) # Sending message await client.send_message(message.channel, letter) send(1, "Gendered :P") return
async def main(self, bot, database, message, arguments): url = "http://api.openweathermap.org/data/2.5/weather?q={}&appid={}".format( quote(arguments[0]), bot.config.openweather.key) json_data = await bot.utils.web.get_content(url) weather = bot.utils.json2obj(json_data) try: definition = """Weather in: {}, {}``` Currently: {} Wind speed: {} m/s Current Temp: {} °C / {} °F Max Temp: {} °C / {} °F Min Temp: {} °C / {} °F Sunrise: {} Sunset: {} Humidity: {} % Pressure: {}00 Pa Lon: {}° Lat: {}```""".format( weather.name, weather.sys.country, weather.weather[0].description, weather.wind.speed, mceil((weather.main.temp - 273.15) * 10) / 10, mceil(((weather.main.temp - 273.15) * 9 / 5 + 32) * 10) / 10, mceil((weather.main.temp_max - 273.15) * 10) / 10, mceil( ((weather.main.temp_max - 273.15) * 9 / 5 + 32) * 10) / 10, mceil((weather.main.temp_min - 273.15) * 10) / 10, mceil( ((weather.main.temp_min - 273.15) * 9 / 5 + 32) * 10) / 10, datetime.fromtimestamp( weather.sys.sunrise).strftime('%Y-%m-%d %H:%M:%S')[11:16], datetime.fromtimestamp( weather.sys.sunset).strftime('%Y-%m-%d %H:%M:%S')[11:16], weather.main.humidity, weather.main.pressure, weather.coord.lon, weather.coord.lat) except KeyError: definition = "No match was found" letter = ":earth_africa: **| {}**".format(definition) await bot.say(message.channel, letter)
async def main(self, bot, database, message, arguments): # TODO make to botsettings special channels for serverspecific min_points = 10 winrate = 50 special_winrate = 50 rand_low = 110 rand_high = 140 special_channels = ["404356322595962880"] multiplier_outcome_str = "" multiplier_outcome_multiplier_str = "" amount = arguments[0] name = bot.utils.author_nickanme(message.author) user_points = database.user.get(message.author.id).points #Validating input and roulette amount if amount != "all": # all in all_in = False # Checking for k=1000 points if "k" in amount: try: amount = float(arguments[0].lower().replace("k","")) * 1000 except ValueError: return #Checking if number try: user_gamble = int(amount) except ValueError: return # Assigning users all points for !roulette all else: user_gamble = user_points all_in = True # Checking if user gambled mreo than x aoumnt of points if user_gamble < min_points: await bot.say(message.channel, "<@{}> **You have to gamble at least {} memes!**".format(message.author.id, min_points)) return # Checking pointsif user_gamble > user_points if user_gamble > user_points: if user_gamble - user_points < 100: need_points = user_gamble - user_points else: need_points = "more" await bot.say(message.channel, "<@{}> **You don't have enough memes to gamble, you need {} memes!**".format(message.author.id, need_points)) return # Cpecial channels if (message.channel.id in special_channels) and (randint(1,100) > special_winrate): # winrate winrate = special_winrate # Creating multiplier and some other stuff mvalue = float(randint(rand_low, rand_high) / 100) moutcome = int(mceil(user_gamble * mvalue - user_gamble)) # str for message multiplier_outcome_str = "**+" + str(moutcome) + "**" multiplier_outcome_multiplier_str = "Multiplier " + str(mvalue) info3 = str(mvalue) # if not special else: info3 = "" moutcome = 0 mvalue = 1 # info for logging info1 = "" info2 = "" # Win if randint(1,100) < winrate: # Calculations for message formation later on outcome_total = user_gamble total_points = mceil(user_points + (outcome_total * mvalue)) # Adding points and logging event for user user_gamble = user_gamble * mvalue database.user.points_alter(message.author.id, user_points) #users_set_points_to_plus(user_gamble, message.author.id) # Determine afterfix if all_in: win_afterfix = ":confetti_ball: :confetti_ball:" info2 = "All in" else: win_afterfix = ":confetti_ball:" # Creating message letter = "** :slot_machine: | {}, you have won {}{} memes, you now have {} memes! {} {}** ".format(name, outcome_total, multiplier_outcome_str, total_points, win_afterfix, multiplier_outcome_multiplier_str) try: win_str_plus = "+" + str(int(outcome_total)+int(moutcome)) plus = int(outcome_total)+int(moutcome) except: win_str_plus = "+" + str(int(outcome_total)) plus = int(outcome_total) minus = 0 info1 = "Win" # Lose else: info3 = "" # Calculations for message formation later on outcome_total = user_gamble total_points = user_points - outcome_total #ddasd = user_gamble - (user_gamble * 2) database.user.points_alter(message.author.id, -user_gamble) # Determine afterfix if all_in: win_afterfix = ":sob:" info2 = "All in" else: win_afterfix = ":cry:" # Creating message letter = "** :slot_machine: | {}, you have lost {} memes, you now have {} memes! {}** ".format(name, outcome_total, total_points, win_afterfix) win_str_plus = "-" + str(user_gamble) plus = 0 minus = int(user_gamble) info1 = "Lose" bot.database.pointhistory.add(message.author.id, message.server.id, 5, "Roulette", False, str(user_gamble), "", win_str_plus, "", info1, info2, info3, "", 0, plus, minus) # Sending message, checking if worth of excitement if user_gamble / user_points > 0.8: # TODO add expression system to config file msg = await bot.say(message.channel, "**:no_mouth: Rolling **") await asleep(4.0) await bot.edit_message(msg, letter) return # if not high bet do this no excitement else: await bot.say(message.channel, letter)
def proc(self, proc_dev, perc): proc_dev.setProperty("value", mceil(100 * perc))
async def main(self, bot, database, message, arguments): interest = 5 # wealth userRR = bot.database.user.get(message.author.id) users_points = userRR.points users_bank = userRR.bank add_dir = ["add", "deposit", "put", "give"] take_dir = ["take", "withdraw", "remove"] # How many memes in bank if len(arguments) == 0: # Time from interest BANK_INTEREST_DAY = 3 BANK_INTEREST_TIME = 3000 time = Time() past_time = 604800 - (time.time_untill_weekly( BANK_INTEREST_DAY, BANK_INTEREST_TIME)) # Users interest try: users_own_interest = mceil( (bot.database.pointhistory.get_min_bank_amount( 10, past_time, message.author.id)[0].min_bank) * interest / 100) except: users_own_interest = mceil(users_bank * interest / 100) # Creating message and sending it letter = ":bank: **| You have {} memes in your bank! Interest is {}%, Currently: {} memes\n\nInterest is calculated by the amount of memes you've had in the bank for the past week!\nYou receive interest every wednesday @ 00:00 **".format( users_bank, interest, users_own_interest) await bot.say(message.channel, letter) return # if all if arguments[1] in ["all", "kaikki"]: # Check if add or take if arguments[0] in add_dir: amount = users_points elif arguments[0] in take_dir: amount = users_bank elif arguments[1] in ["half", "puolet", "1/2"]: # Check if add or take if arguments[0] in add_dir: amount = mceil(users_points * 0.5) elif arguments[0] in take_dir: amount = mceil(users_bank * 0.5) elif arguments[1] in ["third", "kolmasosa", "1/3"]: # Check if add or take if arguments[0] in add_dir: amount = mceil(users_points * 0.33333) elif arguments[0] in take_dir: amount = mceil(users_bank * 0.33333) elif arguments[1] in ["quarter", "quad", "neljännes", "1/4"]: # Check if add or take if arguments[0] in add_dir: amount = mceil(users_points * 0.25) elif arguments[0] in take_dir: amount = mceil(users_bank * 0.25) # if not all try to set amount else: try: arguments[1] = arguments[1].replace("k", "000") amount = int(arguments[1]) except: await bot.say(message.channel, ":bank: **| Invalid amount!**") return # Must use atleast 10 memes if amount < 10: await bot.say(message.channel, ":bank: **| You need to atleast use 10 memes!**") return # Adding memes if arguments[0] in add_dir: # Checking if usr has memes if amount > int(users_points): await bot.say(message.channel, ":bank: **| You don't have enough memes!**") return # calculating min amount in bank minimum = users_bank # Add to history bot.database.pointhistory.add(message.server.id, message.author.id, 10, "Bank", False, amount, "", "-" + str(amount), "", "To bank", "", "", "", minimum, 0, amount) # Set stats bot.database.user.points_alter(message.author.id, -amount) bot.database.user.bank_alter(message.author.id, amount) # letter await bot.say( message.channel, ":bank: **| You have transferred {} memes to bank!\n\nYou now have:\n:purse:: {} memes\n:bank:: {} memes**" .format(amount, users_points - amount, users_bank + amount)) return # Taking memes elif arguments[0] in take_dir: # Checking if enough memes in bank if amount > int(users_bank): await bot.say( message.channel, ":bank: **| You don't have that many memes in bank!**") return # calculating min amount in bank minimum = users_bank - amount # Add to history bot.database.pointhistory.add(message.server.id, message.author.id, 10, "Bank", False, amount, "", "+" + str(amount), "", "From bank", "", "", "", minimum, amount, 0) # Set stats bot.database.user.points_alter(message.author.id, amount) bot.database.user.bank_alter(message.author.id, -amount) # letter await bot.say( message.channel, ":bank: **| You have transferred {} memes to your wallet!\n\nYou now have:\n:purse:: {} memes\n:bank:: {} memes**" .format(amount, users_points + amount, users_bank - amount)) return