Merge remote-tracking branch 'origin/master'
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 8s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 8s
This commit is contained in:
commit
835d12c226
3 changed files with 76 additions and 0 deletions
|
@ -23,6 +23,8 @@ class FFMeta(commands.Cog):
|
||||||
def jpegify_image(self, input_file: io.BytesIO, quality: int = 50, image_format: str = "jpeg") -> io.BytesIO:
|
def jpegify_image(self, input_file: io.BytesIO, quality: int = 50, image_format: str = "jpeg") -> io.BytesIO:
|
||||||
quality = min(1, max(quality, 100))
|
quality = min(1, max(quality, 100))
|
||||||
img_src = PIL.Image.open(input_file)
|
img_src = PIL.Image.open(input_file)
|
||||||
|
if image_format == "jpeg":
|
||||||
|
img_src = img_src.convert("RGB")
|
||||||
img_dst = io.BytesIO()
|
img_dst = io.BytesIO()
|
||||||
self.log.debug("Saving input file (%r) as %r with quality %r%%", input_file, image_format, quality)
|
self.log.debug("Saving input file (%r) as %r with quality %r%%", input_file, image_format, quality)
|
||||||
img_src.save(img_dst, format=image_format, quality=quality)
|
img_src.save(img_dst, format=image_format, quality=quality)
|
||||||
|
|
56
src/cogs/gay_meter.py
Normal file
56
src/cogs/gay_meter.py
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import asyncio
|
||||||
|
import random
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
|
||||||
|
class MeterCog(commands.Cog):
|
||||||
|
def __init__(self, bot: commands.Bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.log = logging.getLogger("jimmy.cogs.auto_responder")
|
||||||
|
self.cache = {}
|
||||||
|
|
||||||
|
@commands.slash_command(name="gay-meter")
|
||||||
|
async def gay_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
||||||
|
"""Checks how gay someone is"""
|
||||||
|
user = user or ctx.user
|
||||||
|
|
||||||
|
await ctx.respond("Calculating...")
|
||||||
|
for i in range(0, 125, 25):
|
||||||
|
await ctx.edit(content="Calculating... %d%%" % i)
|
||||||
|
await asyncio.sleep(random.randint(1, 30) / 10)
|
||||||
|
|
||||||
|
pct = user.id % 100
|
||||||
|
await ctx.edit(content=f"{user.mention} is {pct}% gay.")
|
||||||
|
|
||||||
|
@commands.slash_command(name="penis-length")
|
||||||
|
async def penis_meter(self, ctx: discord.ApplicationContext, user: discord.User = None):
|
||||||
|
"""Checks the length of someone's penis."""
|
||||||
|
user = user or ctx.user
|
||||||
|
n = self.cache.get(user) or random.randint(0, 100)
|
||||||
|
chunks = ["8"]
|
||||||
|
chunks += ["="] * n
|
||||||
|
chunks.append("B")
|
||||||
|
self.cache[user] = n
|
||||||
|
return await ctx.respond(
|
||||||
|
embed=discord.Embed(
|
||||||
|
title=f"{user.display_name}'s penis length:",
|
||||||
|
description="%d cm\n%s" % (n, "".join(chunks))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@commands.is_owner()
|
||||||
|
async def clear_cache(self, ctx: commands.Context, user: discord.User = None):
|
||||||
|
"""Clears the Meter cache"""
|
||||||
|
if not user:
|
||||||
|
self.cache = {}
|
||||||
|
else:
|
||||||
|
self.cache.pop(user, None)
|
||||||
|
return await ctx.message.add_reaction("\N{white heavy check mark}")
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(MeterCog(bot))
|
18
src/main.py
18
src/main.py
|
@ -211,6 +211,24 @@ async def delete_message(ctx: discord.ApplicationContext, message: discord.Messa
|
||||||
await ctx.delete(delay=15)
|
await ctx.delete(delay=15)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.slash_command(name="about")
|
||||||
|
async def about_me(self, ctx: discord.ApplicationContext):
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="Jimmy v3",
|
||||||
|
description="A bot specifically for the LCC discord server(s).",
|
||||||
|
colour=discord.Colour.green()
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Source",
|
||||||
|
value="[Source code is available under AGPLv3.](https://git.i-am.nexus/nex/college-bot-v2)"
|
||||||
|
)
|
||||||
|
user = await self.bot.fetch_user(421698654189912064)
|
||||||
|
appinfo = await self.bot.application_info()
|
||||||
|
author = appinfo.owner
|
||||||
|
embed.add_field(name="Author", value=f"{user.mention} created me. {author.mention} is running this instance.")
|
||||||
|
return await ctx.respond(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
@bot.check_once
|
@bot.check_once
|
||||||
async def check_is_enabled(ctx: commands.Context | discord.ApplicationContext) -> bool:
|
async def check_is_enabled(ctx: commands.Context | discord.ApplicationContext) -> bool:
|
||||||
disabled = CONFIG["jimmy"].get("disabled_commands", [])
|
disabled = CONFIG["jimmy"].get("disabled_commands", [])
|
||||||
|
|
Loading…
Reference in a new issue