diff --git a/Dockerfile b/Dockerfile index 0ceb6440..894b8c85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ FROM python:3.8 as build ADD app/requirements.txt /requirements.txt -RUN pip install -r requirements.txt +RUN apt-get update && apt-get install -y libmagickwand-dev && pip install -r requirements.txt FROM python:3.8-slim +RUN apt-get update && apt-get install -y libmagickwand-dev COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages ADD app /app -CMD python /app/bot.py +WORKDIR /app diff --git a/Dockerfile-test-env b/Dockerfile-test-env index 6e5262e2..894b8c85 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -1,8 +1,9 @@ FROM python:3.8 as build ADD app/requirements.txt /requirements.txt -RUN pip install -r requirements.txt +RUN apt-get update && apt-get install -y libmagickwand-dev && pip install -r requirements.txt FROM python:3.8-slim +RUN apt-get update && apt-get install -y libmagickwand-dev COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages ADD app /app WORKDIR /app diff --git a/app/bot.py b/app/bot.py index e6be15dd..7ca31da2 100755 --- a/app/bot.py +++ b/app/bot.py @@ -55,7 +55,24 @@ async def react_with_dale(ctx): await ctx.add_reaction(emoji) return +@bot.listen('on_message') +async def convert_heic_to_jpg(ctx): + from wand.image import Image + if ctx.attachments: + for attachment in ctx.attachments: + if attachment.filename.lower().endswith('heic'): + heic_file = '/tmp/heic' + jpg_file = '/tmp/jpg.jpg' + await attachment.save(fp=heic_file) + # Convert heic to jpg + img=Image(filename=heic_file) + img.format='jpg' + img.save(filename=jpg_file) + img.close() + await ctx.delete() + await ctx.channel.send(file=discord.File(jpg_file)) + return @bot.event diff --git a/app/requirements.txt b/app/requirements.txt index fb32e793..faf477f0 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -7,3 +7,4 @@ requests owotext wikipedia wolframalpha +Wand \ No newline at end of file