From 9affc085170a1be2e9ae550f310798946c2fb2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Fri, 9 May 2025 03:29:03 +0900 Subject: [PATCH 1/6] add dev container config --- .devcontainer/devcontainer.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d291385 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "MaiBot-Napcat-Adapter-DevContainer", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Configure tool-specific properties. + "customizations" : { + "jetbrains" : { + "backend" : "PyCharm" + } + }, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} From 0b4471f6e9b37d2df8a0d87692d7e9787cdafd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Fri, 9 May 2025 03:31:45 +0900 Subject: [PATCH 2/6] update dev container config, add port forwarding --- .devcontainer/devcontainer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d291385..17703ed 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,9 @@ // "features": {}, // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], + "forwardPorts": [ + "8095:8095" + ], // Use 'postCreateCommand' to run commands after the container is created. // "postCreateCommand": "pip3 install --user -r requirements.txt", From bc11ee5ec7c7c2b1f80b2b810c4aa01eb2c82006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Thu, 8 May 2025 18:41:26 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitignore=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=A4=9A=E4=B8=AA=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E8=A7=84=E5=88=99=E4=BB=A5=E4=BC=98=E5=8C=96=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 269 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index a8b468a..903b535 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,270 @@ -**/__pycache__/ -.vscode -test + +log/ +logs/ +out/ + +.env +.env.* +.cursor + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class +llm_statistics.txt +mongodb +napcat +run_dev.bat +elua.confirmed +# C extensions +*.so +/results + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# PyPI configuration file +.pypirc + +# jieba +jieba.cache + +# .vscode +!.vscode/settings.json + +# direnv +/.direnv + +# JetBrains +.idea +*.iml +*.ipr + +# PyEnv +# If using PyEnv and configured to use a specific Python version locally +# a .local-version file will be created in the root of the project to specify the version. +.python-version + +OtherRes.txt + +/eula.confirmed +/privacy.confirmed + +logs + .ruff_cache -config.toml \ No newline at end of file + +.vscode + +/config/* +config/old/bot_config_20250405_212257.toml +temp/ + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk From a94beb4355b3b74dc26e27a8806463d7842ebee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Fri, 9 May 2025 03:50:25 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20devcontainer.json?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=20tmux=20=E5=92=8C=20GitHub=20CLI?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD=E6=94=AF=E6=8C=81=EF=BC=9B=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20.gitignore=EF=BC=8C=E6=B7=BB=E5=8A=A0=20config.toml?= =?UTF-8?q?=20=E5=BF=BD=E7=95=A5=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 11 +++++++++-- .gitignore | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 17703ed..4ba74cf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,14 @@ "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, + "features": { + "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { + "packages": [ + "tmux" + ] + }, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [ @@ -21,7 +28,7 @@ "jetbrains" : { "backend" : "PyCharm" } - }, + } // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" diff --git a/.gitignore b/.gitignore index 903b535..605eaf4 100644 --- a/.gitignore +++ b/.gitignore @@ -268,3 +268,5 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +config.toml From 60f53e93a0532c776ad082bb8309429be379bca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=A5=E6=B2=B3=E6=99=B4?= Date: Fri, 9 May 2025 13:37:28 +0900 Subject: [PATCH 5/6] add postCreateCommand in devcontainer.json --- .devcontainer/devcontainer.json | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4ba74cf..dbd0445 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,6 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python { "name": "MaiBot-Napcat-Adapter-DevContainer", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", - - // Features to add to the dev container. More info: https://containers.dev/features. "features": { "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { "packages": [ @@ -14,22 +9,13 @@ }, "ghcr.io/devcontainers/features/github-cli:1": {} }, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [ "8095:8095" ], - - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "pip3 install --user -r requirements.txt", - - // Configure tool-specific properties. + "postCreateCommand": "pip3 install --user -r requirements.txt", "customizations" : { "jetbrains" : { "backend" : "PyCharm" } } - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" } From 51dcb37ee41f799b81bd838986e92ea2ed6554bc Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Mon, 12 May 2025 23:16:47 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat=EF=BC=9A=E4=BF=AE=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=92=8Cat=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recv_handler.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/recv_handler.py b/src/recv_handler.py index 33f98b9..1b32126 100644 --- a/src/recv_handler.py +++ b/src/recv_handler.py @@ -404,7 +404,7 @@ class RecvHandler: self_info: dict = await get_self_info(self.server_connection) if self_info: return Seg( - type=RealMessageType.text, data=f"@{self_info.get('nickname')}(id:{self_info.get('user_id')})" + type=RealMessageType.text, data=f"@<{self_info.get('nickname')}:{self_info.get('user_id')}>" ) else: return None @@ -413,7 +413,7 @@ class RecvHandler: if member_info: return Seg( type=RealMessageType.text, - data=f"@{member_info.get('nickname')}(id:{member_info.get('user_id')})", + data=f"@<{member_info.get('nickname')}:{member_info.get('user_id')}>" ) else: return None @@ -442,12 +442,13 @@ class RecvHandler: seg_message: List[Seg] = [] if not sender_nickname: logger.warning("无法获取被引用的人的昵称,返回默认值") - seg_message.append(Seg(type="text", data="[回复 QQ用户(未知id):")) + seg_message.append(Seg(type="text", data="[回复 未知用户:")) seg_message += reply_message seg_message.append(Seg(type="text", data="],说:")) return seg_message else: - seg_message.append(Seg(type="text", data=f"[回复 {sender_nickname}({sender_id}):")) + # seg_message.append(Seg(type="text", data=f"[回复 {sender_nickname}({sender_id}):")) + seg_message.append(Seg(type="text", data=f"[回复<{sender_nickname}:{sender_id}>:")) seg_message += reply_message seg_message.append(Seg(type="text", data="],说:")) return seg_message @@ -580,7 +581,7 @@ class RecvHandler: """ seg_data: Seg = Seg( type="text", - data=f"{first_txt}{target_name}{second_txt}(这是一个类似摸摸头的友善行为,不是恶意行为,请不要作出攻击发言)", + data=f"{first_txt}{target_name}{second_txt}(这是QQ的一个功能,用于提及某人,但没那么明显)", ) return seg_data