2023-01-10 14:06:24 +02:00
|
|
|
from datetime import datetime, timedelta
|
2023-01-10 13:52:44 +02:00
|
|
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
2023-02-17 22:54:30 +02:00
|
|
|
from pytimeparse.timeparse import timeparse
|
2023-01-10 13:52:44 +02:00
|
|
|
from modules.utils import configGet
|
|
|
|
from modules.sender import send_content
|
2023-01-10 14:06:24 +02:00
|
|
|
from modules.commands_register import register_commands
|
|
|
|
from modules.app import app
|
2023-01-10 13:52:44 +02:00
|
|
|
|
|
|
|
scheduler = AsyncIOScheduler()
|
|
|
|
|
|
|
|
if configGet("post", "mode"):
|
2023-02-17 22:54:30 +02:00
|
|
|
if configGet("use_interval", "posting"):
|
2023-03-09 12:33:02 +02:00
|
|
|
scheduler.add_job(
|
|
|
|
send_content,
|
|
|
|
"interval",
|
|
|
|
seconds=timeparse(configGet("interval", "posting")),
|
|
|
|
args=[app],
|
|
|
|
)
|
2023-02-17 22:54:30 +02:00
|
|
|
else:
|
|
|
|
for entry in configGet("time", "posting"):
|
|
|
|
dt_obj = datetime.strptime(entry, "%H:%M")
|
2023-03-09 12:33:02 +02:00
|
|
|
scheduler.add_job(
|
|
|
|
send_content, "cron", hour=dt_obj.hour, minute=dt_obj.minute, args=[app]
|
|
|
|
)
|
2023-01-10 14:06:24 +02:00
|
|
|
|
2023-03-09 12:33:02 +02:00
|
|
|
scheduler.add_job(
|
|
|
|
register_commands,
|
|
|
|
"date",
|
|
|
|
run_date=datetime.now() + timedelta(seconds=10),
|
|
|
|
args=[app],
|
|
|
|
)
|