Add new command - timetopost
This commit is contained in:
12
app.py
12
app.py
@@ -146,6 +146,18 @@ async def command_listener():
|
||||
tags = cmd[len("posttags "):].split()
|
||||
logging.info("Команда posttags получена, публикуем изображение с тегами: %s", tags)
|
||||
await post_image(tags)
|
||||
elif cmd.startswith("timetopost"):
|
||||
now = datetime.now()
|
||||
# Публикуем догоняющее изображение, если запуск не в начале часа
|
||||
if now.minute != 0 or now.second != 0:
|
||||
logging.info("Пропущенный час — публикуем сразу")
|
||||
await post_image()
|
||||
|
||||
# Ждем до следующей 00 минуты
|
||||
next_run = (now + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
|
||||
wait_seconds = (next_run - datetime.now()).total_seconds()
|
||||
logging.info("Времени до публикации: %s", wait_seconds)
|
||||
|
||||
else:
|
||||
logging.info("Неизвестная команда: %s", cmd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user