create basic loop which checks whether a new day started
This commit is contained in:
parent
726f9421ea
commit
a328c255af
|
@ -27,7 +27,7 @@ where = src
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
remember-remember-bot = remember_remember_bot.cli:main
|
remember-remember-bot = remember_remember_bot.loop:loop
|
||||||
|
|
||||||
[tox:tox]
|
[tox:tox]
|
||||||
envlist = lint, py310
|
envlist = lint, py310
|
||||||
|
|
21
src/remember_remember_bot/loop.py
Normal file
21
src/remember_remember_bot/loop.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
def loop():
|
||||||
|
current_day = 0
|
||||||
|
while True:
|
||||||
|
if check_new_day(current_day):
|
||||||
|
pass
|
||||||
|
print(current_day)
|
||||||
|
current_day = update_day()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
def check_new_day(current_day):
|
||||||
|
if current_day == datetime.datetime.now().day:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def update_day():
|
||||||
|
return datetime.datetime.now().day
|
8
tests/test_loop.py
Normal file
8
tests/test_loop.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from remember_remember_bot.loop import check_new_day, update_day
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_day() -> None:
|
||||||
|
current_day = 0
|
||||||
|
assert check_new_day(current_day)
|
||||||
|
current_day = update_day()
|
||||||
|
assert not check_new_day(current_day)
|
Loading…
Reference in a new issue