Skip to content

Commit

Permalink
✨ Support log notice
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Nov 7, 2023
1 parent 3db24a0 commit db2f11c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pagermaid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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,
Expand Down Expand Up @@ -81,12 +81,16 @@
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"

0 comments on commit db2f11c

Please sign in to comment.