def display_moves_by_input(character, original_move): character_move = tkfinder.get_move(character, original_move) character_name = character["name"] if character_move is not None: result = embed.move_embed(character, character_move) else: generic_move = tkfinder.get_generic_move(original_move) if generic_move is not None: generic_character = tkfinder.get_character_detail("generic") result = embed.move_embed(generic_character, generic_move) else: similar_moves = tkfinder.get_similar_moves(original_move, character_name) result = embed.similar_moves_embed(similar_moves, character_name) return result
def display_moves_by_input(character, original_move): character_move = tkfinder.get_move(character, original_move) character_name = character["name"] result = {} if character_move is not None: result["embed"] = embed.move_embed(character, character_move) else: generic_move = tkfinder.get_generic_move(original_move) if generic_move is not None: generic_character = tkfinder.get_character_detail("generic") result["embed"] = embed.move_embed(generic_character, generic_move) else: similar_moves = tkfinder.get_similar_moves(original_move, character_name) result["embed"] = embed.similar_moves_embed( similar_moves, character_name) if character_move and "Tags" in character_move and len( character_move["Tags"]) > 0: result["components"] = ActionRow(create_components(character_move)) return result
def test_get_close_moves(self): close_moves = tkfinder.get_similar_moves("d/f+1, 2", "hwoarang") self.assertIn("d/f+1,3", close_moves)
async def on_message(message): """This has the main functionality of the bot. It has a lot of things that would be better suited elsewhere but I don't know if I'm going to change it.""" try: channel = message.channel if message.content == "?credit": await channel.send(embed=embed.thank_embed()) return elif message.content == '!help': await channel.send(embed=embed.help_embed()) return elif message.content == '!clear-messages': await channel.purge(limit=200, check=is_me) return elif message.content.startswith('?feedback'): user_message = message.content.split(' ', 1)[1] server_name = str(message.channel.guild) try: feedback_channel = bot.get_channel(const.FEEDBACK_CHANNEL_ID) user_message = user_message.replace("\n", "") result = "{} ; {} ; {};\n".format(str(message.author), server_name, user_message) await feedback_channel.send(result) await channel.send(embed=embed.success_embed("Feedback sent")) except Exception as e: await channel.send(embed=embed.error_embed( "Feedback couldn't be sent caused by: " + e)) return elif message.content.startswith('!'): delete_after = 20 if ('tekken' in channel.name) or ('frame' in channel.name): delete_after = None user_message = message.content command = user_message[1:] user_message_list = command.split(' ', 1) if len(user_message_list) <= 1: # malformed command return original_name = user_message_list[0].lower() original_move = user_message_list[1] character_name = tkfinder.correct_character_name(original_name) if character_name is not None: character = tkfinder.get_character_data(character_name) character_move = original_move.lower() if original_move.lower() in const.MOVE_TYPES.keys(): move_list = tkfinder.get_by_move_type( character, const.MOVE_TYPES[character_move]) if len(move_list) < 1: result = embed.error_embed( 'No ' + const.MOVE_TYPES[character_move].lower() + ' for ' + character['proper_name']) await channel.send(embed=result, delete_after=delete_after) elif len(move_list) == 1: character_move = tkfinder.get_move( character, move_list[0]) result = embed.move_embed(character, character_move) await channel.send(embed=result, delete_after=delete_after) elif len(move_list) > 1: result = embed.move_list_embed( character, move_list, const.MOVE_TYPES[character_move]) await channel.send(embed=result, delete_after=delete_after) else: character_move = tkfinder.get_move(character, original_move) # First checks the move as case sensitive, if it doesn't find it # it checks it case insensitive if character_move is not None: result = embed.move_embed(character, character_move) await channel.send(embed=result, delete_after=delete_after) else: character_move = tkfinder.get_move( character, original_move) if character_move is not None: result = embed.move_embed(character, character_move) await channel.send(embed=result, delete_after=delete_after) else: similar_moves = tkfinder.get_similar_moves( original_move, character_name) result = embed.similar_moves_embed(similar_moves) await channel.send(embed=result, delete_after=delete_after) else: bot_msg = f'Character {original_name} does not exist.' result = embed.error_embed(bot_msg) await message.channel.send(embed=result, delete_after=5) return await bot.process_commands(message) except Exception as e: print(e) logger.error(e)
async def on_message(message): """This has the main functionality of the bot. It has a lot of things that would be better suited elsewhere but I don't know if I'm going to change it.""" try: channel = message.channel if message.content.startswith("!auto-delete"): if message.author.permissions_in(channel).manage_messages: duration = message.content.split(' ', 1)[1] if duration.isdigit() or duration == "-1": config.save_auto_delete_duration(channel.id, duration) await channel.send(embed=embed.success_embed("Saved")) else: await channel.send(embed=embed.error_embed( "Duration needs to be a number in seconds")) else: await channel.send(embed=embed.error_embed( "You need the permission <manage_messages> to do that")) return elif message.content == '!help': await channel.send(embed=embed.help_embed()) return elif message.content.startswith('?feedback'): user_message = message.content.split(' ', 1)[1] server_name = str(message.channel.guild) try: feedback_channel = bot.get_channel(feedback_channel_id) user_message = user_message.replace("\n", "") result = "{} ; {} ; {};\n".format(str(message.author), server_name, user_message) await feedback_channel.send(result) await channel.send(embed=embed.success_embed("Feedback sent")) except Exception as e: await channel.send(embed=embed.error_embed( "Feedback couldn't be sent caused by: " + e)) return elif message.content.startswith('!'): delete_after = config.get_auto_delete_duration(channel.id) user_message = message.content command = user_message[1:] user_message_list = command.split(' ', 1) if len(user_message_list) <= 1: # malformed command return original_name = user_message_list[0].lower() original_move = user_message_list[1] character_name = tkfinder.correct_character_name(original_name) if character_name is not None: character = tkfinder.get_character_data(character_name) character_move = original_move.lower() if original_move.lower() in const.MOVE_TYPES.keys(): move_list = tkfinder.get_by_move_type( character, const.MOVE_TYPES[character_move]) if len(move_list) < 1: result = embed.error_embed( 'No ' + const.MOVE_TYPES[character_move].lower() + ' for ' + character['proper_name']) await channel.send(embed=result, delete_after=delete_after) elif len(move_list) == 1: character_move = tkfinder.get_move( character, move_list[0]) result = embed.move_embed(character, character_move) await channel.send(embed=result, delete_after=delete_after) elif len(move_list) > 1: result = embed.move_list_embed( character, move_list, const.MOVE_TYPES[character_move]) await channel.send(embed=result, delete_after=delete_after) else: character_move = tkfinder.get_move(character, original_move) if character_move is not None: result = embed.move_embed(character, character_move) await channel.send(embed=result, delete_after=delete_after) else: similar_moves = tkfinder.get_similar_moves( original_move, character_name) result = embed.similar_moves_embed(similar_moves) await channel.send(embed=result, delete_after=delete_after) else: bot_msg = f'Character {original_name} does not exist.' result = embed.error_embed(bot_msg) await message.channel.send(embed=result, delete_after=5) return await bot.process_commands(message) except Exception as e: error_msg = f'Message: {message.content}. Error: {e}' print(error_msg) logger.error(error_msg)