async def on_message(message): # Ignore bots completely (including ourself) if message.author.bot: return if dbg.should_ignore_message(message): return try: # Check if we need to congratulate a user on getting a new role lvl_up_message = await tr.user_speaks(message.author) if lvl_up_message != None: await message.channel.send(lvl_up_message) # Check if someone is trying to use a bot command if message.content != "" and message.content[0] == CMD_PREFIX: prefix_removed = utils.strip_prefix(message.content) if prefix_removed == "": return command = utils.get_command(prefix_removed) if command in FUNC_DICT: # First, check if they're using a built-in command output_message = await FUNC_DICT[command](message) if output_message != None: await message.channel.send(output_message) elif cc.command_available(command): # Check if they're using a user-defined command cmd_output = cc.parse_response(message) await message.channel.send(cmd_output) except discord.errors.HTTPException as e: print("HTTPException: {}".format(str(e))) pass
def parse_input(input): rule_segment, my_ticket_segment, other_ticket_segment = input.split('\n\n') rules = { name: values for name, values in (parse_rule(rule) for rule in rule_segment.splitlines()) } my_ticket = [ int(s) for s in strip_prefix(my_ticket_segment, 'your ticket:\n').split(',') ] print(my_ticket) other_tickets = [ [int(s) for s in line.split(',')] for line in strip_prefix( other_ticket_segment, 'nearby tickets:\n').splitlines() ] return rules, my_ticket, other_tickets
def parse_response(self, message): prefix_removed = utils.strip_prefix(message.content) command = utils.get_command(prefix_removed) response = self.cmd_dict[command] # Check if they want to embed a ping within the response mentioned_id = parse_mention(message) if mentioned_id != None: ping = "<@!{}>".format(mentioned_id) else: ping = "" response = response.replace("%mention%", ping) return response
async def on_message(message): # Do not react to our own messages if message.author.id == client.user.id: return try: # Check if someone is using a bot command if message.content != "" and message.content[0] == CMD_PREFIX: prefix_removed = utils.strip_prefix(message.content) if prefix_removed == "": return command = utils.get_command(prefix_removed) if command in FUNC_DICT: output = await FUNC_DICT[command](message) if output != None: await message.channel.send(output) except Exception as e: print(traceback.format_exc())
async def on_message(message): # Ignore bots completely (including ourself) if message.author.bot: return # Check first if we're toggling debug mode # Need to do this before we discard a message if dbg.check_toggle(message): await dbg.toggle_debug(message) return elif dbg.should_ignore_message(message): return try: # Keep track of the user's message for dynamic slowmode await thermo.user_spoke(message) # Check if we need to congratulate a user on getting a new role # Don't award XP if posting in specified disabled channels if message.channel.id not in XP_OFF: lvl_up_message = await tr.give_xp(message.author) if lvl_up_message != None: await message.channel.send(lvl_up_message) # Check if someone is trying to use a bot command if message.content != "" and message.content[0] == CMD_PREFIX: prefix_removed = utils.strip_prefix(message.content) if prefix_removed == "": return command = utils.get_command(prefix_removed) if command in FUNC_DICT: # First, check if they're using a built-in command output_message = await FUNC_DICT[command](message) if output_message != None: await message.channel.send(output_message) elif cc.command_available(command): # Check if they're using a user-defined command cmd_output = cc.parse_response(message) await message.channel.send(cmd_output) except discord.errors.HTTPException as e: print(f"HTTPException: {str(e)}") pass
def check_toggle(self, message): prefix_removed = strip_prefix(message.content) if prefix_removed == "" or message.content[0] != CMD_PREFIX: return False command = get_command(prefix_removed) return command == "debug"
gene_metadata = pd.read_table(lbs_dir / 'mutLBSgene_basic.txt') lbs_muts = pd.read_table(lbs_dir / 'mutLBSgene_tcga_cosmic_overlapped_mutations.txt') lbs_genes = sorted(set(lbs_muts.gene)) missing_from_tcga = set(lbs_genes) - set(genes) print('Genes in LBS data but not TCGA mutation data:', len(missing_from_tcga)) lbs_mut_set = set(zip(lbs_muts.gene, lbs_muts.nsSNV)) # set of tuples of (patient, gene, AA sub) brca_muts_in_lbs = set() for i, row in muts.iterrows(): if isinstance(row.HGVSp_Short, float): # null continue aa_sub = strip_prefix(row.HGVSp_Short, 'p.') patient = get_patient_barcode(row.Tumor_Sample_Barcode) gene = row.Hugo_Symbol if (gene, aa_sub) in lbs_mut_set: item = (patient, gene, aa_sub) brca_muts_in_lbs.add(item) print('Found LBS mut:', item) data_path = create_data_path('intersect_muts_lbs') lbs_mut_df = pd.DataFrame(list(brca_muts_in_lbs)) lbs_mut_df.columns = ['patient', 'gene', 'aa_sub'] tcga_mut_path = data_path / 'brca_lbs_muts.csv' print('Saving BRCA mutations in LBS DB to', tcga_mut_path) lbs_mut_df.to_csv(tcga_mut_path, index=None)