From ed34da276a23a9b8580e7a17cf28060a2c6933b4 Mon Sep 17 00:00:00 2001 From: Pyrrhic Date: Wed, 27 Apr 2022 19:04:11 -0500 Subject: [PATCH] Add version command with the build time --- Dockerfile | 2 ++ Dockerfile-arm32v6 | 2 ++ src/bot.py | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dabc05b..7cb731b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,6 @@ RUN pip3 --no-cache-dir install -U py-cord==2.0.0b5 python-dotenv COPY .env src/ secret-scholars-bot-config.json ./ +RUN printf "build_time=%s" "'`date -Iseconds`'" > autogen_buildtime.py + CMD [ "python", "./bot.py" ] diff --git a/Dockerfile-arm32v6 b/Dockerfile-arm32v6 index 2b8e24c..92f0490 100644 --- a/Dockerfile-arm32v6 +++ b/Dockerfile-arm32v6 @@ -9,4 +9,6 @@ RUN pip3 --no-cache-dir install -U py-cord==2.0.0b5 python-dotenv COPY .env src/ secret-scholars-bot-config.json ./ +RUN printf "build_time=%s" "'`date -Iseconds`'" > autogen_buildtime.py + CMD [ "python", "./bot.py" ] diff --git a/src/bot.py b/src/bot.py index e4b3142..fcef2b6 100644 --- a/src/bot.py +++ b/src/bot.py @@ -10,6 +10,7 @@ import asyncio import minecraft import excuse +import autogen_buildtime logging.basicConfig(level=logging.INFO) @@ -49,7 +50,12 @@ async def on_message(message): if await roll.on_message(message): return - if message.content.startswith('$hello'): + if message.content.startswith('$version'): + time = datetime.fromisoformat(autogen_buildtime.build_time) + await message.channel.send(f'Build time: {time.strftime("%b %d %Y %X %Z")}', delete_after=300) + await asyncio.sleep(300) + await message.delete() + elif message.content.startswith('$hello'): await message.channel.send('Hello!', delete_after=300) await asyncio.sleep(300) await message.delete()