From db2f11ca9a20b7490c5b88c8f6a6f0b83941b98b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 7 Nov 2023 20:05:06 +0800 Subject: [PATCH] :sparkles: Support log notice --- pagermaid/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index 02f83ca..ab7469c 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -3,7 +3,7 @@ import contextlib from typing import Callable, Awaitable, Set, Dict from coloredlogs import ColoredFormatter -from datetime import datetime, timezone +from datetime import datetime, timezone, timedelta from logging import ( getLogger, StreamHandler, @@ -81,12 +81,16 @@ bot = Client( bot.job = scheduler -async def log(message): +async def log(message: str, notice: bool = False): logs.info(message.replace("`", '"')) if not Config.LOG: return try: - await bot.send_message(Config.LOG_ID, message) + await bot.send_message( + Config.LOG_ID, + message, + schedule_date=(datetime.now() + timedelta(seconds=3)) if notice else None, + ) except Exception: Config.LOG = False Config.LOG_ID = "me"