"""夜间模式调度服务"""
import logging
from datetime import datetime

logger = logging.getLogger("spam_guard")


async def enable_night_mode(chat) -> None:
    """开启夜间模式：全员禁言"""
    from telegram import ChatPermissions
    await chat.set_permissions(
        ChatPermissions(
            can_send_messages=False,
            can_send_audios=False,
            can_send_documents=False,
            can_send_photos=False,
            can_send_videos=False,
            can_send_video_notes=False,
            can_send_voice_notes=False,
            can_send_polls=False,
            can_send_other_messages=False,
            can_add_web_page_previews=False,
            can_invite_users=False,
            can_change_info=False,
            can_pin_messages=False,
            can_manage_topics=False,
        )
    )
    logger.info("🌙 夜间模式已开启")


async def disable_night_mode(chat) -> None:
    """关闭夜间模式：恢复发言"""
    from telegram import ChatPermissions
    await chat.set_permissions(
        ChatPermissions(
            can_send_messages=True,
            can_send_audios=True,
            can_send_documents=True,
            can_send_photos=True,
            can_send_videos=True,
            can_send_video_notes=True,
            can_send_voice_notes=True,
            can_send_polls=True,
            can_send_other_messages=True,
            can_add_web_page_previews=True,
            can_invite_users=True,
            can_change_info=False,
            can_pin_messages=False,
            can_manage_topics=False,
        )
    )
    logger.info("☀️ 夜间模式已关闭")
