2024-08-08 18:10:18 +08:00
|
|
|
# -*- 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
|
2024-08-10 22:25:41 +08:00
|
|
|
import asyncio
|
|
|
|
|
2024-08-08 18:10:18 +08:00
|
|
|
from liteyuki.plugin import PluginMetadata
|
|
|
|
from liteyuki import get_bot, logger
|
2024-08-10 22:25:41 +08:00
|
|
|
from liteyuki.comm.channel import get_channel
|
2024-08-08 18:10:18 +08:00
|
|
|
|
|
|
|
__plugin_meta__ = PluginMetadata(
|
|
|
|
name="lifespan_monitor",
|
|
|
|
)
|
|
|
|
|
|
|
|
bot = get_bot()
|
2024-08-10 22:25:41 +08:00
|
|
|
nbp_chan = get_channel("nonebot-passive")
|
|
|
|
mbp_chan = get_channel("melobot-passive")
|
2024-08-08 18:10:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
@bot.on_before_start
|
|
|
|
def _():
|
|
|
|
logger.info("生命周期监控器:准备启动")
|
|
|
|
|
|
|
|
|
|
|
|
@bot.on_before_shutdown
|
|
|
|
def _():
|
2024-08-10 22:25:41 +08:00
|
|
|
print(get_channel("main"))
|
2024-08-08 18:10:18 +08:00
|
|
|
logger.info("生命周期监控器:准备停止")
|
|
|
|
|
|
|
|
|
|
|
|
@bot.on_before_restart
|
|
|
|
def _():
|
|
|
|
logger.info("生命周期监控器:准备重启")
|
|
|
|
|
|
|
|
|
|
|
|
@bot.on_after_start
|
|
|
|
def _():
|
|
|
|
logger.info("生命周期监控器:启动完成")
|
2024-08-10 22:25:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
@bot.on_after_start
|
|
|
|
async def _():
|
|
|
|
logger.info("生命周期监控器:启动完成")
|
|
|
|
while True:
|
|
|
|
await asyncio.sleep(3)
|
|
|
|
nbp_chan.send("send by main")
|
|
|
|
|
|
|
|
|
2024-08-10 22:27:42 +08:00
|
|
|
# @mbp_chan.on_receive()
|
|
|
|
# @nbp_chan.on_receive()
|
|
|
|
# async def _(data):
|
|
|
|
# print("主进程收到数据", data)
|