Skip to content

Commit

Permalink
Merge pull request #49 from hs3city/replace-aiocron
Browse files Browse the repository at this point in the history
Replace aiocron with apscheduler
  • Loading branch information
DoomHammer authored Dec 1, 2023
2 parents b9e48c4 + 6119900 commit 7560198
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 63 deletions.
15 changes: 13 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import os
from typing import Dict, List

import aiocron
import discord
import yaml
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger
from dotenv import load_dotenv

load_dotenv()
Expand Down Expand Up @@ -36,13 +37,15 @@
verification_role_id: Dict[int, int] = {}


@aiocron.crontab("45 4 * * *")
async def advent_event():
today = datetime.date.today().strftime("%Y-%m-%d")
logging.info(f"Today is {today}, let's check the theme")
try:
theme = advent_calendar[today]
except KeyError:
logging.info("No theme for today")
return
logging.info(f"The theme is: {theme}")
for channel_id in channel_ids:
await client.get_channel(channel_id).send(f"Dzisiejszy temat to: {theme}")

Expand Down Expand Up @@ -116,5 +119,13 @@ async def on_ready():
)
verification_role_id[guild.id] = role.id

scheduler = AsyncIOScheduler()

scheduler.add_job(
advent_event, CronTrigger(day_of_week="0-6", hour="4", minute="45", second="0")
)

scheduler.start()


client.run(TOKEN)
81 changes: 30 additions & 51 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ license = "MIT"

[tool.poetry.dependencies]
python = "^3.10"
aiocron = "^1.6"
discord = "^1.7.3"
python-dotenv = "^0.19.0"
google-api-python-client = "^2.15.0"
google-auth-oauthlib = "^0.4.5"
PyYAML = "^6.0.1"
apscheduler = "^3.10.4"

[tool.poetry.dev-dependencies]

Expand Down
12 changes: 3 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
aiocron==1.8 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:48546513faf2eb7901e65a64eba7b653c80106ed00ed9ca3419c3d10b6555a01 \
--hash=sha256:b6313214c311b62aa2220e872b94139b648631b3103d062ef29e5d3230ddce6d
aiohttp==3.9.1 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:02ab6006ec3c3463b528374c4cdce86434e7b89ad355e7bf29e2f16b46c7dd6f \
--hash=sha256:04fa38875e53eb7e354ece1607b1d2fdee2d175ea4e4d745f6ec9f751fe20c7c \
Expand Down Expand Up @@ -81,6 +78,9 @@ aiohttp==3.9.1 ; python_version >= "3.10" and python_version < "4.0" \
aiosignal==1.3.1 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:54cd96e15e1649b75d6c87526a6ff0b6c1b0dd3459f43d9ca11d48c339b68cfc \
--hash=sha256:f8376fb07dd1e86a584e4fcdec80b36b7f81aac666ebc724e2c090300dd83b17
apscheduler==3.10.4 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:e6df071b27d9be898e486bc7940a7be50b4af2e9da7c08f0744a96d4bd4cef4a \
--hash=sha256:fb91e8a768632a4756a585f79ec834e0e27aad5860bac7eaa523d9ccefd87661
async-timeout==4.0.3 ; python_version >= "3.10" and python_version < "3.11" \
--hash=sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f \
--hash=sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028
Expand Down Expand Up @@ -184,9 +184,6 @@ charset-normalizer==3.3.2 ; python_version >= "3.10" and python_version < "4.0"
--hash=sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33 \
--hash=sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519 \
--hash=sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561
croniter==2.0.1 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:4cb064ce2d8f695b3b078be36ff50115cf8ac306c10a7e8653ee2a5b534673d7 \
--hash=sha256:d199b2ec3ea5e82988d1f72022433c5f9302b3b3ea9e6bfd6a1518f6ea5e700a
discord-py==2.3.2 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:4560f70f2eddba7e83370ecebd237ac09fbb4980dc66507482b0c0e5b8f76b9c \
--hash=sha256:9da4679fc3cb10c64b388284700dc998663e0e57328283bbfcfc2525ec5960a6
Expand Down Expand Up @@ -378,9 +375,6 @@ pyasn1==0.5.1 ; python_version >= "3.10" and python_version < "4.0" \
pyparsing==3.1.1 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:32c7c0b711493c72ff18a981d24f28aaf9c1fb7ed5e9667c9e84e3db623bdbfb \
--hash=sha256:ede28a1a32462f5a9705e07aea48001a08f7cf81a021585011deba701581a0db
python-dateutil==2.8.2 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
python-dotenv==0.19.2 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:32b2bdc1873fd3a3c346da1c6db83d0053c3c62f28f1f38516070c4c8971b1d3 \
--hash=sha256:a5de49a31e953b45ff2d2fd434bbc2670e8db5273606c1e737cc6b93eff3655f
Expand Down

0 comments on commit 7560198

Please sign in to comment.