ソースを参照

emergency logging for image editing commands.

tags/v2.0.0
Roxie Gibson 6年前
コミット
97cf0576f7
1個のファイルの変更124行の追加11行の削除
  1. +124
    -11
      roxbot/cogs/image.py

+ 124
- 11
roxbot/cogs/image.py ファイルの表示

@@ -199,7 +199,8 @@ class ImageEditor:
async def pride(self, ctx):
"""A collection of filters that show simple LGBT pride flags over the image provided.
The filters work with either your pfp, someone elses', or an image provided either by attachment or URL."""
pass
logging = roxbot.guild_settings.get(ctx.guild).logging
self.log_channel = self.bot.get_channel(logging["channel"])

@pride.command()
async def lgbt(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -217,8 +218,19 @@ class ImageEditor:
flag = PrideFlags.lgbt()
async with ctx.typing():
file = await self.flag_filter("lgbt", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["trans"])
async def transgender(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -236,8 +248,19 @@ class ImageEditor:
flag = PrideFlags.trans()
async with ctx.typing():
file = await self.flag_filter("trans", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["nb", "enby"])
async def nonbinary(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -255,8 +278,19 @@ class ImageEditor:
flag = PrideFlags.non_binary()
async with ctx.typing():
file = await self.flag_filter("nb", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["bi"])
async def bisexual(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -274,8 +308,19 @@ class ImageEditor:
flag = PrideFlags.bi()
async with ctx.typing():
file = await self.flag_filter("bi", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["gq"])
async def genderqueer(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -293,8 +338,19 @@ class ImageEditor:
flag = PrideFlags.gq()
async with ctx.typing():
file = await self.flag_filter("gq", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["pan"])
async def pansexual(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -312,8 +368,19 @@ class ImageEditor:
flag = PrideFlags.pan()
async with ctx.typing():
file = await self.flag_filter("pan", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["ace"])
async def asexual(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -331,8 +398,19 @@ class ImageEditor:
flag = PrideFlags.ace()
async with ctx.typing():
file = await self.flag_filter("ace", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command(aliases=["gf"])
async def genderfluid(self, ctx, image: roxbot.converters.AvatarURL = None):
@@ -350,8 +428,19 @@ class ImageEditor:
flag = PrideFlags.gf()
async with ctx.typing():
file = await self.flag_filter("pan", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@pride.command()
async def agender(self, ctx, image: roxbot.converters.AvatarURL = None):
@@ -369,8 +458,19 @@ class ImageEditor:
flag = PrideFlags.agender()
async with ctx.typing():
file = await self.flag_filter("gf", flag, image)
await ctx.send(file=file)
output = await ctx.send(file=file)
os.remove(file.filename)
await roxbot.log(
ctx.guild,
self.log_channel,
"pride",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)

@commands.command(aliases=["df"])
async def deepfry(self, ctx, image: roxbot.converters.AvatarURL=None):
@@ -382,6 +482,8 @@ class ImageEditor:
Provide a URL, that image
Provide an image via upload, that image.
"""
logging = roxbot.guild_settings.get(ctx.guild).logging
log_channel = self.bot.get_channel(logging["channel"])
if not image:
image = self.image_lookup(ctx.message)
filename = await roxbot.http.download_file(image)
@@ -428,8 +530,19 @@ class ImageEditor:
img = img.convert(mode="RGB")
img.save(jpg_name)

await ctx.send(file=discord.File(jpg_name))
output = await ctx.send(file=discord.File(jpg_name))
os.remove(jpg_name)
await roxbot.log(
ctx.guild,
log_channel,
"deepfry",
User=ctx.author,
User_ID=ctx.author.id,
Output_Message_ID=output.id,
Channel=ctx.channel,
Channel_Mention=ctx.channel.mention,
Time="{:%a %Y/%m/%d %H:%M:%S} UTC".format(ctx.message.created_at)
)


def setup(bot_client):

読み込み中…
キャンセル
保存