mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-15 00:24:26 +08:00
feat: 自动向轻雪服务器上报错误信息
This commit is contained in:
parent
5a929d3e99
commit
ccef8ca125
36
README.md
36
README.md
@ -16,9 +16,10 @@
|
|||||||
- 基于[Nonebot2]("https://github.com/nonebot/nonebot2"),有良好的生态支持
|
- 基于[Nonebot2]("https://github.com/nonebot/nonebot2"),有良好的生态支持
|
||||||
- 开箱即用,无需复杂配置
|
- 开箱即用,无需复杂配置
|
||||||
- 新的点击交互模式,拒绝手打指令
|
- 新的点击交互模式,拒绝手打指令
|
||||||
- 支持一切Onebot标准通信,后续会支持更多的平台
|
- 全新可视化`npm`包管理,支持一键安装插件
|
||||||
|
- 支持一切Onebot标准通信
|
||||||
|
|
||||||
## 手动安装和部署
|
## 1.手动安装和部署
|
||||||
|
|
||||||
1. 安装`Git`和`Python3.10+`
|
1. 安装`Git`和`Python3.10+`
|
||||||
2. 克隆项目`git clone https://github.com/snowykami/LiteyukiBot`
|
2. 克隆项目`git clone https://github.com/snowykami/LiteyukiBot`
|
||||||
@ -26,7 +27,7 @@
|
|||||||
4. 安装依赖`pip install -r requirements.txt`(如果多个Python环境请指定后安装`pythonx -m pip install -r requirements.txt`)
|
4. 安装依赖`pip install -r requirements.txt`(如果多个Python环境请指定后安装`pythonx -m pip install -r requirements.txt`)
|
||||||
5. 启动`python main.py`
|
5. 启动`python main.py`
|
||||||
|
|
||||||
## 一键部署脚本
|
## 1.一键部署脚本
|
||||||
|
|
||||||
#### 提前部署好`Python3.10+`环境和`Git`环境
|
#### 提前部署好`Python3.10+`环境和`Git`环境
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ echo Install finished! Please click "start.bat" to start the bot!
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Linux
|
#### Linux
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/snowykami/LiteyukiBot
|
git clone https://github.com/snowykami/LiteyukiBot
|
||||||
cd LiteyukiBot
|
cd LiteyukiBot
|
||||||
@ -51,6 +53,25 @@ chmod +x start.sh
|
|||||||
echo Install finished! Please run "sh start.sh" to start the bot!
|
echo Install finished! Please run "sh start.sh" to start the bot!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 2. 配置项(Nonebot插件配置项也可以写在此)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# 建议修改的配置项目
|
||||||
|
command_start: [ "/", " " ] # 指令前缀
|
||||||
|
host: 127.0.0.1 # 反向监听地址
|
||||||
|
port: 20216 # 绑定端口
|
||||||
|
nickname: [ "liteyuki" ] # 机器人昵称
|
||||||
|
superusers: [ "1919810" ] # 超级用户
|
||||||
|
show_icon: true # 是否显示日志等级图标(某些控制台不可用)
|
||||||
|
|
||||||
|
# 下面是不建议修改,且默认没有列出的配置项,除非你有特殊需求
|
||||||
|
log_level: "INFO" # 日志等级
|
||||||
|
|
||||||
|
# 其他Nonebot插件的配置项
|
||||||
|
custom_config_1: "custom_value1"
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
## 注意事项
|
## 注意事项
|
||||||
|
|
||||||
- 首次启动会提醒用户注册超级用户
|
- 首次启动会提醒用户注册超级用户
|
||||||
@ -65,16 +86,25 @@ echo Install finished! Please run "sh start.sh" to start the bot!
|
|||||||
| 地址 | ws://`host`:`port`/onebot/v11 | 地址取决于配置文件,默认为`20216`端口 |
|
| 地址 | ws://`host`:`port`/onebot/v11 | 地址取决于配置文件,默认为`20216`端口 |
|
||||||
|
|
||||||
### 推荐方案(QQ)
|
### 推荐方案(QQ)
|
||||||
|
|
||||||
1. 使用`Lagrange.OneBot`,点按交互目前仅支持`Lagrange.OneBot`,详细请看[Lagrange.OneBot]()
|
1. 使用`Lagrange.OneBot`,点按交互目前仅支持`Lagrange.OneBot`,详细请看[Lagrange.OneBot]()
|
||||||
2. 云崽的`icqq-plugin`和`ws-plugin`进行通信
|
2. 云崽的`icqq-plugin`和`ws-plugin`进行通信
|
||||||
3. `Go-cqhttp`(目前已经半死不活了)
|
3. `Go-cqhttp`(目前已经半死不活了)
|
||||||
4. 人工实现的`Onebot`协议,自己整一个WebSocket客户端,看着QQ的消息,然后给轻雪传输数据
|
4. 人工实现的`Onebot`协议,自己整一个WebSocket客户端,看着QQ的消息,然后给轻雪传输数据
|
||||||
|
|
||||||
### 推荐方案(Minecraft)
|
### 推荐方案(Minecraft)
|
||||||
|
|
||||||
1. 我们有专门为Minecraft开发的服务器Bot,支持OnebotV11/12标准,详细请看[MinecraftOneBot](https://github.com/snowykami/MinecraftOnebot)
|
1. 我们有专门为Minecraft开发的服务器Bot,支持OnebotV11/12标准,详细请看[MinecraftOneBot](https://github.com/snowykami/MinecraftOnebot)
|
||||||
|
|
||||||
请先自行查阅文档,若有困难请联系相关开发者而不是Liteyuki的开发者
|
请先自行查阅文档,若有困难请联系相关开发者而不是Liteyuki的开发者
|
||||||
|
|
||||||
## 其他
|
## 其他
|
||||||
|
|
||||||
- 有一个用`Nuitka`编译的C语言版本可用
|
- 有一个用`Nuitka`编译的C语言版本可用
|
||||||
|
|
||||||
|
## 用户协议
|
||||||
|
1. 本项目遵循`MIT`协议,你可以自由使用,修改,分发,但是请保留原作者信息
|
||||||
|
2. 轻雪会收集使用者的设备信息,通过安全的方式传输到服务器,用于统计用户数量和设备信息,进行优化
|
||||||
|
3. 本项目不会收集用户的任何隐私信息,但请注意甄别第三方插件的安全性
|
||||||
|
|
||||||
## 鸣谢
|
## 鸣谢
|
||||||
|
@ -1,14 +1,47 @@
|
|||||||
import nonebot
|
import json
|
||||||
|
import os.path
|
||||||
|
import platform
|
||||||
|
|
||||||
from .log import logger
|
import nonebot
|
||||||
import sys
|
import sys
|
||||||
|
import pickle
|
||||||
|
|
||||||
__NAME__ = "LiteyukiBot"
|
__NAME__ = "LiteyukiBot"
|
||||||
__VERSION__ = "6.2.1" # 60201
|
__VERSION__ = "6.2.3" # 60201
|
||||||
|
|
||||||
|
import psutil
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from liteyuki.utils.config import load_from_yaml
|
||||||
|
|
||||||
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()}",
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
nonebot.logger.info("Waiting for register to Liteyuki...")
|
||||||
|
resp = requests.post(url, json=data)
|
||||||
|
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():
|
||||||
"""
|
"""
|
||||||
初始化
|
初始化
|
||||||
@ -20,6 +53,12 @@ def init():
|
|||||||
nonebot.logger.error("This project requires Python3.10+ to run, please upgrade your Python Environment.")
|
nonebot.logger.error("This project requires Python3.10+ to run, please upgrade your Python Environment.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
load_from_yaml("config.yml")
|
||||||
|
from .log import logger
|
||||||
|
|
||||||
|
if not os.path.exists("data/liteyuki/liteyuki.json"):
|
||||||
|
register_bot()
|
||||||
|
|
||||||
print("\033[34m" + r"""
|
print("\033[34m" + r"""
|
||||||
__ ______ ________ ________ __ __ __ __ __ __ ______
|
__ ______ ________ ________ __ __ __ __ __ __ ______
|
||||||
/ | / |/ |/ |/ \ / |/ | / |/ | / |/ |
|
/ | / |/ |/ |/ \ / |/ | / |/ | / |/ |
|
||||||
|
@ -49,10 +49,10 @@ logger_id = logger.add(
|
|||||||
level=0,
|
level=0,
|
||||||
diagnose=False,
|
diagnose=False,
|
||||||
filter=default_filter,
|
filter=default_filter,
|
||||||
format=get_format(load_from_yaml('config.yml').get("log_level", "INFO")),
|
format=get_format(config.get("log_level", "INFO")),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
show_icon = config.get("show_icon", True)
|
||||||
logger.level("DEBUG", color="<blue>", icon=f"*️⃣==DEBUG")
|
logger.level("DEBUG", color="<blue>", icon=f"*️⃣==DEBUG")
|
||||||
logger.level("INFO", color="<white>", icon=f"ℹ️===INFO")
|
logger.level("INFO", color="<white>", icon=f"ℹ️===INFO")
|
||||||
logger.level("SUCCESS", color="<green>", icon=f"✅SUCCESS")
|
logger.level("SUCCESS", color="<green>", icon=f"✅SUCCESS")
|
||||||
|
@ -15,3 +15,4 @@ PyYAML~=6.0.1
|
|||||||
starlette~=0.36.3
|
starlette~=0.36.3
|
||||||
loguru==0.7.2
|
loguru==0.7.2
|
||||||
importlib_metadata==7.0.2
|
importlib_metadata==7.0.2
|
||||||
|
requests==2.31.0
|
Loading…
Reference in New Issue
Block a user