Kostiantyn Kuleshov
853c3c7cea
* Config file changes * Commands `/remove`, `/import` and `/export` Co-authored-by: profitroll <vozhd.kk@gmail.com> Co-authored-by: Profitroll <47523801+profitrollgame@users.noreply.github.com> Co-authored-by: Renovate <renovate@git.end-play.xyz> Reviewed-on: #19
32 lines
965 B
Python
32 lines
965 B
Python
from datetime import datetime, timedelta
|
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|
from pytimeparse.timeparse import timeparse
|
|
from modules.utils import configGet
|
|
from modules.sender import send_content
|
|
from modules.commands_register import register_commands
|
|
from modules.app import app
|
|
|
|
scheduler = AsyncIOScheduler()
|
|
|
|
if configGet("post", "mode"):
|
|
if configGet("use_interval", "posting"):
|
|
scheduler.add_job(
|
|
send_content,
|
|
"interval",
|
|
seconds=timeparse(configGet("interval", "posting")),
|
|
args=[app],
|
|
)
|
|
else:
|
|
for entry in configGet("time", "posting"):
|
|
dt_obj = datetime.strptime(entry, "%H:%M")
|
|
scheduler.add_job(
|
|
send_content, "cron", hour=dt_obj.hour, minute=dt_obj.minute, args=[app]
|
|
)
|
|
|
|
scheduler.add_job(
|
|
register_commands,
|
|
"date",
|
|
run_date=datetime.now() + timedelta(seconds=10),
|
|
args=[app],
|
|
)
|