🔀手动Merge轻雪主仓库a77f97f

This commit is contained in:
2024-10-06 02:39:10 +08:00
parent 4cc2ae61db
commit f8b57bfe9a
108 changed files with 3131 additions and 3574 deletions

View File

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""
此模块为内置插件文件夹,用于存放内置插件。
This module is the built-in plugin folder, used to store built-in plugins.
"""

View File

@ -1,55 +0,0 @@
# -*- 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
from liteyuki.plugin import PluginMetadata
from liteyuki import get_bot, logger
from liteyuki.comm.channel import get_channel
__plugin_meta__ = PluginMetadata(
name="lifespan_monitor",
)
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("生命周期监控器:启动后")
@bot.on_after_start
async def _():
logger.info("生命周期监控器:启动后")
# @mbp_chan.on_receive()
# @nbp_chan.on_receive()
# async def _(data):
# print("主进程收到数据", data)

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/22 下午12:31
@Author : snowykami
@Email : snowykami@outlook.com
@File : liteecho.py
@Software: PyCharm
"""
from liteyuki.message.on import on_startswith
from liteyuki.message.event import MessageEvent
from liteyuki.message.rule import is_su_rule
@on_startswith(["ryounecho", "ryeco"], rule=is_su_rule).handle()
async def liteecho(event: MessageEvent):
event.reply(event.raw_message.strip()[8:].strip())

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/11 下午10:02
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py.py
@Software: PyCharm
"""
from liteyuki import get_config, load_plugin
from liteyuki.plugin import PluginMetadata, load_plugins, PluginType
__plugin_meta__ = PluginMetadata(
name="外部轻雪插件加载器",
description="插件加载器,用于加载轻雪原生插件",
type=PluginType.SERVICE
)
def default_plugins_loader():
"""
默认插件加载器,应在初始化时调用
"""
for plugin in get_config("liteyuki.plugins", []):
load_plugin(plugin)
for plugin_dir in get_config("liteyuki.plugin_dirs", ["src/liteyuki_plugins"]):
load_plugins(plugin_dir)
default_plugins_loader()

View File

@ -1,57 +0,0 @@
# -*- 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" : "尹灵温|轻雪-睿乐",
"version" : "即时更新",
"hash" : commit_hash,
"version_i": 99,
"python" : f"{platform.python_implementation()} {platform.python_version()}",
"os" : f"{platform.system()} {platform.version()} {platform.machine()}"
}
try:
logger.info("正在等待 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("成功将 {} 注册到 Liteyuki 服务器".format(liteyuki_id))
else:
raise ValueError(f"无法向 Liteyuki 服务器注册:{data}")
except Exception as e:
logger.warning(f"虽然向 Liteyuki 服务器注册失败,但无关紧要:{e}")
@liteyuki.on_before_start
async def _():
if not os.path.exists("data/liteyuki/liteyuki.json"):
register_bot()

View File

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/10 下午5:18
@Author : snowykami
@Email : snowykami@outlook.com
@File : reloader_monitor.py
@Software: PyCharm
"""