Ejemplo n.º 1
0
    async def upgrade(self, ctx: commands.Context, faction=None, number=None):
        """Retrieves information of a Faction Upgrade from Not-a-Wiki"""
        if faction in ['help', 'Help'] or (faction == None and number == None):
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.upgrade <faction>**\n**Aliases: **" + ', '.join(alias["upgrade"]) + \
                          "\n\nRetrieves a Faction upgrade information " \
                          "directly from Not-a-Wiki. <faction> inputs can be using two-letter Mercenary Template with " \
                          "upgrade number, or full Faction name with an upgrade number.\n\nExamples: Fairy 7, MK10 "
            embed = discord.Embed(title=f"{emoji}  Upgrade", description=description, colour=self.color)
            return await ctx.send(embed=embed)

        # Checking if input returns an abbreviation faction i.e. FR7 or MK11, also accepts lowercase inputs
        if faction[2].isdigit() and number is None:
            faction = faction.upper()
            color = FactionUpgrades.getFactionColour(faction[0:2])

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Some people just like to watch the world burn
            if int(number) < 1 or int(number) > 12:
                raise Exception("The upgrade number must be between 1 and 12, Your Majesty.")

            faction = faction.lower()
            faction = faction.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(faction)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception("I seem to can\'t find that upgrade anywhere, Your Majesty.")
            else:
                faction = fac + number

        # if inputs match neither above, raise Exception
        else:
            raise Exception("I seem to can\'t find that upgrade anywhere, Your Majesty.")

        async with ctx.channel.typing():
            # We get our list through Not-a-Wiki Beautiful Soup search
            upgradeEmbed = NaWSearch.factionUpgrade(faction)
            author: discord.Member = ctx.author

            # Embed things, using the list retrieved from factionUpgradeSearch
            title = f'**{upgradeEmbed[1]}**'
            embed = discord.Embed(title=title, colour=discord.Colour(color), timestamp=datetime.datetime.utcnow())
            embed.set_footer(text="http://musicfamily.org/realm/FactionUpgrades/",
                             icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                 .set_thumbnail(url=upgradeEmbed[0]) \
                 .set_author(name=author, icon_url=author.avatar_url)

            # Since the first two lines always are guaranteed to be an url and name of Faction upgrade, we ignore
            # them, and then start processing adding new fields for each line
            try:
                for line in upgradeEmbed[2:]:
                    line = line.split(": ")
                    embed.add_field(name=f'**{line[0]}**', value=line[1], inline=False)
            except IndexError:
                return await ctx.send('There is something wrong with this upgrade. Notify Alright#2304')

        await ctx.send(embed=embed)
Ejemplo n.º 2
0
    async def lineage(self, ctx: commands.Context, faction=None, number=None):
        if (faction is None and number is None) or faction == "help":
            description = "**.lineage <faction> <perk>**\n**Aliases: **" + ', '.join(
                alias["lineage"]) + "\n\nRetrieves the " \
                                    "Lineage info from Not-a-Wiki in an embed displaying name, cost, formula, and effect. Also includes challenges." \
                                    "\n\nAcceptable inputs include full or shortened faction names, plus the number of perk (can be left empty to get base effect)." \
                                    "\n\nExample: .lineage Fairy, .line Dwarf 4, .l ARP5"
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            embed = discord.Embed(title=f"{emoji}  Research", description=description, colour=self.color)
            return await ctx.send(embed=embed)

        if len(faction) == 2:
            faction = faction.upper()
            colour = FactionUpgrades.getFactionColour(faction)
            faction = FactionUpgrades.getFactionNameFull(faction)
            if not faction:
                raise Exception('Invalid Input')
        elif len(faction) == 4 and faction[2].lower() == 'p':
            number = faction[3]
            faction = faction[0:2].upper()
            colour = FactionUpgrades.getFactionColour(faction)
            faction = FactionUpgrades.getFactionNameFull(faction)
            if not faction:
                raise Exception ('Invalid Input')
        else:
            faction = faction.lower()
            faction = faction.capitalize()
            colour = FactionUpgrades.getFactionColour(faction)

        # TODO: Add "p" as part of 1st parameter

        # nobody calls elf/dwarf "Elven/Dwarven", it's not hip
        if faction == 'Elf':
            faction = 'Elven'
        elif faction == 'Dwarf':
            faction = 'Dwarven'

        async with ctx.channel.typing():
            lineageEmbed = NaWSearch.lineage(faction, number)

            title = f'{lineageEmbed[1]}'
            author: discord.Member = ctx.message.author

            embed = discord.Embed(title=title, colour=discord.Colour(colour))
            embed.set_footer(text="http://musicfamily.org/realm/Lineages/",
                             icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                 .set_thumbnail(url=lineageEmbed[0]) \
                 .set_author(name=author, icon_url=author.avatar_url)

            for line in lineageEmbed[2:]:
                line = line.split(": ")
                embed.add_field(name=f'**{line[0]}**', value=line[1], inline=False)

        await ctx.send(embed=embed)
Ejemplo n.º 3
0
    async def bloodline(self, ctx: commands.Context, faction=None):
        if faction in ['help', 'Help'] or faction == None:
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.bloodline <faction>**\n**Aliases: **" + ', '.join(alias["bloodline"]) + \
                          "\n\nRetrieves the Bloodline info from the wiki. " \
                          "<faction> inputs can be using two-letter Mercenary Template, or the full Faction name. " \
                          "\n\nExamples: .bloodline Fairy, .bl AR "
            embed = discord.Embed(title=f"{emoji}  Bloodline", description=description, colour=self.color)
            return await ctx.send(embed=embed)

        if len(faction) == 2:
            faction = faction.upper()
            faction = FactionUpgrades.getFactionNameFull(faction)
            if faction is None:
                raise Exception("Invalid Input")
            color = FactionUpgrades.getFactionColour(faction)
        else:
            faction = faction.lower()
            faction = faction.capitalize()
            if faction == "Dwarven":
                color = FactionUpgrades.getFactionColour("Dwarf")
                faction = "Dwarf"
            elif faction == "Elven":
                color = FactionUpgrades.getFactionColour("Elf")
            else:
                color = FactionUpgrades.getFactionColour(faction)

        if faction in ["EL", "Elf"]:
            faction = "Elven"

        async with ctx.channel.typing():
            bloodlineEmbed = NaWSearch.bloodline(faction)
            author: discord.Member = ctx.message.author

            embed = discord.Embed(title=bloodlineEmbed[1] + " Bloodline", colour=discord.Colour(color)) \
                .set_footer(text="http://musicfamily.org/realm/Bloodline/",
                            icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                .set_author(name=author, icon_url=author.avatar_url) \
                .set_thumbnail(url=bloodlineEmbed[0])

            for line in bloodlineEmbed[2:]:
                try:
                    line = line.split(": ")
                    embed.add_field(name=f'**{line[0]}**', value=line[1], inline=False)
                except Exception as e:
                    print(e)

        await ctx.send(embed=embed)
Ejemplo n.º 4
0
    async def combo(self, ctx: commands.Context, faction1: str = None, faction2: str = None):
        print(type(faction1), type(faction2))
        if (faction1 in ['Help', 'help']) or (faction1 is None and faction2 is None):
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.combo <faction1> <faction2>**\n**Aliases: **" + ', '.join(alias["combo"]) + \
                          "\n\nRetrieves the Legacy Combo info from the wiki. " \
                          "<faction> inputs can be using two-letter Mercenary Template or the full Faction name. " \
                          "\n\nExamples: .combo Fairy Demon, .lc UD EL"
            embed = discord.Embed(title=f"{emoji} Legacy Combo", description=description, colour=self.color)
            return await ctx.send(embed=embed)

        if len(faction1) == 2:
            faction1 = faction1.upper()
        else:
            check1, faction1, ignore1 = FactionUpgrades.getFactionAbbr(faction1.capitalize())

        if len(faction2) == 2:
            faction2 = faction2.upper()
        else:
            check2, faction2, ignore2 = FactionUpgrades.getFactionAbbr(faction2.capitalize())

        print(faction1, faction2)

        if not faction1 or not faction2 or faction1 == faction2:
            raise Exception("Invalid User Input")

        async with ctx.channel.typing():
            legacyEmbed = NaWSearch.legacyCombo(faction1, faction2)
            author: discord.Member = ctx.message.author
            color = discord.Colour.dark_green()

            embed = discord.Embed(title=legacyEmbed[1], colour=color) \
                .set_footer(text="http://musicfamily.org/realm/Legacies/",
                            icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                .set_author(name=author, icon_url=author.avatar_url) \
                .set_thumbnail(url=legacyEmbed[0])

            for line in legacyEmbed[2:]:
                try:
                    line = line.split(": ", maxsplit = 1)
                    embed.add_field(name=f'**{line[0]}**', value=line[1], inline=False)
                except Exception as e:
                    print(e)

        await ctx.send(embed=embed)
Ejemplo n.º 5
0
def factionUpgradeSearch(faction):
    # Getting the Upgrade from FactionUpgrades
    factionUpgrade = FactionUpgrades.getFactionUpgradeName(faction)

    # Retrieving data using Request and converting to BeautifulSoup object
    nawLink = "http://musicfamily.org/realm/FactionUpgrades/"
    content = requests.get(nawLink)
    soup = BeautifulSoup(content.content, 'html5lib')

    # Searching tags starting with <p>, which upgrades' lines on NaW begin with
    p = soup.find_all('p')

    # Our upgrade info will be added here
    screen = []

    # Iterating through p, finding until upgrade matches
    for tag in p:
        # space is necessary because there is always one after image
        if tag.get_text() == " " + factionUpgrade:
            # if True, adds full line so we can retrieve the image through our formatting function
            screen.append(str(tag))

            # Since we return true, we search using find_all_next function, and then break it there since we don't
            # need to iterate anymore at the end
            for line in tag.find_all_next(['p', 'br', 'hr', 'div']):
                # Not-a-Wiki stops lines after a break, a new line, or div, so we know the upgrade info stop there
                if str(line) == "<br/>" or str(line) == "<hr/>" or str(
                        line).startswith("<div"):
                    break
                else:
                    # Otherwise, add the lines of upgrade to the list - line.text returns the text without HTML tags
                    screen.append(line.text)
            break

    # Then we run the list through a formatter, and that becomes our new list
    return format(screen, factionUpgrade)
Ejemplo n.º 6
0
    async def challenge(self, ctx: commands.Context, faction=None, number=None):
        """Retrieves information of a Faction Challenge from Not-a-Wiki"""
        # Help command
        if faction in ['help', 'Help'] or (faction == None and number == None):
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.challenge <faction>**\n**Aliases: **" + ', '.join(alias["challenge"]) + "\n\nRetrieves " \
                          "challenge info from Not-a-Wiki displaying name, requirements, effects, and formulas. Valid " \
                          "inputs include using faction name and the challenge number, or r for spell challenge " \
                          "reward. Mercenary templates in place of full name can be used, adding C# or \"R\".\n\nExample: " \
                          "Fairy 2, Makers r, DGC5, DJR"
            embed = discord.Embed(title=f"{emoji}  Challenge", description=description,
                                  colour=self.color)
            return await ctx.send(embed=embed)

        # Too many people call Mercenary "merc" so this is to make it easier
        if faction in ["merc", "Merc"]:
            faction = "Mercenary"

        # Checking if input returns an abbreviation faction i.e. FR2 or MK5, also accepts lowercase inputs
        if faction[2].isdigit() or faction[2] in ["R", "r", "C", "c"] and number is None:
            if faction[2] in ["C", "c"]:
                faction = faction[:2] + faction[3:]
            faction = faction.upper()
            factionColor = faction[0:2]
            color = FactionUpgrades.getFactionColour(factionColor)
            # No huge dictionary this time around
            faction2 = FactionUpgrades.getFactionNameFull(factionColor)
            faction = faction2 + faction[0] + "C" + faction[2:]

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Number checker has been moved to factionChallengeSearch()
            faction = faction.lower()
            faction = faction.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(faction)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception('Invalid Input')
            else:
                faction = faction + faction[0] + "C" + str(number).upper()

        # if inputs match neither above, raise Exception
        else:
            raise Exception('Invalid Input')

        async with ctx.channel.typing():
            challengeEmbed = NaWSearch.challenge(faction)
            author: discord.Member = ctx.message.author

            embed = discord.Embed(title=f'**{challengeEmbed[1]}**', colour=discord.Colour(color), timestamp=datetime.datetime.utcnow()) \
                .set_footer(text="http://musicfamily.org/realm/Challenges/",
                            icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                .set_thumbnail(url=challengeEmbed[0]) \
                .set_author(name=author, icon_url=author.avatar_url)

            if faction == "MercenaryMCR":
                return await ctx.send(
                    'This challenge reward is disabled for a bit due to the embed being too large. See: http://musicfamily.org/realm/Challenges/')

            # Ignore the first 4 fields and create the rest
            for line in challengeEmbed[2:]:
                newline = line.split(": ")
                embed.add_field(name=f'**{newline[0]}**', value=newline[1], inline=False)

        await ctx.send(embed=embed)
Ejemplo n.º 7
0
    async def research(self, ctx, researchName=None):
        """Retrieves Research upgrade from Not-a-Wiki"""
        global image

        # Help command
        if researchName is None or researchName == "help":
            description = "**.research <research>**\n**Aliases: **" + ', '.join(alias["research"]) + "\n\nRetrieves the " \
                    "Research info from Not-a-Wiki in an embed displaying name, cost, formula, and effect." \
                    "\n\nAcceptable inputs are only using research branch + number (i.e. S10, C340, E400)."
            emoji = discord.utils.get(ctx.guild.emojis,
                                      name="SuggestionMaster")
            embed = discord.Embed(title=f"{emoji}  Research",
                                  description=description,
                                  colour=discord.Colour.dark_green())
            return await ctx.send(embed=embed)

        # Capitalizing researchName, adding check and importing the research dict
        researchName = researchName.upper()
        check = False
        rbranch = FactionUpgrades.getResearchBranch()

        # Checks if first letter is an alphabet and the input after 0th index are digits
        if researchName[0].isalpha() and researchName[1:].isdigit():
            for key, value in rbranch.items():
                if key[0] == researchName[0]:
                    image = value
                    check = True

        if not check:
            raise Exception("Invalid Input")

        async with ctx.channel.typing():
            data = researchSearch(researchName)

            # data[0] and data[2] returns the shorthand research and the name of research
            title = f'{data[0]} - {data[2]}'

            # mostly "For x factions"
            description = data[1]

            embed = discord.Embed(title=title,
                                  description=description,
                                  colour=discord.Colour.dark_green())
            embed.set_footer(
                text="http://musicfamily.org/realm/Researchtree/",
                icon_url=
                "http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png"
            )
            embed.set_thumbnail(url=image)

            # Cleaning the list a little, removing white spaces and also </p> that the re.compile didn't catch
            for line in data[3:]:
                line = line.strip()
                if line.endswith("</p>"):
                    line = line.replace("</p>", "")
                newLine = line.split(": ")
                embed.add_field(name=f'**{newLine[0]}**',
                                value=newLine[1],
                                inline=True)

        await ctx.send(embed=embed)
Ejemplo n.º 8
0
    async def challenge(self, ctx, arg=None, number=None):
        """Retrieves information of a Faction Challenge from Not-a-Wiki"""
        global color
        global faction

        # Help panel in case of no input
        if (arg is None and number is None) or (arg == "help"
                                                and number is None):
            emoji = discord.utils.get(ctx.guild.emojis,
                                      name="SuggestionMaster")
            description = "**.challenge <faction>**\n**Aliases: **" + ', '.join(alias["challenge"]) + "\n\nRetrieves " \
                        "challenge info from Not-a-Wiki displaying name, requirements, effects, and formulas. Valid " \
                        "inputs include using faction name and the challenge number, or r for spell challenge " \
                        "reward.\n\nExample: Fairy 2, Makers r"
            embed = discord.Embed(title=f"{emoji}  Challenge",
                                  description=description,
                                  colour=discord.Colour.dark_gold())
            return await ctx.send(embed=embed)

        # Checking if input returns an abbreviation faction i.e. FR2 or MK5, also accepts lowercase inputs
        if arg[2].isdigit() or arg[2] in ["R", "r", "C", "c"
                                          ] and number is None:
            if arg[2] in ["C", "c"]:
                arg = arg[:2] + arg[3:]
            faction = arg.upper()
            argColor = faction[0:2]
            color = FactionUpgrades.getFactionColour(argColor)
            # No huge dictionary this time around
            faction2 = FactionUpgrades.getFactionNameFull(argColor)

            faction = faction2 + faction[0] + "C" + faction[2:]

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Number checker has been moved to factionChallengeSearch()
            arg2 = arg.lower()
            arg2 = arg2.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(arg2)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception('Invalid Input')
            else:
                faction = arg2 + arg2[0] + "C" + str(number).upper()

        # if inputs match neither above, raise Exception
        else:
            raise Exception('Invalid Input')

        async with ctx.channel.typing():
            # We get our list through Not-a-Wiki Beautiful Soup search
            # factionChallengeSearch takes parameters like "FairyFC1" or "FacelessFC1" (note the similar last 3 characters)
            data = factionChallengeSearch(faction)

            ignore = 4

            # Embed things, using the list retrieved from factionChallengeSearch
            thumbnail = data[0]
            # Spell rewards need special formatting
            if faction[-1:] == "R":
                title = f'**{data[1]}**'
                ignore = 3
            else:
                title = f'**{data[2]} : {data[1]}**'
            embed = discord.Embed(title=title,
                                  colour=discord.Colour(color),
                                  timestamp=datetime.datetime.utcnow())
            embed.set_footer(
                text="http://musicfamily.org/realm/Challenges/",
                icon_url=
                "http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png"
            )
            embed.set_thumbnail(url=thumbnail)

            # Ignore the first 4 fields and create the rest
            for line in data[ignore:]:
                newline = line.split(": ")
                first = f'**{newline[0]}**'
                embed.add_field(name=first, value=newline[1], inline=True)

        await ctx.send(embed=embed)
Ejemplo n.º 9
0
    async def upgrade(self, ctx, arg=None, number=None):
        """Retrieves information of a Faction Upgrade from Not-a-Wiki"""
        global color
        global faction

        # basic Help command
        if (arg is None and number is None) or (arg == "help"
                                                and number is None):
            emoji = discord.utils.get(ctx.guild.emojis,
                                      name="SuggestionMaster")
            description = "**.upgrade <faction>**\n**Aliases: **" + ', '.join(alias["upgrade"]) + \
                          "\n\nRetrieves a Faction upgrade information " \
                          "directly from Not-a-Wiki. <faction> inputs can be using two-letter Mercenary Template with " \
                          "upgrade number, or full Faction name with an upgrade number.\n\nExamples: Fairy 7, MK10 "
            embed = discord.Embed(title=f"{emoji}  Upgrade",
                                  description=description,
                                  colour=discord.Colour.dark_gold())
            return await ctx.send(embed=embed)

        # Checking if input returns an abbreviation faction i.e. FR7 or MK11, also accepts lowercase inputs
        if arg[2].isdigit() and number is None:
            faction = arg.upper()
            argColor = faction[0:2]
            color = FactionUpgrades.getFactionColour(argColor)

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Some people just like to watch the world burn
            if int(number) < 0 or int(number) > 12:
                raise Exception('Invalid Input')

            arg2 = arg.lower()
            arg2 = arg2.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(arg2)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception('Invalid Input')
            else:
                faction = fac + number

        # if inputs match neither above, raise Exception
        else:
            raise Exception('Invalid Input')

        async with ctx.channel.typing():
            # We get our list through Not-a-Wiki Beautiful Soup search
            data = factionUpgradeSearch(faction)

            # Embed things, using the list retrieved from factionUpgradeSearch
            thumbnail = data[0]
            title = f'**{data[1]}**'
            embed = discord.Embed(title=title,
                                  colour=discord.Colour(color),
                                  timestamp=datetime.datetime.utcnow())
            embed.set_footer(
                text="http://musicfamily.org/realm/FactionUpgrades/",
                icon_url=
                "http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png"
            )
            embed.set_thumbnail(url=thumbnail)

            # Since the first two lines always are guaranteed to be an url and name of Faction upgrade, we ignore
            # them, and then start processing adding new fields for each line
            for line in data[2:]:
                newline = line.split(": ")
                first = f'**{newline[0]}**'
                embed.add_field(name=first, value=newline[1], inline=True)

        await ctx.send(embed=embed)