Exemplo n.º 1
0
    async def do_zane(self, ctx: utils.CustomContext, what: str,
                      method: callable, gif_or_png: str):
        async with ctx.typing():
            get_image = await method(what)
            discord_file = discord.File(get_image,
                                        f"hellomagicman.{gif_or_png}")

            await ctx.send(file=discord_file)
Exemplo n.º 2
0
    async def zip_all_emojis(self, ctx: utils.CustomContext):
        """Compress all of the servers emojis into one ZIP file."""

        await ctx.send("Alright, this may take a while!")

        async with ctx.timeit:
            async with ctx.typing():
                zip_file = await self._zip_all_guild_emojis(ctx.guild)
                file = discord.File(zip_file, "emojis.zip")

            await ctx.reply(
                "Hey, here's all the guilds emojis you called for!", file=file)
Exemplo n.º 3
0
    async def polaroid(self,
                       ctx: utils.CustomContext,
                       user: discord.Member = None):
        """Puts someones profile picture in a polaroid.
        Powered by Dagpi."""

        async with ctx.timeit:
            async with ctx.typing():
                user = user or ctx.author
                img_file = await do_dagpi_stuff(ctx, user,
                                                ImageFeatures.polaroid())
                await ctx.send("*Look at this photograph*", file=img_file)
Exemplo n.º 4
0
    async def pixelate(self,
                       ctx: utils.CustomContext,
                       user: discord.Member = None):
        """Pixelates someones profile picture.
        Powered by Dagpi."""

        async with ctx.timeit:
            async with ctx.typing():
                user = user or ctx.author
                img_file = await do_dagpi_stuff(ctx, user,
                                                ImageFeatures.pixel())
                await ctx.send(file=img_file)
Exemplo n.º 5
0
    async def colours(self,
                      ctx: utils.CustomContext,
                      user: discord.Member = None):
        """Gives you the top 5 colours of your own or another persons profile picture.
        Powered by Dagpi."""

        async with ctx.timeit:
            async with ctx.typing():
                user = user or ctx.author
                img_file = await do_dagpi_stuff(ctx, user,
                                                ImageFeatures.colors())
                await ctx.send(f"Top 5 Colours for {user}", file=img_file)
Exemplo n.º 6
0
async def do_polaroid_image(ctx: utils.CustomContext, method: callable,
                            image: bytes, name: str, *args):
    async with ctx.timeit:
        async with ctx.typing():
            func = functools.partial(method, image)
            buffer = await ctx.bot.loop.run_in_executor(None, func, *args)

            embed = ctx.bot.embed(ctx)
            file = discord.File(fp=buffer, filename=f"{name}.png")
            embed.set_image(url=f"attachment://{name}.png")

            await ctx.send(file=file, embed=embed)
Exemplo n.º 7
0
    async def screenshot(self, ctx: utils.CustomContext, url: str):
        """Screenshots a given URL.
        *Note: this is limited to NSFW channels.*"""

        async with ctx.typing():
            obj = await self.bot.loop.run_in_executor(
                None, BlockingFunctions.screenshot, url)
            embed = self.bot.embed(ctx)

            file = discord.File(obj, filename="scrape.png")
            embed.set_image(url="attachment://scrape.png")

            await ctx.send(file=file, embed=embed)
Exemplo n.º 8
0
    async def wanted(self,
                     ctx: utils.CustomContext,
                     user: discord.Member = None):
        """Puts a members user avatar on a wanted poster.
        Powered by Dagpi."""

        async with ctx.timeit:
            async with ctx.typing():
                user = user or ctx.author
                img_file = await do_dagpi_stuff(ctx, user,
                                                ImageFeatures.wanted())
                await ctx.send(content=f"Hands up **{user.name}!**",
                               file=img_file)
Exemplo n.º 9
0
    async def chroma(self, ctx: utils.CustomContext, what=None):
        """Adds a chroma gamma affect to a given image."""

        async with ctx.timeit:
            async with ctx.typing():
                image = await get_image(ctx, what)
                buffer = BytesIO(image)
                func = functools.partial(Manipulation.chroma, buffer)
                buffer = await self.bot.loop.run_in_executor(None, func)

                embed = self.bot.embed(ctx)
                file = discord.File(fp=buffer, filename="chroma.png")
                embed.set_image(url="attachment://chroma.png")

                await ctx.send(file=file, embed=embed)
Exemplo n.º 10
0
    async def chatbot(self,
                      ctx: utils.CustomContext,
                      emotion: EmotionConverter = None):
        """Starts an interactive session with the chat bot.
        Type `cancel` to quit talking to the bot."""

        cb = async_cleverbot.Cleverbot(
            self.bot.settings["keys"]["chatbot_api"])
        not_ended = True

        emotion = emotion or async_cleverbot.Emotion.neutral

        await ctx.send(
            "I have started a chat bot session for you, type away! Type `cancel` to end the session."
        )

        while not_ended:
            try:
                message = await self.bot.wait_for(
                    "message",
                    timeout=30.0,
                    check=lambda m: m.author == ctx.author and m.channel == ctx
                    .channel)
            except asyncio.TimeoutError:
                await cb.close()
                not_ended = False
                return await ctx.send(
                    "You took a very long time to talk to the bot, so I ended the session."
                )
            else:
                async with ctx.typing():
                    if message.content.lower() == "cancel":
                        await cb.close()
                        not_ended = False
                        return await ctx.send(
                            "Good bye! \N{SLIGHTLY SMILING FACE}")
                    response = await cb.ask(message.content,
                                            ctx.author.id,
                                            emotion=emotion)

                    try:
                        text = utils.owoify_text(
                            response.text) if self.bot.config[
                                ctx.guild.id]["owoify"] else response.text
                    except (KeyError, AttributeError):
                        text = response.text

                    await message.reply(text)
Exemplo n.º 11
0
    async def solarize(self, ctx: utils.CustomContext,
                       what: typing.Optional[str]):
        """Solarizes your own or someone else's profile picture or even a given picture."""

        async with ctx.timeit:
            async with ctx.typing():
                what = await get_image(ctx, what)

                func = functools.partial(Manipulation.solarize_image, what)
                image_bytes = await self.bot.loop.run_in_executor(None, func)

                embed = self.bot.embed(ctx)
                file = discord.File(image_bytes, filename="solarize.png")
                embed.set_image(url="attachment://solarize.png")

                await ctx.send(file=file, embed=embed)
Exemplo n.º 12
0
    async def reddit(self, ctx: utils.CustomContext, subreddit: str):
        """Browse your favourite sub-reddit, gives a random submission from it."""

        async with ctx.typing():
            url = f"https://www.reddit.com/r/{subreddit}/random.json"
            async with self.bot.session.get(url) as resp:
                if resp.status != 200:
                    return await ctx.send(
                        "That subreddit doesn't exist or something severely wrong just happened."
                    )
                data = await resp.json()
                try:
                    data = data[0]["data"]["children"][0]["data"]
                except KeyError:
                    return await ctx.send(
                        "That subreddit doesn't exist or something severely wrong just happened."
                    )

                title, author, ups, downs, score, over_18, url, perma_link, subs, created_at = (
                    data["title"], data["author"], data["ups"], data["downs"],
                    data["score"], data["over_18"], data["url"],
                    data["permalink"], data["subreddit_subscribers"],
                    data["created_utc"])

                if over_18:
                    if not ctx.channel.is_nsfw():
                        return await ctx.send("Bonk! Go to horny jail.")

                embed = self.bot.embed(
                    ctx,
                    title=title,
                    url=f"https://www.reddit.com{perma_link}")

                embed.add_field(name="\N{UPWARDS BLACK ARROW}", value=ups)
                embed.add_field(name="\N{DOWNWARDS BLACK ARROW}", value=downs)

                embed.set_image(url=url)
                embed.set_author(name=f"Poster: {author}")
                embed.set_footer(
                    text=
                    f"Subreddit Subs: {subs} | Post score: {score} | Posted at"
                )
                embed.timestamp = datetime.datetime.fromtimestamp(created_at)

                await ctx.send(embed=embed)
Exemplo n.º 13
0
    async def facetime(self, ctx: utils.CustomContext, what: str):
        """Facetime with another user or even an image if you're really that lonely, I guess."""

        async with ctx.timeit:
            async with ctx.typing():
                author_image = await ctx.author.avatar_url_as(
                    static_format="png", size=1024).read()
                what = await get_image(ctx, what)

                func = functools.partial(Manipulation.facetime, what,
                                         author_image)
                image_bytes = await self.bot.loop.run_in_executor(None, func)

                embed = self.bot.embed(ctx)
                file = discord.File(image_bytes, filename="facetime.png")
                embed.set_image(url="attachment://facetime.png")

                await ctx.send(file=file, embed=embed)
Exemplo n.º 14
0
    async def brighten(self,
                       ctx: utils.CustomContext,
                       what: typing.Optional[str],
                       amount: int = 50):
        """Brightens a given picture or your own or even someone else's profile picture by a given amount"""

        async with ctx.timeit:
            async with ctx.typing():
                what = await get_image(ctx, what)

                func = functools.partial(Manipulation.brighten_image, what,
                                         amount)
                image_bytes = await self.bot.loop.run_in_executor(None, func)

                embed = self.bot.embed(ctx)
                file = discord.File(image_bytes, filename="brightened.png")
                embed.set_image(url="attachment://brightened.png")

                await ctx.send(file=file, embed=embed)
Exemplo n.º 15
0
    async def swirl(self,
                    ctx: utils.CustomContext,
                    degrees: typing.Optional[int] = 90,
                    what: str = None):
        """Adds a swirl affect to a given image."""

        async with ctx.timeit:
            async with ctx.typing():
                image = await get_image(ctx, what)
                buffer = BytesIO(image)

                func = functools.partial(Manipulation.swirl, buffer, degrees)
                buffer = await self.bot.loop.run_in_executor(None, func)

                embed = self.bot.embed(ctx)
                file = discord.File(fp=buffer, filename="swirl.png")
                embed.set_image(url="attachment://swirl.png")

                await ctx.send(file=file, embed=embed)
Exemplo n.º 16
0
    async def alwayshasbeen(self,
                            ctx: utils.CustomContext,
                            *,
                            text: commands.clean_content = None):
        """Always has been meme."""

        text = text or "I'm dumb and didn't put any text"

        async with ctx.timeit:
            async with ctx.typing():
                if len(text) > 50:
                    fmt = "<:smh:789142899290931241> it can't be any longer than 50 characters!"
                    return await ctx.send(fmt)

                func = functools.partial(Manipulation.alwayshasbeen, text)
                buffer = await self.bot.loop.run_in_executor(None, func)

                embed = self.bot.embed(ctx)

                file = discord.File(fp=buffer, filename="ahb.png")
                embed.set_image(url="attachment://ahb.png")

                await ctx.send(file=file, embed=embed)