🐛 fix 通道无法在进程内传递消息的问题
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
# 说明
|
||||
|
||||
此目录为**轻雪插件**目录,非其他插件目录。
|
45
src/liteyuki_plugins/lifespan_monitor.py
Normal file
45
src/liteyuki_plugins/lifespan_monitor.py
Normal file
@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
#
|
||||
# @Time : 2024/7/22 上午11:25
|
||||
# @Author : snowykami
|
||||
# @Email : snowykami@outlook.com
|
||||
# @File : asa.py
|
||||
# @Software: PyCharm
|
||||
import asyncio
|
||||
import multiprocessing
|
||||
|
||||
from liteyuki.plugin import PluginMetadata
|
||||
from liteyuki import get_bot, logger
|
||||
from liteyuki.comm.channel import get_channel
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="生命周期日志",
|
||||
)
|
||||
|
||||
bot = get_bot()
|
||||
|
||||
|
||||
# nbp_chan = get_channel("nonebot-passive")
|
||||
# mbp_chan = get_channel("melobot-passive")
|
||||
|
||||
@bot.on_before_start
|
||||
def _():
|
||||
logger.info("生命周期监控器:准备启动")
|
||||
|
||||
|
||||
@bot.on_before_shutdown
|
||||
def _():
|
||||
print(get_channel("main"))
|
||||
logger.info("生命周期监控器:准备停止")
|
||||
|
||||
|
||||
@bot.on_before_restart
|
||||
def _():
|
||||
logger.info("生命周期监控器:准备重启")
|
||||
|
||||
|
||||
@bot.on_after_start
|
||||
def _():
|
||||
logger.info("生命周期监控器:启动完成")
|
9
src/liteyuki_plugins/process_manager/__init__.py
Normal file
9
src/liteyuki_plugins/process_manager/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
from liteyuki.plugin import PluginMetadata
|
||||
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="进程管理器",
|
||||
version="0.1.0",
|
||||
author="snowykami",
|
||||
description="进程管理器,用于管理子进程"
|
||||
)
|
10
src/liteyuki_plugins/reboot.py
Normal file
10
src/liteyuki_plugins/reboot.py
Normal file
@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
|
||||
@Time : 2024/8/11 下午8:22
|
||||
@Author : snowykami
|
||||
@Email : snowykami@outlook.com
|
||||
@File : reloader.py.py
|
||||
@Software: PyCharm
|
||||
"""
|
57
src/liteyuki_plugins/register_service.py
Normal file
57
src/liteyuki_plugins/register_service.py
Normal file
@ -0,0 +1,57 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
|
||||
@Time : 2024/8/10 下午11:25
|
||||
@Author : snowykami
|
||||
@Email : snowykami@outlook.com
|
||||
@File : register_service.py
|
||||
@Software: PyCharm
|
||||
"""
|
||||
import json
|
||||
import os.path
|
||||
import platform
|
||||
|
||||
import requests
|
||||
from git import Repo
|
||||
from liteyuki.plugin import PluginMetadata
|
||||
from liteyuki import get_bot, logger
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="注册服务",
|
||||
)
|
||||
|
||||
liteyuki = get_bot()
|
||||
commit_hash = Repo(".").head.commit.hexsha
|
||||
|
||||
|
||||
def register_bot():
|
||||
url = "https://api.liteyuki.icu/register"
|
||||
data = {
|
||||
"name" : "LiteyukiBot",
|
||||
"version" : "RollingUpdate",
|
||||
"hash" : commit_hash,
|
||||
"version_i": 0,
|
||||
"python" : f"{platform.python_implementation()} {platform.python_version()}",
|
||||
"os" : f"{platform.system()} {platform.version()} {platform.machine()}"
|
||||
}
|
||||
try:
|
||||
logger.info("Waiting for register to Liteyuki...")
|
||||
resp = requests.post(url, json=data, timeout=(10, 15))
|
||||
if resp.status_code == 200:
|
||||
data = resp.json()
|
||||
if liteyuki_id := data.get("liteyuki_id"):
|
||||
with open("data/liteyuki/liteyuki.json", "wb") as f:
|
||||
f.write(json.dumps(data).encode("utf-8"))
|
||||
logger.success(f"Register {liteyuki_id} to Liteyuki successfully")
|
||||
else:
|
||||
raise ValueError(f"Register to Liteyuki failed: {data}")
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Register to Liteyuki failed, but it's no matter: {e}")
|
||||
|
||||
|
||||
@liteyuki.on_before_start
|
||||
async def _():
|
||||
if not os.path.exists("data/liteyuki/liteyuki.json"):
|
||||
register_bot()
|
0
src/liteyuki_plugins/resource_loader/__init__.py
Normal file
0
src/liteyuki_plugins/resource_loader/__init__.py
Normal file
Reference in New Issue
Block a user