diff --git a/assets/disdain_for_jpegs.gif b/assets/disdain_for_jpegs.gif new file mode 100644 index 0000000..f2c773e Binary files /dev/null and b/assets/disdain_for_jpegs.gif differ diff --git a/commands/canvas.py b/commands/canvas.py index 4646339..10b9a98 100644 --- a/commands/canvas.py +++ b/commands/canvas.py @@ -1,4 +1,5 @@ import re +import discord from discord.ext import commands from discord.ext.commands import BucketType from discord.utils import get as dget @@ -43,7 +44,11 @@ async def parse_diff(ctx, coords): att = ctx.message.attachments[0] if att.filename[-4:].lower() != ".png": if att.filename[-4:].lower() == ".jpg" or att.filename[-5:].lower() == ".jpeg": - await ctx.send(getlang(ctx.guild.id, "bot.error.jpeg")) + try: + f = discord.File("assets/disdain_for_jpegs.gif", "disdain_for_jpegs.gif") + await ctx.send(getlang(ctx.guild.id, "bot.error.jpeg"), file=f) + except IOError: + await ctx.send(getlang(ctx.guild.id, "bot.error.jpeg")) return await ctx.send(getlang(ctx.guild.id, "bot.error.no_png")) return @@ -194,7 +199,11 @@ async def check_attachment(ctx): filename = ctx.message.attachments[0].filename if filename[-4:].lower() != ".png": if filename[-4:].lower() == ".jpg" or filename[-5:].lower() == ".jpeg": - await ctx.send(getlang(ctx.guild.id, "bot.error.jpeg")) + try: + f = discord.File("assets/disdain_for_jpegs.gif", "disdain_for_jpegs.gif") + await ctx.send(getlang(ctx.guild.id, "bot.error.jpeg"), file=f) + except IOError: + await ctx.send(getlang(ctx.guild.id, "bot.error.jpeg")) return False await ctx.send(getlang(ctx.guild.id, "bot.error.no_png")) return False @@ -262,7 +271,6 @@ async def repeat(self, ctx): x = int(match.group(3)) y = int(match.group(4)) zoom = int(match.group(5)) if match.group(5) is not None else 1 - print("cmd: {}, scmd: {}, x: {}, y: {}".format(cmd, sub_cmd, x, y)) if (cmd == "diff" or cmd == "d") and len(msg.attachments) > 0 \ and msg.attachments[0].filename[-4:].lower() == ".png": att = msg.attachments[0] diff --git a/glimmer.py b/glimmer.py index 65b54df..ec4dc2d 100644 --- a/glimmer.py +++ b/glimmer.py @@ -124,7 +124,6 @@ async def on_guild_update(before, after): @bot.event async def on_command_error(ctx, error): - print(type(error)) if isinstance(error, commands.CommandOnCooldown): await ctx.send(getlang(ctx.guild.id, "bot.error.command_on_cooldown").format(error.retry_after)) return @@ -224,25 +223,25 @@ async def ditherchart(ctx): @ditherchart.command(name="pixelcanvas") async def ditherchart_pixelcanvas(ctx): - f = discord.File("assets/dither_chart_pixelcanvas.png", "assets/dither_chart_pixelcanvas.png") + f = discord.File("assets/dither_chart_pixelcanvas.png", "dither_chart_pixelcanvas.png") await ctx.send(file=f) @ditherchart.command(name="pixelzio") async def ditherchart_pixelzio(ctx): - f = discord.File("assets/dither_chart_pixelzio.png", "assets/dither_chart_pixelzio.png") + f = discord.File("assets/dither_chart_pixelzio.png", "dither_chart_pixelzio.png") await ctx.send(file=f) @ditherchart.command(name="pixelzone") async def ditherchart_pixelzio(ctx): - f = discord.File("assets/dither_chart_pixelzone.png", "assets/dither_chart_pixelzone.png") + f = discord.File("assets/dither_chart_pixelzone.png", "dither_chart_pixelzone.png") await ctx.send(file=f) @ditherchart.command(name="pxlsspace") async def ditherchart_pixelzio(ctx): - f = discord.File("assets/dither_chart_pxlsspace.png", "assets/dither_chart_pxlsspace.png") + f = discord.File("assets/dither_chart_pxlsspace.png", "dither_chart_pxlsspace.png") await ctx.send(file=f) diff --git a/lang/pt_BR.py b/lang/pt_BR.py index a87766f..80fcb30 100644 --- a/lang/pt_BR.py +++ b/lang/pt_BR.py @@ -29,6 +29,8 @@ "configuration.alert_channel_set": "O canal de Alerta foi definido para {0}.", "configuration.autoscan_disabled": "Autoscan foi desativado.", "configuration.autoscan_enabled": "Autoscan foi ativado.", + "configuration.canvas_check": "O canvas padrão desta guild é ** {0} **. \ n" + "Para alterar o canvas padrão, execute este comando novamente com um canvas suportado. (Use `{1}help canvas` para ver uma lista.)", "configuration.canvas_set": "O canvas padrão foi definido para **{0}**.", "configuration.language_check": "O idioma atual deste guild é **{1}**.\n" "Para definir um novo idioma, execute este comando novamente com uma das seguintes opções:\n" @@ -235,9 +237,9 @@ "command.version": "version", # Command signatures - "signature.alertchannel": "alertchannel ", + "signature.alertchannel": "alertchannel ", "signature.alertchannel.clear": "alertchannel clear", - "signature.alertchannel.set": "alertchannel set ", + "signature.alertchannel.set": "alertchannel set ", "signature.autoscan": "autoscan", "signature.canvas": "canvas ", "signature.canvas.pixelcanvas": "canvas pixelcanvas", @@ -245,30 +247,30 @@ "signature.canvas.pixelzone": "canvas pixelzone", "signature.canvas.pxlsspace": "canvas pxlsspace", "signature.changelog": "changelog", - "signature.diff": "diff ", - "signature.diff.pixelcanvas": "diff pixelcanvas (zoom)", - "signature.diff.pixelzio": "diff pixelzio (zoom)", - "signature.diff.pixelzone": "diff pixelzone (zoom)", - "signature.diff.pxlsspace": "diff pxlsspace (zoom)", - "signature.ditherchart": "ditherchart ", + "signature.diff": "diff ", + "signature.diff.pixelcanvas": "diff pixelcanvas (zoom)", + "signature.diff.pixelzio": "diff pixelzio (zoom)", + "signature.diff.pixelzone": "diff pixelzone (zoom)", + "signature.diff.pxlsspace": "diff pxlsspace (zoom)", + "signature.ditherchart": "ditherchart ", "signature.ditherchart.pixelcanvas": "ditherchart pixelcanvas", "signature.ditherchart.pixelzio": "ditherchart pixelzio", "signature.ditherchart.pixelzone": "ditherchart pixelzone", "signature.ditherchart.pxlsspace": "ditherchart pxlsspace", "signature.github": "github", - "signature.gridify": "gridify (size)", + "signature.gridify": "gridify (tamanho)", "signature.help": "help", "signature.invite": "invite", - "signature.language": "language (code)", + "signature.language": "language (código)", "signature.listemotes": "listemotes", "signature.ping": "ping", - "signature.prefix": "prefix ", + "signature.prefix": "prefix ", "signature.preview": "preview ", - "signature.preview.pixelcanvas": "preview pixelcanvas (zoom)", - "signature.preview.pixelzio": "preview pixelzio (zoom)", - "signature.preview.pixelzone": "preview pixelzone (zoom)", - "signature.preview.pxlsspace": "preview pxlsspace (zoom)", - "signature.quantize": "quantize ", + "signature.preview.pixelcanvas": "preview pixelcanvas (zoom)", + "signature.preview.pixelzio": "preview pixelzio (zoom)", + "signature.preview.pixelzone": "preview pixelzone (zoom)", + "signature.preview.pxlsspace": "preview pxlsspace (zoom)", + "signature.quantize": "quantize ", "signature.quantize.pixelcanvas": "quantize pixelcanvas", "signature.quantize.pixelzio": "quantize pixelzio", "signature.quantize.pixelzone": "quantize pixelzone", @@ -276,6 +278,6 @@ "signature.register": "register", "signature.registerguild": "registerguild", "signature.repeat": "repeat", - "signature.suggest": "suggest ", + "signature.suggest": "suggest ", "signature.version": "version", -} \ No newline at end of file +} diff --git a/utils/render.py b/utils/render.py index 783fb22..56dd9fb 100644 --- a/utils/render.py +++ b/utils/render.py @@ -1,4 +1,5 @@ import aiohttp +import asyncio import discord import io import json @@ -43,6 +44,7 @@ async def diff(ctx, x, y, att, zoom, fetch, palette): bad = 0 # Number of pixels in the template that are not in the color palette for py in range(template.height): + await asyncio.sleep(0) for px in range(template.width): tp = template.getpixel((px, py)) dp = diff_img.getpixel((px, py)) @@ -108,6 +110,7 @@ async def quantize(ctx, att, palette): bad_pixels = template.height * template.width for py in range(template.height): + await asyncio.sleep(0) for px in range(template.width): pix = template.getpixel((px, py)) @@ -146,6 +149,7 @@ async def gridify(ctx, att, zoom): grid_img = Image.new('RGBA', (template.width * (zoom + 1) - 1, template.height * (zoom + 1) - 1)) for iy in range(template.height): + await asyncio.sleep(0) for ix in range(template.width): for ziy in range(zoom): for zix in range(zoom): @@ -191,6 +195,7 @@ def pixel_to_data_index(): ) / 2 # Pixels come packed in pairs for py in range(dy): + await asyncio.sleep(0) for px in range(dx): i = pixel_to_data_index() color_id = data[int(i)] & 15 if i % 1 != 0 else data[int(i)] >> 4 @@ -257,6 +262,7 @@ async def fetch_pixelzone(x, y, dx, dy): tmp = lz4.frame.decompress(bytes(tmp)) chunk = Image.new('RGB', (512, 512), (255, 255, 255, 255)) for py in range(chunk.height): + await asyncio.sleep(0) for px in range(chunk.width): i = (py * 512 + px) / 2 color_id = tmp[int(i)] & 15 if i % 1 == 0 else tmp[int(i)] >> 4 @@ -277,6 +283,7 @@ async def fetch_pxlsspace(x, y, dx, dy): data = await resp.read() for py in range(dy): + await asyncio.sleep(0) for px in range(dx): if 1280 <= px+x or px+x < 0 or 720 <= py+y or py+y < 0: continue