diff --git a/.idea/misc.xml b/.idea/misc.xml index 739588e068a5328b7b720e2f0e07c0734cece709..acb62c55f9bdd397a54a058c3513942e432a2463 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ <component name="JavaScriptSettings"> <option name="languageLevel" value="ES6" /> </component> - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (strolchibot)" project-jdk-type="Python SDK" /> + <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (strolchibot)" project-jdk-type="Python SDK" /> </project> \ No newline at end of file diff --git a/.idea/strolchibot.iml b/.idea/strolchibot.iml index a69cde905cbf1f07c0a033378a784a2a7a9f90f6..e116631e39d76e660a48a4bc8933bce0b2c2a473 100644 --- a/.idea/strolchibot.iml +++ b/.idea/strolchibot.iml @@ -18,7 +18,7 @@ <sourceFolder url="file://$MODULE_DIR$/strolchguru" isTestSource="false" /> <excludeFolder url="file://$MODULE_DIR$/venv" /> </content> - <orderEntry type="jdk" jdkName="Python 3.9 (strolchibot)" jdkType="Python SDK" /> + <orderEntry type="jdk" jdkName="Python 3.10 (strolchibot)" jdkType="Python SDK" /> <orderEntry type="sourceFolder" forTests="false" /> </component> <component name="TemplatesService"> diff --git a/twitchbot/countdown.py b/twitchbot/countdown.py new file mode 100644 index 0000000000000000000000000000000000000000..52bae853aaafee279d9607aefe536e891ccd3164 --- /dev/null +++ b/twitchbot/countdown.py @@ -0,0 +1,23 @@ +from asyncio import sleep +from datetime import datetime + +from twitchio.ext import commands, routines + + +class Countdown(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.timer.start() + self.until = datetime(year=2022, month=4, day=5, hour=20) + + @routines.routine(minutes=1) + async def timer(self): + now = datetime.now() + diff = (self.until - now).seconds // 60 + 1 + + if diff > 0: + await self.bot.channel().send(str(diff)) + + @timer.before_routine + async def timer_before(self): + await sleep(60 - datetime.now().second) diff --git a/twitchbot/strolchibot.py b/twitchbot/strolchibot.py index 404e66f5b92c560deefeaac57223db9cb17c8b4d..299806eddd1d985a27ac39a55bf2a2b4c7170ecb 100644 --- a/twitchbot/strolchibot.py +++ b/twitchbot/strolchibot.py @@ -9,7 +9,7 @@ from twitchio import Channel, Message from twitchio.ext import commands from twitchio.ext.commands import Context -import chat_commands, giveaway, klassenbuch, link_protection, spotify_cog, vote_cog +import chat_commands, giveaway, klassenbuch, link_protection, spotify_cog, vote_cog, countdown load_dotenv() @@ -34,6 +34,7 @@ class StrolchiBot(commands.Bot, ABC): self.add_cog(link_protection.LinkProtection(self)) self.add_cog(giveaway.Giveaway(self)) self.add_cog(chat_commands.Commands(self)) + self.add_cog(countdown.Countdown(self)) @staticmethod async def send_me(ctx, content):