mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-22 22:37:37 +08:00
⬇️ 修复部分依赖问题,目前请勿使用清华镜像源安装
This commit is contained in:
parent
4705eac79c
commit
ca89fa7efd
@ -1,36 +1,28 @@
|
|||||||
aiohttp~=3.9.3
|
aiohttp>=3.9.3
|
||||||
aiofiles~=23.2.1
|
aiofiles>=23.2.1
|
||||||
colored~=2.2.4
|
colored>=2.2.4
|
||||||
GitPython~=3.1.42
|
GitPython>=3.1.43
|
||||||
httpx~=0.27.0
|
httpx>=0.27.0
|
||||||
nb-cli~=1.4.1
|
liteyukibot-plugin-htmlrender>=0.1.0
|
||||||
nonebot2[fastapi,httpx,websockets]~=2.3.3
|
nonebot2[fastapi,httpx,websockets]>=2.3.3
|
||||||
nonebot-adapter-onebot~=2.4.3
|
nonebot-adapter-onebot>=2.4.3
|
||||||
nonebot-plugin-alconna~=0.46.3
|
nonebot-plugin-alconna>=0.46.3
|
||||||
nonebot_plugin_apscheduler~=0.4.0
|
nonebot_plugin_apscheduler>=0.4.0
|
||||||
nonebot-adapter-satori~=0.11.5
|
nonebot-adapter-satori>=0.11.5
|
||||||
liteyukibot-plugin-htmlrender~=0.1.0
|
pyppeteer>=2.0.0
|
||||||
pyppeteer~=2.0.0
|
|
||||||
markdown>=3.3.6
|
markdown>=3.3.6
|
||||||
zhDateTime>=1.0.3
|
zhDateTime>=1.0.3
|
||||||
numpy<2.0.0
|
numpy>=2.1.0
|
||||||
packaging~=23.1
|
packaging>=23.1
|
||||||
psutil~=5.9.8
|
psutil>=5.9.8
|
||||||
py-cpuinfo~=9.0.0
|
py-cpuinfo>=9.0.0
|
||||||
pydantic~=2.7.0
|
Pygments>=2.17.2
|
||||||
Pygments~=2.17.2
|
pyppeteer>=2.0.0
|
||||||
pyppeteer~=2.0.0
|
pytz>=2024.1
|
||||||
pytz~=2024.1
|
PyYAML>=6.0.1
|
||||||
PyYAML~=6.0.1
|
pillow>=10.0.0
|
||||||
pillow~=10.0.0
|
toml>=0.10.2
|
||||||
pdm-backend~=2.3.3
|
importlib_metadata>=7.0.2
|
||||||
starlette~=0.36.3
|
watchdog>=4.0.0
|
||||||
toml~=0.10.2
|
jieba>=0.42.1
|
||||||
loguru~=0.7.2
|
python-dotenv>=1.0.1
|
||||||
importlib_metadata~=7.0.2
|
|
||||||
requests~=2.31.0
|
|
||||||
watchdog~=4.0.0
|
|
||||||
jieba~=0.42.1
|
|
||||||
aiosqlite3~=0.3.0
|
|
||||||
fastapi~=0.110.0
|
|
||||||
python-dotenv~=1.0.1
|
|
@ -8,10 +8,6 @@ from src.utils.base.data_manager import InstalledPlugin, plugin_db
|
|||||||
from src.utils.base.resource import load_resources
|
from src.utils.base.resource import load_resources
|
||||||
from src.utils.message.tools import check_for_package
|
from src.utils.message.tools import check_for_package
|
||||||
|
|
||||||
from liteyuki import get_bot
|
|
||||||
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
|
|
||||||
load_resources()
|
load_resources()
|
||||||
init_log()
|
init_log()
|
||||||
|
|
||||||
@ -29,7 +25,7 @@ async def load_plugins():
|
|||||||
for installed_plugin in installed_plugins:
|
for installed_plugin in installed_plugins:
|
||||||
if not check_for_package(installed_plugin.module_name):
|
if not check_for_package(installed_plugin.module_name):
|
||||||
nonebot.logger.error(
|
nonebot.logger.error(
|
||||||
f"{installed_plugin.module_name} not installed, but in loading database. please run `npm fixup` in chat to reinstall it.")
|
f"{installed_plugin.module_name} not installed, but still in loader index.")
|
||||||
else:
|
else:
|
||||||
nonebot.load_plugin(installed_plugin.module_name)
|
nonebot.load_plugin(installed_plugin.module_name)
|
||||||
nonebot.plugin.load_plugins("plugins")
|
nonebot.plugin.load_plugins("plugins")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import httpx
|
|
||||||
import nonebot
|
import nonebot
|
||||||
from nonebot import require
|
from nonebot import require
|
||||||
from nonebot.exception import IgnoredException
|
from nonebot.exception import IgnoredException
|
||||||
|
@ -1,50 +1,18 @@
|
|||||||
import json
|
|
||||||
import os.path
|
|
||||||
import platform
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
|
|
||||||
import nonebot
|
import nonebot
|
||||||
|
|
||||||
__NAME__ = "LiteyukiBot"
|
__NAME__ = "LiteyukiBot"
|
||||||
__VERSION__ = "6.3.2" # 60201
|
__VERSION__ = "6.3.2" # 60201
|
||||||
|
|
||||||
import requests
|
|
||||||
|
|
||||||
from src.utils.base.config import load_from_yaml, config
|
from src.utils.base.config import load_from_yaml, config
|
||||||
from src.utils.base.log import init_log
|
from src.utils.base.log import init_log
|
||||||
from git import Repo
|
from git import Repo
|
||||||
|
|
||||||
|
|
||||||
major, minor, patch = map(int, __VERSION__.split("."))
|
major, minor, patch = map(int, __VERSION__.split("."))
|
||||||
__VERSION_I__ = major * 10000 + minor * 100 + patch
|
__VERSION_I__ = major * 10000 + minor * 100 + patch
|
||||||
|
|
||||||
|
|
||||||
def register_bot():
|
|
||||||
url = "https://api.liteyuki.icu/register"
|
|
||||||
data = {
|
|
||||||
"name" : __NAME__,
|
|
||||||
"version" : __VERSION__,
|
|
||||||
"version_i": __VERSION_I__,
|
|
||||||
"python" : f"{platform.python_implementation()} {platform.python_version()}",
|
|
||||||
"os" : f"{platform.system()} {platform.version()} {platform.machine()}"
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
nonebot.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"))
|
|
||||||
nonebot.logger.success(f"Register {liteyuki_id} to Liteyuki successfully")
|
|
||||||
else:
|
|
||||||
raise ValueError(f"Register to Liteyuki failed: {data}")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
nonebot.logger.warning(f"Register to Liteyuki failed, but it's no matter: {e}")
|
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""
|
"""
|
||||||
初始化
|
初始化
|
||||||
@ -67,18 +35,8 @@ def init():
|
|||||||
# temp_data.data["start_time"] = time.time()
|
# temp_data.data["start_time"] = time.time()
|
||||||
# common_db.save(temp_data)
|
# common_db.save(temp_data)
|
||||||
|
|
||||||
# 在加载完成语言后再初始化日志
|
|
||||||
nonebot.logger.info("Liteyuki is initializing...")
|
|
||||||
|
|
||||||
if not os.path.exists("data/liteyuki/liteyuki.json"):
|
|
||||||
register_bot()
|
|
||||||
|
|
||||||
if not os.path.exists("pyproject.toml"):
|
|
||||||
with open("pyproject.toml", "w", encoding="utf-8") as f:
|
|
||||||
f.write("[tool.nonebot]\n")
|
|
||||||
|
|
||||||
nonebot.logger.info(
|
nonebot.logger.info(
|
||||||
f"Run Liteyuki with Python{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} "
|
f"Run Liteyuki-NoneBot with Python{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} "
|
||||||
f"at {sys.executable}"
|
f"at {sys.executable}"
|
||||||
)
|
)
|
||||||
nonebot.logger.info(f"{__NAME__} {__VERSION__}({__VERSION_I__}) is running")
|
nonebot.logger.info(f"{__NAME__} {__VERSION__}({__VERSION_I__}) is running")
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
import json
|
|
||||||
import os.path
|
|
||||||
import platform
|
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
import nonebot
|
|
||||||
import psutil
|
|
||||||
import requests
|
|
||||||
|
|
||||||
from .config import load_from_yaml
|
|
||||||
from .. import __NAME__, __VERSION_I__, __VERSION__
|
|
||||||
|
|
||||||
|
|
||||||
class LiteyukiAPI:
|
|
||||||
def __init__(self):
|
|
||||||
self.liteyuki_id = None
|
|
||||||
if os.path.exists("data/liteyuki/liteyuki.json"):
|
|
||||||
with open("data/liteyuki/liteyuki.json", "rb") as f:
|
|
||||||
self.data = json.loads(f.read())
|
|
||||||
self.liteyuki_id = self.data.get("liteyuki_id")
|
|
||||||
self.report = load_from_yaml("config.yml").get("auto_report", True)
|
|
||||||
|
|
||||||
if self.report:
|
|
||||||
nonebot.logger.info("Auto report enabled")
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> dict:
|
|
||||||
"""
|
|
||||||
获取设备信息
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
"""
|
|
||||||
return {
|
|
||||||
"name" : __NAME__,
|
|
||||||
"version" : __VERSION__,
|
|
||||||
"version_i" : __VERSION_I__,
|
|
||||||
"python" : f"{platform.python_implementation()} {platform.python_version()}",
|
|
||||||
"os" : f"{platform.system()} {platform.version()} {platform.machine()}",
|
|
||||||
"cpu" : f"{psutil.cpu_count(logical=False)}c{psutil.cpu_count()}t{psutil.cpu_freq().current}MHz",
|
|
||||||
"memory_total": f"{psutil.virtual_memory().total / 1024 ** 3:.2f}GB",
|
|
||||||
"memory_used" : f"{psutil.virtual_memory().used / 1024 ** 3:.2f}GB",
|
|
||||||
"memory_bot" : f"{psutil.Process(os.getpid()).memory_info().rss / 1024 ** 2:.2f}MB",
|
|
||||||
"disk" : f"{psutil.disk_usage('/').total / 1024 ** 3:.2f}GB"
|
|
||||||
}
|
|
||||||
|
|
||||||
def bug_report(self, content: str):
|
|
||||||
"""
|
|
||||||
提交bug报告
|
|
||||||
Args:
|
|
||||||
content:
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
"""
|
|
||||||
if self.report:
|
|
||||||
nonebot.logger.warning(f"Reporting bug...: {content}")
|
|
||||||
url = "https://api.liteyuki.icu/bug_report"
|
|
||||||
data = {
|
|
||||||
"liteyuki_id": self.liteyuki_id,
|
|
||||||
"content" : content,
|
|
||||||
"device_info": self.device_info
|
|
||||||
}
|
|
||||||
resp = requests.post(url, json=data)
|
|
||||||
if resp.status_code == 200:
|
|
||||||
nonebot.logger.success(f"Bug report sent successfully, report_id: {resp.json().get('report_id')}")
|
|
||||||
else:
|
|
||||||
nonebot.logger.error(f"Bug report failed: {resp.text}")
|
|
||||||
else:
|
|
||||||
nonebot.logger.warning(f"Bug report is disabled: {content}")
|
|
||||||
|
|
||||||
def register(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
async def heartbeat_report(self):
|
|
||||||
"""
|
|
||||||
提交心跳,预留接口
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
"""
|
|
||||||
url = "https://api.liteyuki.icu/heartbeat"
|
|
||||||
data = {
|
|
||||||
"liteyuki_id": self.liteyuki_id,
|
|
||||||
"version" : __VERSION__,
|
|
||||||
}
|
|
||||||
async with aiohttp.ClientSession() as session:
|
|
||||||
async with session.post(url, json=data) as resp:
|
|
||||||
if resp.status == 200:
|
|
||||||
nonebot.logger.success("Heartbeat sent successfully")
|
|
||||||
else:
|
|
||||||
nonebot.logger.error(f"Heartbeat failed: {await resp.text()}")
|
|
Loading…
Reference in New Issue
Block a user