mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-11 01:27:29 +08:00
feat: 自动更新功能
This commit is contained in:
parent
185b1d8a21
commit
6a4c88a6ba
@ -13,7 +13,7 @@ from liteyuki.utils.config import get_config, load_from_yaml
|
|||||||
from liteyuki.utils.data_manager import StoredConfig, TempConfig, common_db
|
from liteyuki.utils.data_manager import StoredConfig, TempConfig, common_db
|
||||||
from liteyuki.utils.language import get_user_lang
|
from liteyuki.utils.language import get_user_lang
|
||||||
from liteyuki.utils.ly_typing import T_Bot, T_MessageEvent
|
from liteyuki.utils.ly_typing import T_Bot, T_MessageEvent
|
||||||
from liteyuki.utils.message import Markdown as md
|
from liteyuki.utils.message import Markdown as md, broadcast_to_superusers
|
||||||
from liteyuki.utils.reloader import Reloader
|
from liteyuki.utils.reloader import Reloader
|
||||||
from .api import update_liteyuki
|
from .api import update_liteyuki
|
||||||
|
|
||||||
@ -225,7 +225,8 @@ async def every_day_update():
|
|||||||
if get_config("auto_update", True):
|
if get_config("auto_update", True):
|
||||||
result, logs = update_liteyuki()
|
result, logs = update_liteyuki()
|
||||||
if result:
|
if result:
|
||||||
|
await broadcast_to_superusers(f"Liteyuki updated: ```\n{logs}\n```")
|
||||||
nonebot.logger.info(f"Liteyuki updated: {logs}")
|
nonebot.logger.info(f"Liteyuki updated: {logs}")
|
||||||
Reloader.reload(1)
|
Reloader.reload(1)
|
||||||
else:
|
else:
|
||||||
nonebot.logger.info(logs)
|
nonebot.logger.info(logs)
|
||||||
|
@ -13,7 +13,7 @@ from typing import Any
|
|||||||
|
|
||||||
from . import load_from_yaml
|
from . import load_from_yaml
|
||||||
from .ly_api import liteyuki_api
|
from .ly_api import liteyuki_api
|
||||||
from .ly_typing import T_Bot, T_MessageEvent
|
from .ly_typing import T_Bot, T_Message, T_MessageEvent
|
||||||
|
|
||||||
require("nonebot_plugin_htmlrender")
|
require("nonebot_plugin_htmlrender")
|
||||||
from nonebot_plugin_htmlrender import md_to_pic
|
from nonebot_plugin_htmlrender import md_to_pic
|
||||||
@ -23,6 +23,16 @@ config = load_from_yaml("config.yml")
|
|||||||
can_send_markdown = {} # 用于存储机器人是否支持发送markdown消息,id->bool
|
can_send_markdown = {} # 用于存储机器人是否支持发送markdown消息,id->bool
|
||||||
|
|
||||||
|
|
||||||
|
async def broadcast_to_superusers(message: str | T_Message, markdown: bool = False):
|
||||||
|
"""广播消息给超级用户"""
|
||||||
|
for bot in nonebot.get_bots().values():
|
||||||
|
for user_id in config.get("superusers", []):
|
||||||
|
if markdown:
|
||||||
|
await Markdown.send_md(message, bot, message_type="private", session_id=user_id)
|
||||||
|
else:
|
||||||
|
await bot.send_private_msg(user_id=user_id, message=message)
|
||||||
|
|
||||||
|
|
||||||
class Markdown:
|
class Markdown:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def send_md(
|
async def send_md(
|
||||||
|
Loading…
Reference in New Issue
Block a user