убрал удаление и статичное расписание
This commit is contained in:
@@ -121,7 +121,6 @@ def getFreeSlots(vkPost) -> dict:
|
||||
logger.error("Ответ не получен")
|
||||
return {}
|
||||
slotsDataFull = response.json()
|
||||
logger.info(slotsDataFull)
|
||||
if len(slotsDataFull.keys()) == 0:
|
||||
logger.error("Нет свободных приемов")
|
||||
return {}
|
||||
|
||||
+7
-2
@@ -65,9 +65,14 @@ def enable_publish_job():
|
||||
interval_minutes = scheduleData.interval_minutes
|
||||
|
||||
trigger = CronTrigger(
|
||||
hour=f"{start_hour}-{end_hour - 1}",
|
||||
minute=f"*/{interval_minutes}",
|
||||
hour="12",
|
||||
minute="0",
|
||||
day="*",
|
||||
)
|
||||
# trigger = CronTrigger(
|
||||
# hour=f"{start_hour}-{end_hour - 1}",
|
||||
# minute=f"*/{interval_minutes}",
|
||||
# )
|
||||
|
||||
scheduler.add_job(
|
||||
vk_publish_job,
|
||||
|
||||
+9
-8
@@ -19,8 +19,9 @@ def handle_vk_post():
|
||||
logger.error("Информация для размещения поста не найдена")
|
||||
return
|
||||
|
||||
if not vkPost.dynamic_text and not vkPost.post_id:
|
||||
logger.info("Не требуется публикация или удаление поста")
|
||||
if not vkPost.dynamic_text:
|
||||
# if not vkPost.dynamic_text and not vkPost.post_id:
|
||||
logger.info("Не требуется публикация поста")
|
||||
return
|
||||
|
||||
vk_session = vk_api.VkApi(token=vkApi.access_token)
|
||||
@@ -32,16 +33,16 @@ def handle_vk_post():
|
||||
new_post = vk.wall.post(
|
||||
owner_id=-vkApi.group_id,
|
||||
from_group=1,
|
||||
message=f"{vkPost.dynamic_text}\n{vkPost.static_text}".strip(),
|
||||
message=f"{vkPost.dynamic_text}{vkPost.static_text}".strip(),
|
||||
attachments=f"photo-{vkApi.group_id}_{vkApi.base_photo_url}",
|
||||
)
|
||||
logger.info(f"Пост #{new_post.get('post_id')} создан")
|
||||
|
||||
if vkPost.post_id:
|
||||
logger.info(f"Удаление поста #{vkPost.post_id}")
|
||||
vk.wall.delete(owner_id=-vkApi.group_id, post_id=vkPost.post_id)
|
||||
vkPost.post_id = None
|
||||
vkPost.publish_at = None
|
||||
# if vkPost.post_id:
|
||||
# logger.info(f"Удаление поста #{vkPost.post_id}")
|
||||
# vk.wall.delete(owner_id=-vkApi.group_id, post_id=vkPost.post_id)
|
||||
# vkPost.post_id = None
|
||||
# vkPost.publish_at = None
|
||||
|
||||
if vkPost.dynamic_text:
|
||||
vkPost.dynamic_text = None
|
||||
|
||||
Reference in New Issue
Block a user