mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-21 23:55:33 +00:00
✨ Support log notice
This commit is contained in:
parent
3db24a013c
commit
db2f11ca9a
@ -3,7 +3,7 @@ import contextlib
|
|||||||
from typing import Callable, Awaitable, Set, Dict
|
from typing import Callable, Awaitable, Set, Dict
|
||||||
|
|
||||||
from coloredlogs import ColoredFormatter
|
from coloredlogs import ColoredFormatter
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone, timedelta
|
||||||
from logging import (
|
from logging import (
|
||||||
getLogger,
|
getLogger,
|
||||||
StreamHandler,
|
StreamHandler,
|
||||||
@ -81,12 +81,16 @@ bot = Client(
|
|||||||
bot.job = scheduler
|
bot.job = scheduler
|
||||||
|
|
||||||
|
|
||||||
async def log(message):
|
async def log(message: str, notice: bool = False):
|
||||||
logs.info(message.replace("`", '"'))
|
logs.info(message.replace("`", '"'))
|
||||||
if not Config.LOG:
|
if not Config.LOG:
|
||||||
return
|
return
|
||||||
try:
|
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:
|
except Exception:
|
||||||
Config.LOG = False
|
Config.LOG = False
|
||||||
Config.LOG_ID = "me"
|
Config.LOG_ID = "me"
|
||||||
|
Loading…
Reference in New Issue
Block a user