async def image(self, link): async with ClientSession() as session: async with session.get(link) as resp: json_data = loads(await resp.text()) logging_info(json_data["url"]) async with session.get(json_data["url"]) as resp: return BytesIO(await resp.read())
async def db(self, ctx, argument0=None, argument1=None, argument2=None): if argument0 == 'add' and argument1 == 'inv': ref = dab.collection('users').document('collectionlist').get().get( 'array') amount = len(ref) - 1 count = 0 while (count <= amount): try: ID = ref[count] inv = dab.collection('users').document( str(ID)).get().get('inv') inv.append(argument2) dab.collection('users').document(str(ID)).update( {'inv': inv}) except Exception as e: logging_error(e) count = count + 1 logging_info("updated database\n----------") await ctx.send('I\'ve updated the database senpai UwU') elif argument0 == 'add': ref = dab.collection('users').document('collectionlist').get().get( 'array') amount = len(ref) - 1 count = 0 while (count <= amount): try: ID = ref[count] inv = dab.collection('users').document(str(ID)).update( {f'{argument1}': argument2}) except Exception as e: logging_error(e) count = count + 1 await ctx.send('I\'ve updated the database senpai UwU')
async def buy_friend(self, ctx): inv = dab.collection('users').document(str( ctx.author.id)).get().get('inv') bal = dab.collection('users').document(str( ctx.author.id)).get().get('bal') inv_len = len(inv) a = 0 while a < inv_len: item = str(inv[a]).split('~') if item[0] == 'friend': if bal >= 2750: count = int(item[1]) + 1 inv[a] = f'friend~{count}' bal = bal - 2750 dab.collection('users').document(str( ctx.author.id)).update({ 'inv': inv, 'bal': bal }) await ctx.send( f'Friend has been added to your inv, you now have {count} friends' ) logging_info( 'Response: Friend has been bought\n----------') else: await ctx.send( f'I didnt know you where poor master OwO, you need at least 2750 coins, you only have {bal}' ) a = a + 1
async def withdraw(self, ctx, argument): bal = dab.collection('users').document(str( ctx.author.id)).get().get('bal') bank = dab.collection('users').document(str( ctx.author.id)).get().get('bank') if argument == 'all': bal = bal + bank bank = 0 dab.collection('users').document(str(ctx.author.id)).update({ 'bal': bal, 'bank': bank }) await ctx.send(f'Wallet: {bal}\nBank: {bank}') logging_info( f'Response: {ctx.author} transferred all to bal \n----------') else: if int(argument) > bank: await ctx.send( f'You don\'t have enough money in your bank to do that!') logging_info( f'Response: {ctx.author} did not have enough money\n----------' ) else: bal = bal + int(argument) bank = bank - int(argument) dab.collection('users').document(str(ctx.author.id)).update({ 'bal': bal, 'bank': bank }) await ctx.send(f'Wallet: {bal}\nBank: {bank}')
async def birthday(self, ctx, argument): logging_info(f'Recieved user update birthday {ctx.author.name}') if ((bool(search(r"\d/", argument)))) is False: logging_warning("Birthday input validation triggered") await ctx.send( "Oopsie, looks like you did a woopsie! uwu\n``Don't use characters expect for numbers and /``" ) return storer = argument.split('/') storer[0] = int(storer[0]) storer[1] = int(storer[1]) if (storer[1] > 12 or storer[1] < 1 or storer[0] > 31 or storer[0] < 1): logging_warning( "Birthday legitimacy triggered, date and/or month invalid") return await ctx.send( "B-Baka!! that date doesn't make any sense!\n``Please use a legitimate date``" ) try: print(int(len(storer[2]))) if int(len(storer[2])) > 4 or int(len(storer[2])) < 4: logging_warning("Birthday legitmacy triggered, year invalid") return await ctx.send( "B-Baka!! that date doesn't make any sense!\n``Please use a legitimate year, or don't include one``" ) except IndexError: False doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'birthday': argument}) await ctx.send(f"I've updated Senpai's birthday to {argument}! >w<") logging_info( f"{ctx.author.name} has updated their birthday to {argument}\n----------" )
async def youtube(self, ctx, argument): logging_info(f'Recieved user update youtube {ctx.author.name}') doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'youtube': argument}) await ctx.send("I've updated your Youtube, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their youtube to {argument}\n----------" )
async def reddit(self, ctx, argument): logging_info(f'Recieved user update reddit {ctx.author.name}') doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'reddit': argument}) await ctx.send("I've updated your Reddit, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their reddit to {argument}\n----------" )
async def status(self, ctx, *, argument): logging_info(f'Recieved user update status {ctx.author.name}') doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'status': argument}) await ctx.send("I've updated your status, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their status to {argument}\n----------" )
async def twitch(self, ctx, argument): logging_info(f'Recieved user update twitch {ctx.author.name}') doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'twitch': argument}) await ctx.send("I've updated your Twitch, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their twitch to {argument}\n----------" )
async def username(self, ctx, *, argument): logging_info(f'Recieved user update username {ctx.author.name}') doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'username': argument}) await ctx.send(f"I've updated Senpai's username to {argument}! >w<") logging_info( f"{ctx.author.name} has updated their username to {argument}\n----------" )
async def bal(self, ctx): logging_info('Recieved >bal') bal = dab.collection('users').document(str( ctx.author.id)).get().get('bal') bank = dab.collection('users').document(str( ctx.author.id)).get().get('bank') await ctx.send( f'You have {bal} Scuffed Coins in your wallet and {bank} Coins in your bank' )
async def shop_friend(self, ctx): logging_info('Recieved >shop friend') embed = Embed(title="<:adult:815178865475321868> Friend", description="At least you can buy them...", color=0xff0000) embed.add_field(name="Buyable", value='Yes', inline=False) embed.add_field(name="Cost", value='2750 Scuffed Coins', inline=False) embed.add_field(name="Usable", value='no', inline=False) embed.add_field(name="Consumable", value='no', inline=False) await ctx.send(embed=embed)
async def shop_gun(self, ctx): logging_info('Recieved >shop gun') embed = Embed(title="<:PixelGun:806977728094928906> Gun", description="Are we in texas or something?", color=0xff0000) embed.add_field(name="Buyable", value='Yes', inline=False) embed.add_field(name="Cost", value='1000 Scuffed Coins', inline=False) embed.add_field(name="Usable", value='Yes', inline=False) embed.add_field(name="Consumable", value='Yes', inline=False) await ctx.send(embed=embed)
async def unmute(self, ctx): if ctx.author.voice is None: return await ctx.send("You aren't in a voice channel!") voice = self.bot.get_channel(ctx.author.voice.channel.id) logging_info(f"Unmuting in {voice.name}") for x in voice.members: member = ctx.guild.get_member(x.id) if member.voice.mute is True: await member.edit(mute=False, deafen=False) logging_info(f"{x.name} unmuted") await ctx.message.delete()
async def status(self): await self.bot.wait_until_ready() if getrandbits(1) == 1: value = choice(play_status_list) await self.bot.change_presence(activity=Game(name=value)) logging_info(f"Status set to: {value}") else: value = choice(watch_status_list) await self.bot.change_presence( activity=Activity(name=value, type=ActivityType.watching)) logging_info(f"Status set to: {value}")
async def nhentai(self, ctx, *, argument=None): if argument is None: sauce = nhentai.get_random() logging_info(sauce) await ctx.send(embed=await sauce_embed(sauce)) elif argument.isdigit(): sauce = nhentai.get_doujin(id=argument) logging_info(sauce) if sauce is None: return await ctx.send("S-Sorry, I can't find that id qwq") await ctx.send(embed=await sauce_embed(sauce))
def eval_complex(rf=0, rf_nm=0, inputs={}, known_complex_nodes_list=[], prot_list=[], fin_list_graphs=[], suffix="both"): # rf - read flag to read complexes from file logging_info("Evaluating complexes..." + suffix) out_comp_nm = inputs['dir_nm'] + inputs['out_comp_nm'] if rf == 1: if rf_nm == 0: rf_nm = out_comp_nm + '_pred.out' with open(rf_nm) as fn: fin_list_graphs = [(set(line.rstrip('\n').split()), 1) for line in fn] # Space separated text only # Just list of list of nodes sizes_orig = [len(comp[0]) for comp in fin_list_graphs] N_pred_comp = len(fin_list_graphs) if N_pred_comp == 0: return N_test_comp = len(known_complex_nodes_list) with open(out_comp_nm + '_metrics.out', "a") as fid: print("No. of known complexes = ", N_test_comp, file=fid) print("No. of predicted complexes = ", N_pred_comp, file=fid) print("\n -- Metrics on complexes with all proteins -- ", file=fid) compute_metrics(known_complex_nodes_list, fin_list_graphs, out_comp_nm, N_test_comp, N_pred_comp, inputs, suffix + '_all_prots') fin_list_graphs = remove_unknown_prots(fin_list_graphs, prot_list) plot_size_dists(known_complex_nodes_list, fin_list_graphs, sizes_orig, out_comp_nm) N_pred_comp = len(fin_list_graphs) with open(out_comp_nm + '_metrics.out', "a") as fid: print( "No. of predicted complexes after removing non-gold std proteins = ", N_pred_comp, file=fid) print("\n -- Metrics on complexes with only gold std proteins -- ", file=fid) compute_metrics(known_complex_nodes_list, fin_list_graphs, out_comp_nm, N_test_comp, N_pred_comp, inputs, suffix + '_gold_std_prots') with open(out_comp_nm + '_metrics.out', "a") as fid: print("-- Finished writing main metrics -- \n", file=fid) logging_info("Finished evaluating basic metrics for complexes " + suffix)
async def scoresaber(self, ctx, argument1=None): if argument1 is not None: ctx.author = await userID(self, argument1) if ctx.author is None: return await ctx.send( "Sorry Senpai, I can't find anyone with that ID qwq") logging_info(f"Argument given, now {ctx.author.name}") async with ctx.channel.typing(): ref = dab.collection("users").document(str(ctx.author.id)).get() if ref.exists is False: await ctx.send("Sorry Senpai, that user isn't in my database!") return logging_info("scoresaber is None\n----------") scoresaber = ref.get('scoresaber') SS_id = scoresaber[25:] URL = (f"https://new.scoresaber.com/api/player/{SS_id}/full") logging_info(URL) response = get(URL, headers=header) json_data = loads(response.text) if "error" in json_data: return await ctx.send( "Uh Oh, the codie wodie did an oopsie woopsie! uwu\nCheck if your ScoreSaber link is valid <:AYAYASmile:789578607688417310>" ) playerInfo = json_data["playerInfo"] scoreStats = json_data["scoreStats"] embed = Embed( title=playerInfo["playerName"] + "'s ScoreSaber Stats <:WidePeepoHappy1:757948845362511992><:WidePeepoHappy2:757948845404585984><:WidePeepoHappy3:757948845400522812><:WidePeepoHappy4:757948845463306310>", url=scoresaber, colour=0xffdc1b, timestamp=ctx.message.created_at) embed.add_field(name="Global Rank 🌐", value=playerInfo["rank"], inline=True) embed.add_field(name=f"Country Rank :flag_" + playerInfo["country"].lower() + ":", value=playerInfo["countryRank"], inline=True) embed.add_field(name="PP <a:PogLick:792002791828357131>", value=playerInfo["pp"], inline=True) embed.add_field( name="Ranked Acc <:PeepoAcc:792385194351001610>", value=str(round(scoreStats["averageRankedAccuracy"], 2)) + "%", inline=True) embed.add_field( name="Total Play Count <a:ppJedi:754632378206388315>", value=scoreStats["totalPlayCount"], inline=True) embed.add_field(name="Ranked Play Count 🧑🌾", value=scoreStats["rankedPlayCount"], inline=True) embed.set_thumbnail(url="https://new.scoresaber.com" + playerInfo["avatar"]) await ctx.send(embed=embed)
async def pfp(self, ctx, argument): logging_info(f"Recieved user update pfp {ctx.author.name}") if argument[:4] != "http": logging_warning(f"Argument is not a link ({argument})") return await ctx.send( "Baka! You can only use links for your profile picture!") doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'pfp': argument}) await ctx.send("I've updated your pfp, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their pfp to {argument}\n----------" )
def split_meth_orig(perm_lines, inputs): fact = inputs['fact'] # 0.99 split_pt = int(round(len(perm_lines) * fact)) train_list = [line for line in perm_lines[0:split_pt]] test_list = [line for line in perm_lines[split_pt:]] # Start with something that has a biased size distribution !! sizes = [len(line) for line in train_list] train_mean = np_mean(sizes) # Transferring some of the smaller complexes to the test list train_list_lower_mean = [ line for line in train_list if len(line) < train_mean ] perc_transfer = inputs[ 'perc_transfer'] # 0.3 # You can optimize these parameters ! to_transfer = train_list_lower_mean[:int( round(len(train_list_lower_mean) * perc_transfer))] test_list = test_list + to_transfer # Now remove from train set for line in to_transfer: train_list.remove(line) # Finding complexes in train that share an edge with a complex in test com_comp = 10 while com_comp != 0: # Do until train and test sets are completely separated # Removing super huge complexes also (nodes >30 ) from test set test_list = [line for line in test_list if len(line) < 30] # REMOVE OVERLAP B/W TRAIN AND TEST DATA # Remove complexes from train set sharing two proteins with test set train_rem = [] train_rem_append = train_rem.append com_comp = 0 for train_line in train_list: pres = 0 for test_line in test_list: common = len( set(train_line.edges()).intersection(set(test_line.edges))) if common >= 1: pres = 1 break if pres == 1: train_rem_append(train_line) com_comp += 1 logging_info("No. of train complexes transferred = %s", str(com_comp)) test_list = test_list + train_rem for t_line in train_rem: train_list.remove(t_line) return train_list, test_list
async def colour(self, ctx, argument): logging_info(f"Recieved user update colour {ctx.author.name}") try: await commands.ColourConverter().convert(ctx, "0x" + argument) except Exception as e: await ctx.send("Please use a valid hexadecimal colour value. uwu") return logging_error(f"expect triggered: {e}") doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'colour': argument}) await ctx.send("I've updated your colour, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their colour to {argument}\n----------" )
async def scoresaber(self, ctx, argument): logging_info(f'Recieved user update scoresaber {ctx.author.name}') if argument.isdigit(): argument = "https://scoresaber.com/u/" + argument else: argument = argument.split("?", 1)[0] argument = argument.split("&", 1)[0] doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'scoresaber': argument}) await ctx.send("I've updated your Scoresaber, Senpai! >w<") logging_info( f"{ctx.author.name} has updated their scoresaber to {argument}\n----------" )
def extract_features(out_comp_nm, split_type, max_size, inputs, G_nodes, feat_list, X_pos, X_allpos, n_allpos, sizes): n_pos = len(X_pos) folNm = inputs['dir_nm'] + inputs['graph_files_dir'] + "/neig_dicts" dims = X_pos.shape n_feats = dims[1] with open(out_comp_nm + '_metrics.out', "a") as fid: print("No. of " + split_type + " features = ", n_feats, file=fid) print("No. of " + split_type + " positive complexes = ", n_pos, file=fid) logging_info("Constructing " + split_type + " negative complexes...") if "neg_sample_method" not in inputs: inputs["neg_sample_method"] = "uniform" neg_comp_list = construct_neg_comps(max_size, n_pos, inputs['scale_factor'], G_nodes, sizes, inputs["neg_sample_method"], folNm) logging_info("Finished constructing " + split_type + " negative complexes") X_neg = create_feat_mat(neg_comp_list, n_feats) X_neg, neg_comp_list, n_neg = remove_same_rows(n_allpos, X_neg, X_allpos, neg_comp_list) # print(n_neg) # HHANDLE CASE WHEN n_neg = 0 !!!!! with open(out_comp_nm + '_metrics.out', "a") as fid: print("No. of " + split_type + " negative complexes = ", n_neg, file=fid) write_neg2out(out_comp_nm + '_neg_' + split_type + '.out', out_comp_nm + '_neg_' + split_type + '_edges.out', neg_comp_list) X = np_vstack((X_pos, X_neg)) y_pos = [1] * n_pos y_neg = [0] * n_neg y = y_pos + y_neg y = np_array(y) y_pos = np_array(y_pos) y_neg = np_array(y_neg) # Writing raw training data to csv in tpot format write2csv_tpot(X, y, out_comp_nm + "_" + split_type + "_dat.csv", feat_list) return y, X, X_pos, y_pos, X_neg, y_neg
async def challonge(self, ctx): try: async with ctx.channel.typing(): messages = "" tournaments = tournaments_index() count = (len(tournaments) - 4) par_count = 0 #for x in (tournaments): for x in range(0, 4): tournament = tournaments[count] if tournament["state"] == "pending" or tournament[ "state"] == "underway": message = ( "{} - ID: {}\nStatus: Tourney currently {}\n". format(tournament["name"], tournament["id"], tournament["state"])) else: participants = participants_index(tournament["id"]) for x in participants: participant = participants[par_count] if participant["final_rank"] == 1: first = participant["name"] elif participant["final_rank"] == 2: second = participant["name"] elif participant["final_rank"] == 3: third = participant["name"] par_count = par_count + 1 par_count = 0 message = ( "**[{}]({}) - ID: {}**\n1st: {}, 2nd: {}, 3rd: {}\n" .format(tournament["name"], tournament["full_challonge_url"], tournament["id"], first, second, third)) messages = "\n" + message + messages count = count + 1 embed = Embed( title="Scuffed Tournaments", url= "https://challonge.com/users/scuffedtourney/tournaments", description=messages, colour=0xff7324, timestamp=ctx.message.created_at) await ctx.send(embed=embed) logging_info("responded with embed") except Exception as e: logging_error(f"Uh Oh it did a fucky\n{e}") await ctx.send( "I'm sorry, S-Senpai. I messed up your command qwq. Here's the challonge link instead >w< \n<https://challonge.com/users/scuffedtourney/tournaments>" )
async def job(self, ctx): try: job = dab.collection('users').document(str( ctx.author.id)).get().get('job') except: job = False if job is True: jtype = dab.collection('users').document(str( ctx.author.id)).get().get('jtype') await ctx.send( f'You are currently working as a {jtype}! I\'m so proud of you senpai UwU' ) logging_info(f'Response: job is {jtype}\n----------') else: await ctx.send('You should get a job first senpai!')
async def hmd(self, ctx, *, argument): logging_info(f'Recieved user update hmd {ctx.author.name}') valid_HMD_low = [x.lower() for x in self.bot.valid_HMD] try: pos = valid_HMD_low.index(argument.lower()) except: logging_warning(f"{argument} not in valid_HMD") return await ctx.send( "BAKA!! That HMD isn't valid!\n``Use >help update to check the valid HMDs``" ) doc_ref = dab.collection("users").document(str(ctx.author.id)) doc_ref.update({'hmd': self.bot.valid_HMD[pos]}) await ctx.send( f"I've updated Senpai's HMD to {self.bot.valid_HMD[pos]}! >w<") logging_info( f"{ctx.author.name} has updated their status to {self.bot.valid_HMD[pos]}\n----------" )
async def gib(self, ctx, argument, argument2: int): if str(ctx.author.id) != '303017061637160961': if '@' in argument: argument = argument[3:] argument = argument[:-1] bal = dab.collection('users').document(argument).get().get('bal') bal = bal + int(argument2) dab.collection('users').document(argument).update({'bal': bal}) a = ctx.guild.get_member(int(argument)) await ctx.send( f'Given {argument2} Coins to {a.name}. their total is now {bal}' ) logging_info('Response: inv embed\n----------') else: await ctx.send(f'F**k you james <:KEK:819309467208122388>') logging_info( 'Response: james is trying to cheat again...\n----------')
async def on_member_remove(self, member): logging_info(f"{member.name} ({member.id}) has left the server") try: col_ref = dab.collection('users').document( 'collectionlist').get().get('array') col_ref.remove(str(member.id)) dab.collection('users').document('collectionlist').update( {'array': col_ref}) dab.collection("users").document(str(member.id)).delete() await self.bot.get_channel(754625185306378271).send( f"{member.name} ({member.id}) has left the server and been successfully removed from the database" ) logging_info( f"Response: {member.id} has been successfully removed to the database\n----------" ) except Exception as e: logging_error(e)
def transfer_common(test_list, train_list): # Test to train test_rem = [] test_rem_append = test_rem.append com_comp = 0 for test_line in test_list: pres = check_overlap(train_list, test_line) if pres == 1: com_comp += 1 test_rem_append(test_line) logging_info("No. of transfers = %s", str(com_comp)) train_list = train_list + test_rem for t_line in test_rem: test_list.remove(t_line) train_list = list(rand_perm(train_list)) test_list = list(rand_perm(test_list)) return test_list, train_list, com_comp, test_rem
async def work(self, ctx): try: job = dab.collection('users').document(str( ctx.author.id)).get().get('job') except: job = False if job is True: pro = randint(0, 666) bal = dab.collection('users').document(str( ctx.author.id)).get().get('bal') bal = bal + pro dab.collection('users').document(str(ctx.author.id)).update( {'bal': bal}) await ctx.send(f'WOW! You made a whole {pro} coins!') logging_info( f'Response: user {ctx.author.id} has earned {pro}, their total is {bal}\n----------' ) else: await ctx.send('You should get a job first senpai! try >job get')