Exemplo n.º 1
0
    async def work(self, ctx):
        isSuccessful = random.choice([True, False, True, False, True, False])
        amount = int(random.randint(15, 50) * random.uniform(0.95, 2.95))

        embed = libneko.Embed(
            title=
            f"Work {'Successful <:le:808638475229986876>' if isSuccessful else 'Failed <:nogis:808638474646978560>'}"
        )

        if isSuccessful:
            embed.color = random.choice(
                [Color.green(), Color.blue(),
                 Color.blurple()])
            embed.add_field(name="Outcome:",
                            value=random.choice(
                                workOutcome[isSuccessful]).format(
                                    ctx.author, amount))
            await self.bot.eco.edit_money(ctx.author.id, amount, "wallet",
                                          "add")
        else:
            embed.color = random.choice(
                [Color.red(), Color.orange(), 0xffff00])
            embed.add_field(name="Outcome:",
                            value=random.choice(
                                workOutcome[isSuccessful]).format(ctx.author))
        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Invoked by {ctx.author}")

        try:
            await ctx.send(f"{ctx.author.mention}", embed=embed)
        except discord.errors.Forbidden:
            await ctx.send(
                f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )
Exemplo n.º 2
0
    async def add_role(self, ctx: Context, role: Role):

        if self.config.sismember(f"allowed_roles:{ctx.guild.id}", role.id):
            em = Embed(title="Polls Administration",
                       description=
                       f"{role.mention} is already allowed to conduct polls.",
                       color=Color.red())
            await ctx.send(embed=em, delete_after=5)

        else:
            self.config.sadd(f"allowed_roles:{ctx.guild.id}", role.id)
            em = Embed(
                title="Polls Administration",
                description=f"{role.mention} is now allowed to conduct polls.",
                color=Color.green())
            await ctx.send(embed=em, delete_after=5)
Exemplo n.º 3
0
    async def jf(self, ctx, dest, volume):
        """
        Calculates the cost by m3 for GreenSwarm Express contracts. Valid destinations at this point are: d-o, do, home, d-ojez, and jita
        """
        priceIn = 800
        priceOut = 500
        minimumValue = 5000000

        allowedIn = ['d-o', 'home', 'do', 'd-ojez']
        allowedOut = ['jita']

        if dest in allowedIn:
            costs = int(priceIn) * int(volume)
        elif dest in allowedOut:
            costs = int(priceOut) * int(volume)
        else:
            return await ctx.send('Please select a valid destination. For now, the only valid destnations are \'d-o\', \'home\', \'do\', \'d-ojez\', \'jita\'')
        if int(costs) < int(minimumValue):
            costs = 5000000
        embed = Embed(title='Cost to transport {} m3 to {}: {:,} isk'.format(volume, dest, costs))
        embed.color = Color.green()

        return await ctx.send(embed=embed)
Exemplo n.º 4
0
    async def list_roles(self, ctx: Context):
        role_ids = sorted(
            self.config.smembers(f"allowed_roles:{ctx.guild.id}"))

        if role_ids:
            roles = "\n".join([
                ctx.guild.get_role(int(role_id)).mention
                for role_id in role_ids
            ])
            em = Embed(
                title="Polls Administration",
                description=
                f"The following roles are allowed to conduct polls:\n{roles}",
                color=Color.green())
            await ctx.send(embed=em, delete_after=5)

        else:
            em = Embed(
                title="Polls Administration",
                description=
                "There are currently no roles allowed to conduct polls.",
                color=Color.red())
            await ctx.send(embed=em, delete_after=5)
Exemplo n.º 5
0
    async def price_check(self, ctx, markets, item_name: str = None):
        """
        do the price checks and post to Discord
        :param ctx:
        :param markets:
        :param item_name:
        :return:
        """

        has_thumbnail = False

        await ctx.trigger_typing()

        if item_name != "":
            embed = Embed(
                title="Price Lookup for {item_name}".format(
                    item_name=item_name),
                color=Color.green(),
            )

            for market in markets:
                embed.add_field(
                    name="{market_name} Market".format(
                        market_name=market["name"]),
                    value="Prices for {item_name} on the {market_name} Market."
                    .format(item_name=item_name, market_name=market["name"]),
                    inline=False,
                )

                market_data = requests.post(
                    "https://evepraisal.com/appraisal/structured.json",
                    json={
                        "market_name": market["api_key"],
                        "items": [{
                            "name": item_name
                        }],
                    },
                )

                if market_data.status_code == 200:
                    market_json = market_data.json()

                    if has_thumbnail is False:
                        embed.set_thumbnail(url=(
                            "https://images.evetech.net/types/{type_id}/icon?size=64"
                        ).format(type_id=market_json["appraisal"]["items"][0]
                                 ["typeID"]))

                        has_thumbnail = True

                    # sell order price
                    market_sell_order_price = f'{market_json["appraisal"]["items"][0]["prices"]["sell"]["min"]:,} ISK'  # noqa: E501

                    if (market_json["appraisal"]["items"][0]["prices"]["sell"]
                        ["order_count"] == 0):
                        market_sell_order_price = "No sell orders found"

                    embed.add_field(
                        name="Sell Order Price",
                        value=market_sell_order_price,
                        inline=True,
                    )

                    # buy order price
                    market_buy_order_price = f'{market_json["appraisal"]["items"][0]["prices"]["buy"]["max"]:,} ISK'  # noqa: E501

                    if (market_json["appraisal"]["items"][0]["prices"]["buy"]
                        ["order_count"] == 0):
                        market_buy_order_price = "No buy orders found"

                    embed.add_field(
                        name="Buy Order Price",
                        value=market_buy_order_price,
                        inline=True,
                    )
                else:
                    embed.add_field(
                        name="API Error",
                        value=
                        ("Couldn't not fetch the price for the {market_name} market."
                         ).format(market_name=market["name"]),
                        inline=False,
                    )
        else:
            embed = Embed(
                title="Price Lookup",
                color=Color.red(),
            )

            embed.add_field(
                name="Error",
                value=
                ("You forget to enter an item you want to lookup the price for ..."
                 ),
                inline=False,
            )

        return await ctx.send(embed=embed)
Exemplo n.º 6
0
    def build_embed(self):
        fmt_utc = "%H:%M:%S (UTC)\n%A %d. %b %Y"
        fmt = "%H:%M:%S (UTC %z)\n%A %d. %b %Y"
        url = None

        embed = Embed(title="Time")
        embed.colour = Color.green()

        embed.add_field(
            name="EVE Time",
            value=datetime.utcnow().strftime(fmt_utc),
            inline=False,
        )

        if timezones_active():
            from timezones.models import Timezones

            url = get_site_url() + reverse("timezones:index")
            configured_timezones = (
                Timezones.objects.select_related("timezone")
                .filter(is_enabled=True)
                .order_by("panel_name")
            )

            # get configured timezones from module setting
            if configured_timezones.count() > 0:
                for configured_timezone in configured_timezones:
                    embed.add_field(
                        name=configured_timezone.panel_name,
                        value=(
                            datetime.utcnow()
                            .astimezone(
                                pytz.timezone(
                                    configured_timezone.timezone.timezone_name
                                )
                            )
                            .strftime(fmt)
                        ),
                        inline=True,
                    )

            # get default timezones from module
            else:
                from timezones import __version__ as timezones_version
                from packaging import version

                if version.parse(timezones_version) >= version.parse("1.3.1"):
                    from timezones.constants import AA_TIMEZONE_DEFAULT_PANELS

                    configured_timezones = AA_TIMEZONE_DEFAULT_PANELS

                    for configured_timezone in configured_timezones:
                        embed.add_field(
                            name=configured_timezone["panel_name"],
                            value=(
                                datetime.utcnow()
                                .astimezone(
                                    pytz.timezone(
                                        configured_timezone["timezone"]["timezone_name"]
                                    )
                                )
                                .strftime(fmt)
                            ),
                            inline=True,
                        )

        # add url to the timezones module
        if url is not None:
            embed.add_field(
                name="Timezones Conversion",
                value=url,
                inline=False,
            )

        return embed
Exemplo n.º 7
0
    async def time(self, ctx):
        """
        Returns EVE Time
        """

        fmt_utc = "%H:%M:%S (UTC)\n%A %d. %b %Y"
        fmt = "%H:%M:%S (UTC %z)\n%A %d. %b %Y"
        url = None

        await ctx.trigger_typing()

        embed = Embed(title="Time")
        embed.colour = Color.green()

        embed.add_field(
            name="EVE Time",
            value=datetime.utcnow().strftime(fmt_utc),
            inline=False,
        )

        if timezones_active():
            from timezones.models import Timezones

            url = get_site_url() + "/timezones/"
            configured_timezones = Timezones.objects.filter(is_enabled=True)

            # get configured timezones from module setting
            if configured_timezones.count() > 0:
                for configured_timezone in configured_timezones:
                    embed.add_field(
                        name=configured_timezone.panel_name,
                        value=(datetime.utcnow().astimezone(
                            pytz.timezone(configured_timezone.timezone.
                                          timezone_name)).strftime(fmt)),
                        inline=True,
                    )

            # get default timezones from module
            else:
                from timezones import __version__ as timezones_version
                from packaging import version

                if version.parse(timezones_version) >= version.parse("1.3.1"):
                    from timezones.constants import AA_TIMEZONE_DEFAULT_PANELS

                    configured_timezones = AA_TIMEZONE_DEFAULT_PANELS

                    for configured_timezone in configured_timezones:
                        embed.add_field(
                            name=configured_timezone["panel_name"],
                            value=(datetime.utcnow().astimezone(
                                pytz.timezone(
                                    configured_timezone["timezone"]
                                    ["timezone_name"])).strftime(fmt)),
                            inline=True,
                        )

        # add url to the timezones module
        if url is not None:
            embed.add_field(
                name="Timezones Conversion",
                value=url,
                inline=False,
            )

        return await ctx.send(embed=embed)
Exemplo n.º 8
0
    async def jump(self, ctx, origin, dest, ship):
        if not origin:
            raise commands.BadArgument(
                'Missing required argument: \'origin\'.')
        if not dest:
            raise commands.BadArgument(
                'Missing required argument: \'destination\'.')
        if not ship:
            raise commands.BadArgument('Missing required argument: \'ship\'')
        origin = origin.capitalize()
        dest = dest.capitalize()
        ship = ship.capitalize()

        await ctx.trigger_typing()
        try:
            try:
                origin_lookup = self.bot.esi.search('solar_system', origin)
                origin_id = origin_lookup['solar_system'][0]
            except KeyError:
                embed = Embed(title='Origin not found')
                embed.color = Color.red()
                return await ctx.send(embed=embed)
            try:
                dest_lookup = self.bot.esi.search('solar_system', dest)
                dest_id = dest_lookup['solar_system'][0]

                dest_sheet_operation = self.bot.esi.esi.get_operation(
                    'get_universe_systems_system_id')
                dest_sheet = dest_sheet_operation.json(system_id=dest_id)

                dest_sec = round(float(dest_sheet['security_status']), 2)
                if dest_sec >= .50:
                    raise commands.BadArgument(
                        'You cannot jump to a high security system.')
            except KeyError:
                embed = Embed(title='Destination not found')
                embed.color = Color.red()
                return await ctx.send(embed=embed)

            try:
                ship_lookup = self.bot.esi.search('inventory_type', ship)
                ship_id = ship_lookup['inventory_type'][0]

                ship_sheet_operation = self.bot.esi.esi.get_operation(
                    'get_universe_types_type_id')
                ship_sheet = ship_sheet_operation.json(type_id=ship_id)

                dogma_attr = ship_sheet['dogma_attributes']
                if len(
                        list(
                            filter(lambda x: x['attribute_id'] == 861,
                                   dogma_attr))) == 1:
                    pass
                else:
                    embed = Embed(
                        title=f'The **{ship}** is not a jump capable ship.')
                    embed.color = Color.red()
                    embed.set_thumbnail(
                        url=f'https://image.eveonline.com/Type/{ship_id}_64.png'
                    )
                    return await ctx.send(embed=embed)
            except KeyError:
                embed = Embed(title='Ship not found')
                embed.color = Color.red()
                return await ctx.send(embed=embed)

            route = origin + ':' + dest
            skills = 555
            url = f'https://evemaps.dotlan.net/jump/{ship},{skills}/{route}'
            embed = Embed(title=f'Jump Route for {ship}', url=url)
            embed.set_thumbnail(
                url=f'https://image.eveonline.com/Type/{ship_id}_64.png')
            embed.add_field(name='Origin System',
                            value=f'{origin}',
                            inline=False)
            embed.add_field(name='Destination System',
                            value=f'{dest}',
                            inline=False)
            embed.set_footer(
                text=
                'Skills used: Jump Drive Callibration = 5, Jump Fuel Conservation = 5, Jump Freighter = 5'
            )
            embed.color = Color.green()
        except Exception as err:
            return await ctx.send(f'```py\n{traceback.format_exc()}\n```')

        return await ctx.send(embed=embed)