Merge branch 'SengokuCola:debug' into debug
This commit is contained in:
56
flake.lock
generated
56
flake.lock
generated
@@ -1,43 +1,21 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1741196730,
|
"lastModified": 0,
|
||||||
"narHash": "sha256-0Sj6ZKjCpQMfWnN0NURqRCQn2ob7YtXTAOTwCuz7fkA=",
|
"narHash": "sha256-nJj8f78AYAxl/zqLiFGXn5Im1qjFKU8yBPKoWEeZN5M=",
|
||||||
"owner": "NixOS",
|
"path": "/nix/store/f30jn7l0bf7a01qj029fq55i466vmnkh-source",
|
||||||
"repo": "nixpkgs",
|
"type": "path"
|
||||||
"rev": "48913d8f9127ea6530a2a2f1bd4daa1b8685d8a3",
|
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-24.11",
|
"type": "indirect"
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs": "nixpkgs"
|
"utils": "utils"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
@@ -54,6 +32,24 @@
|
|||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|||||||
69
flake.nix
69
flake.nix
@@ -1,62 +1,37 @@
|
|||||||
{
|
{
|
||||||
description = "MaiMBot Nix Dev Env";
|
description = "MaiMBot Nix Dev Env";
|
||||||
# 本配置仅方便用于开发,但是因为 nb-cli 上游打包中并未包含 nonebot2,因此目前本配置并不能用于运行和调试
|
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
utils.url = "github:numtide/flake-utils";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = {
|
||||||
{
|
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
utils,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
utils.lib.eachDefaultSystem (system: let
|
||||||
system:
|
pkgs = import nixpkgs {inherit system;};
|
||||||
let
|
pythonPackages = pkgs.python3Packages;
|
||||||
pkgs = import nixpkgs {
|
in {
|
||||||
inherit system;
|
devShells.default = pkgs.mkShell {
|
||||||
};
|
name = "python-venv";
|
||||||
|
venvDir = "./.venv";
|
||||||
pythonEnv = pkgs.python3.withPackages (
|
|
||||||
ps: with ps; [
|
|
||||||
ruff
|
|
||||||
pymongo
|
|
||||||
python-dotenv
|
|
||||||
pydantic
|
|
||||||
jieba
|
|
||||||
openai
|
|
||||||
aiohttp
|
|
||||||
requests
|
|
||||||
urllib3
|
|
||||||
numpy
|
|
||||||
pandas
|
|
||||||
matplotlib
|
|
||||||
networkx
|
|
||||||
python-dateutil
|
|
||||||
APScheduler
|
|
||||||
loguru
|
|
||||||
tomli
|
|
||||||
customtkinter
|
|
||||||
colorama
|
|
||||||
pypinyin
|
|
||||||
pillow
|
|
||||||
setuptools
|
|
||||||
]
|
|
||||||
);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pythonEnv
|
pythonPackages.python
|
||||||
pkgs.nb-cli
|
pythonPackages.venvShellHook
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = ''
|
postVenvCreation = ''
|
||||||
|
unset SOURCE_DATE_EPOCH
|
||||||
|
pip install -r requirements.txt
|
||||||
|
'';
|
||||||
|
|
||||||
|
postShellHook = ''
|
||||||
|
# allow pip to install wheels
|
||||||
|
unset SOURCE_DATE_EPOCH
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
import html
|
||||||
|
import re
|
||||||
|
import json
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Dict, ForwardRef, List, Optional, Union
|
from typing import Dict, ForwardRef, List, Optional, Union
|
||||||
|
|
||||||
@@ -71,6 +74,20 @@ class MessageRecv(Message):
|
|||||||
message_dict: MessageCQ序列化后的字典
|
message_dict: MessageCQ序列化后的字典
|
||||||
"""
|
"""
|
||||||
self.message_info = BaseMessageInfo.from_dict(message_dict.get('message_info', {}))
|
self.message_info = BaseMessageInfo.from_dict(message_dict.get('message_info', {}))
|
||||||
|
|
||||||
|
message_segment = message_dict.get('message_segment', {})
|
||||||
|
|
||||||
|
if message_segment.get('data','') == '[json]':
|
||||||
|
# 提取json消息中的展示信息
|
||||||
|
pattern = r'\[CQ:json,data=(?P<json_data>.+?)\]'
|
||||||
|
match = re.search(pattern, message_dict.get('raw_message',''))
|
||||||
|
raw_json = html.unescape(match.group('json_data'))
|
||||||
|
try:
|
||||||
|
json_message = json.loads(raw_json)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
json_message = {}
|
||||||
|
message_segment['data'] = json_message.get('prompt','')
|
||||||
|
|
||||||
self.message_segment = Seg.from_dict(message_dict.get('message_segment', {}))
|
self.message_segment = Seg.from_dict(message_dict.get('message_segment', {}))
|
||||||
self.raw_message = message_dict.get('raw_message')
|
self.raw_message = message_dict.get('raw_message')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user