mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
Merge branch 'main' into feature/add-more-fn
This commit is contained in:
commit
4e28e958db
17
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
17
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -1,8 +1,21 @@
|
||||
name: Bug 反馈
|
||||
title: "Bug: 出现异常"
|
||||
title: "Bug: "
|
||||
description: 提交 Bug 反馈以帮助我们改进代码
|
||||
labels: ["bug"]
|
||||
labels: [ "bug" ]
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: 提交前检查项
|
||||
description: 在提交问题之前,请确认以下事项:
|
||||
options:
|
||||
- label: 我已搜索相关的 issue,但没有找到类似的问题
|
||||
required: true
|
||||
- label: 我已更新到最新版本(包括但不限于真寻本体,插件以及相关依赖),问题仍然存在
|
||||
required: true
|
||||
- label: 我已仔细阅读文档,确认我的配置正确
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: env-os
|
||||
attributes:
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
9
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -1,7 +1,7 @@
|
||||
name: 功能建议
|
||||
title: "Feature: 功能描述"
|
||||
description: 提出关于项目新功能的想法
|
||||
labels: ["enhancement"]
|
||||
labels: [ "enhancement" ]
|
||||
body:
|
||||
- type: textarea
|
||||
id: problem
|
||||
@ -18,3 +18,10 @@ body:
|
||||
description: 请说明需要的功能或解决方法
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: 我有能力且愿意为这个功能贡献代码
|
||||
options:
|
||||
- label: 我有能力且愿意为这个功能贡献代码
|
||||
|
||||
94
.github/workflows/codeql.yml
vendored
Normal file
94
.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL Code Security Analysis"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '45 21 * * 2'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze (${{ matrix.language }})
|
||||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||||
# - https://gh.io/supported-runners-and-hardware-resources
|
||||
# - https://gh.io/using-larger-runners (GitHub.com only)
|
||||
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
||||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
||||
permissions:
|
||||
# required for all workflows
|
||||
security-events: write
|
||||
|
||||
# required to fetch internal or private CodeQL packs
|
||||
packages: read
|
||||
|
||||
# only required for workflows in private repositories
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- language: python
|
||||
build-mode: none
|
||||
- language: javascript-typescript
|
||||
build-mode: none
|
||||
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
|
||||
# Use `c-cpp` to analyze code written in C, C++ or both
|
||||
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
||||
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
||||
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
||||
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
||||
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
||||
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
build-mode: ${{ matrix.build-mode }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
# If the analyze step fails for one of the languages you are analyzing with
|
||||
# "We were unable to automatically build your code", modify the matrix above
|
||||
# to set the build mode to "manual" for that language. Then modify this step
|
||||
# to build your code.
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
- if: matrix.build-mode == 'manual'
|
||||
shell: bash
|
||||
run: |
|
||||
echo 'If you are using a "manual" build mode for one or more of the' \
|
||||
'languages you are analyzing, replace this with the commands to build' \
|
||||
'your code, for example:'
|
||||
echo ' make bootstrap'
|
||||
echo ' make release'
|
||||
exit 1
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
@ -72,6 +72,8 @@
|
||||
|
||||
<div align=center>
|
||||
|
||||
<img width="100%" src="https://starify.komoridevs.icu/api/starify?owner=HibiKier&repo=zhenxun_bot" alt="starify" />
|
||||
|
||||
<img src="https://api.star-history.com/svg?repos=HibiKier/zhenxun_bot&type=Timeline" alt="Star Trend" width="800" />
|
||||
|
||||
</div>
|
||||
|
||||
1304
poetry.lock
generated
1304
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -23,11 +23,11 @@ strenum = "^0.4.15"
|
||||
nonebot-plugin-session = "^0.2.3"
|
||||
ujson = "^5.9.0"
|
||||
nb-cli = "^1.3.0"
|
||||
nonebot2 = {extras = ["fastapi"], version = "^2.3.3"}
|
||||
nonebot2 = { extras = ["fastapi"], version = "^2.3.3" }
|
||||
pillow = "^10.0.0"
|
||||
retrying = "^1.3.4"
|
||||
aiofiles = "^23.2.1"
|
||||
nonebot-plugin-htmlrender = "^0.3.0"
|
||||
nonebot-plugin-htmlrender = ">=0.6.0,<1.0.0"
|
||||
pypinyin = "^0.51.0"
|
||||
beautifulsoup4 = "^4.12.3"
|
||||
lxml = "^5.1.0"
|
||||
@ -44,6 +44,7 @@ py-cpuinfo = "^9.0.0"
|
||||
nonebot-plugin-alconna = "^0.54.0"
|
||||
tenacity = "^9.0.0"
|
||||
nonebot-plugin-uninfo = ">0.4.1"
|
||||
nonebot-plugin-waiter = "^0.8.1"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
nonebug = "^0.4"
|
||||
@ -66,8 +67,8 @@ plugins = [
|
||||
plugin_dirs = ["zhenxun/services", "zhenxun/builtin_plugins", "zhenxun/plugins"]
|
||||
adapters = [
|
||||
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
|
||||
# { name = "DoDo", module_name = "nonebot.adapters.dodo" },
|
||||
# { name = "开黑啦", module_name = "nonebot.adapters.kaiheila" },
|
||||
# { name = "DoDo", module_name = "nonebot.adapters.dodo" },
|
||||
# { name = "开黑啦", module_name = "nonebot.adapters.kaiheila" },
|
||||
]
|
||||
|
||||
[tool.ruff]
|
||||
|
||||
@ -9,41 +9,41 @@ arclet-alconna==1.8.35 ; python_version >= "3.10" and python_version < "4.0"
|
||||
arrow==1.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
async-timeout==5.0.1 ; python_version >= "3.10" and python_version < "3.11.0"
|
||||
asyncpg==0.30.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
attrs==24.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
beautifulsoup4==4.12.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
attrs==25.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
beautifulsoup4==4.13.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
bilireq==0.2.3.post0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
binaryornot==0.4.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||
cashews==7.4.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
cattrs==23.2.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
certifi==2024.12.14 ; python_version >= "3.10" and python_version < "4.0"
|
||||
certifi==2025.1.31 ; python_version >= "3.10" and python_version < "4.0"
|
||||
cffi==1.17.1 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
|
||||
chardet==5.2.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
charset-normalizer==3.4.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
click==8.1.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||
cn2an==0.5.23 ; python_version >= "3.10" and python_version < "4.0"
|
||||
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and (platform_system == "Windows" or sys_platform == "win32")
|
||||
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
|
||||
cookiecutter==2.6.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
cryptography==44.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
dateparser==1.2.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
cryptography==44.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
dateparser==1.2.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
distlib==0.3.9 ; python_version >= "3.10" and python_version < "4.0"
|
||||
ecdsa==0.19.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
exceptiongroup==1.2.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
fastapi==0.115.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
fastapi==0.115.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||
feedparser==6.0.11 ; python_version >= "3.10" and python_version < "4.0"
|
||||
filelock==3.16.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
filelock==3.17.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
greenlet==3.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
grpcio==1.69.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
grpcio==1.70.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
h11==0.14.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
httpcore==0.16.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
httptools==0.6.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||
httpx==0.23.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
idna==3.10 ; python_version >= "3.10" and python_version < "4.0"
|
||||
imagehash==4.3.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
importlib-metadata==8.5.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
imagehash==4.3.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
importlib-metadata==8.6.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
iso8601==1.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
jinja2==3.1.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||
loguru==0.7.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
lxml==5.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
lxml==5.3.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
markdown-it-py==3.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
markdown==3.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||
markupsafe==3.0.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
@ -55,75 +55,75 @@ nepattern==0.7.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-adapter-onebot==2.4.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-alconna==0.54.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-apscheduler==0.5.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-htmlrender==0.3.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-htmlrender==0.6.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-session==0.2.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-uninfo==0.4.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-waiter==0.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-uninfo==0.6.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot-plugin-waiter==0.8.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot2==2.4.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
nonebot2[fastapi]==2.4.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
noneprompt==0.1.9 ; python_version >= "3.10" and python_version < "4.0"
|
||||
numpy==2.2.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
numpy==2.2.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pillow==10.4.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
platformdirs==4.3.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
playwright==1.49.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
playwright==1.50.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
proces==0.1.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||
prompt-toolkit==3.0.48 ; python_version >= "3.10" and python_version < "4.0"
|
||||
prompt-toolkit==3.0.50 ; python_version >= "3.10" and python_version < "4.0"
|
||||
propcache==0.2.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
protobuf==4.25.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||
protobuf==4.25.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
psutil==5.9.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||
py-cpuinfo==9.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pyasn1==0.6.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pycparser==2.22 ; python_version >= "3.10" and python_version < "4.0" and platform_python_implementation != "PyPy"
|
||||
pydantic-core==2.27.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pydantic==2.10.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pyee==12.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pydantic==2.10.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pyee==12.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pyfiglet==1.0.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pygments==2.19.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pygtrie==2.5.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pymdown-extensions==10.14 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pymdown-extensions==10.14.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pypika-tortoise==0.1.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pypinyin==0.51.0 ; python_version >= "3.10" and python_version < "4"
|
||||
pypinyin==0.51.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-dateutil==2.9.0.post0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-dotenv==1.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-jose[cryptography]==3.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-jose==3.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-markdown-math==0.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-multipart==0.0.9 ; python_version >= "3.10" and python_version < "4.0"
|
||||
python-slugify==8.0.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pytz==2024.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pytz==2025.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pywavelets==1.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
pyyaml==6.0.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
regex==2024.11.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
requests==2.32.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
retrying==1.3.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||
rfc3986[idna2008]==1.5.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
rfc3986==1.5.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
rich==13.9.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||
rsa==4.9 ; python_version >= "3.10" and python_version < "4"
|
||||
ruamel-yaml-clib==0.2.12 ; platform_python_implementation == "CPython" and python_version < "3.13" and python_version >= "3.10"
|
||||
rsa==4.9 ; python_version >= "3.10" and python_version < "4.0"
|
||||
ruamel-yaml-clib==0.2.12 ; python_version >= "3.10" and python_version < "3.13" and platform_python_implementation == "CPython"
|
||||
ruamel-yaml==0.18.10 ; python_version >= "3.10" and python_version < "4.0"
|
||||
scipy==1.15.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
scipy==1.15.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
sgmllib3k==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
six==1.17.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
sniffio==1.3.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
soupsieve==2.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||
starlette==0.41.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
starlette==0.45.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
strenum==0.4.15 ; python_version >= "3.10" and python_version < "4.0"
|
||||
tarina==0.6.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||
tenacity==9.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
text-unidecode==1.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
tomli==2.2.1 ; python_version >= "3.10" and python_version < "3.11"
|
||||
tomlkit==0.13.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
tortoise-orm[asyncpg]==0.20.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
tortoise-orm==0.20.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
types-python-dateutil==2.9.0.20241206 ; python_version >= "3.10" and python_version < "4.0"
|
||||
typing-extensions==4.12.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
tzdata==2024.2 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
|
||||
tzdata==2025.1 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
|
||||
tzlocal==5.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
ujson==5.10.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
urllib3==2.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
uvicorn[standard]==0.34.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
uvloop==0.21.0 ; (sys_platform != "win32" and sys_platform != "cygwin") and platform_python_implementation != "PyPy" and python_version >= "3.10" and python_version < "4.0"
|
||||
virtualenv==20.28.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
uvicorn==0.34.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
uvloop==0.21.0 ; python_version >= "3.10" and python_version < "4.0" and (sys_platform != "win32" and sys_platform != "cygwin") and platform_python_implementation != "PyPy"
|
||||
virtualenv==20.29.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
watchfiles==0.24.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
wcwidth==0.2.13 ; python_version >= "3.10" and python_version < "4.0"
|
||||
websockets==14.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||
websockets==14.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||
win32-setctime==1.2.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
|
||||
yarl==1.18.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||
zipp==3.21.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||
|
||||
@ -16,8 +16,10 @@ from tests.utils import _v11_group_message_event
|
||||
|
||||
|
||||
@pytest.mark.parametrize("package_api", ["jsd", "gh"])
|
||||
@pytest.mark.parametrize("is_commit", [True, False])
|
||||
async def test_add_plugin_basic(
|
||||
package_api: str,
|
||||
is_commit: bool,
|
||||
app: App,
|
||||
mocker: MockerFixture,
|
||||
mocked_api: MockRouter,
|
||||
@ -40,6 +42,12 @@ async def test_add_plugin_basic(
|
||||
if package_api != "gh":
|
||||
mocked_api["zhenxun_bot_plugins_tree"].respond(404)
|
||||
|
||||
if not is_commit:
|
||||
mocked_api["zhenxun_bot_plugins_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_commit_proxy"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit_proxy"].respond(404)
|
||||
|
||||
plugin_id = 1
|
||||
|
||||
async with app.test_matcher(_matcher) as ctx:
|
||||
@ -67,15 +75,22 @@ async def test_add_plugin_basic(
|
||||
result=None,
|
||||
bot=bot,
|
||||
)
|
||||
if is_commit:
|
||||
assert mocked_api["search_image_plugin_file_init_commit"].called
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
else:
|
||||
assert mocked_api["search_image_plugin_file_init"].called
|
||||
assert mocked_api["basic_plugins_no_commit"].called
|
||||
assert mocked_api["extra_plugins_no_commit"].called
|
||||
assert (mock_base_path / "plugins" / "search_image" / "__init__.py").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("package_api", ["jsd", "gh"])
|
||||
@pytest.mark.parametrize("is_commit", [True, False])
|
||||
async def test_add_plugin_basic_commit_version(
|
||||
package_api: str,
|
||||
is_commit: bool,
|
||||
app: App,
|
||||
mocker: MockerFixture,
|
||||
mocked_api: MockRouter,
|
||||
@ -98,6 +113,11 @@ async def test_add_plugin_basic_commit_version(
|
||||
if package_api != "gh":
|
||||
mocked_api["zhenxun_bot_plugins_tree_commit"].respond(404)
|
||||
|
||||
if not is_commit:
|
||||
mocked_api["zhenxun_bot_plugins_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_commit_proxy"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit_proxy"].respond(404)
|
||||
plugin_id = 3
|
||||
|
||||
async with app.test_matcher(_matcher) as ctx:
|
||||
@ -125,19 +145,25 @@ async def test_add_plugin_basic_commit_version(
|
||||
result=None,
|
||||
bot=bot,
|
||||
)
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
if package_api == "jsd":
|
||||
assert mocked_api["zhenxun_bot_plugins_metadata_commit"].called
|
||||
if package_api == "gh":
|
||||
assert mocked_api["zhenxun_bot_plugins_tree_commit"].called
|
||||
if is_commit:
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
else:
|
||||
assert mocked_api["basic_plugins_no_commit"].called
|
||||
assert mocked_api["extra_plugins_no_commit"].called
|
||||
assert mocked_api["bilibili_sub_plugin_file_init"].called
|
||||
assert (mock_base_path / "plugins" / "bilibili_sub" / "__init__.py").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("package_api", ["jsd", "gh"])
|
||||
@pytest.mark.parametrize("is_commit", [True, False])
|
||||
async def test_add_plugin_basic_is_not_dir(
|
||||
package_api: str,
|
||||
is_commit: bool,
|
||||
app: App,
|
||||
mocker: MockerFixture,
|
||||
mocked_api: MockRouter,
|
||||
@ -160,6 +186,12 @@ async def test_add_plugin_basic_is_not_dir(
|
||||
if package_api != "gh":
|
||||
mocked_api["zhenxun_bot_plugins_tree"].respond(404)
|
||||
|
||||
if not is_commit:
|
||||
mocked_api["zhenxun_bot_plugins_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_commit_proxy"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit_proxy"].respond(404)
|
||||
|
||||
plugin_id = 0
|
||||
|
||||
async with app.test_matcher(_matcher) as ctx:
|
||||
@ -187,15 +219,22 @@ async def test_add_plugin_basic_is_not_dir(
|
||||
result=None,
|
||||
bot=bot,
|
||||
)
|
||||
if is_commit:
|
||||
assert mocked_api["jitang_plugin_file_commit"].called
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
else:
|
||||
assert mocked_api["jitang_plugin_file"].called
|
||||
assert mocked_api["basic_plugins_no_commit"].called
|
||||
assert mocked_api["extra_plugins_no_commit"].called
|
||||
assert (mock_base_path / "plugins" / "alapi" / "jitang.py").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("package_api", ["jsd", "gh"])
|
||||
@pytest.mark.parametrize("is_commit", [True, False])
|
||||
async def test_add_plugin_extra(
|
||||
package_api: str,
|
||||
is_commit: bool,
|
||||
app: App,
|
||||
mocker: MockerFixture,
|
||||
mocked_api: MockRouter,
|
||||
@ -218,6 +257,14 @@ async def test_add_plugin_extra(
|
||||
if package_api != "gh":
|
||||
mocked_api["zhenxun_github_sub_tree"].respond(404)
|
||||
|
||||
if not is_commit:
|
||||
mocked_api["zhenxun_github_sub_commit"].respond(404)
|
||||
mocked_api["zhenxun_github_sub_commit_proxy"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_commit_proxy"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit"].respond(404)
|
||||
mocked_api["zhenxun_bot_plugins_index_commit_proxy"].respond(404)
|
||||
|
||||
plugin_id = 4
|
||||
|
||||
async with app.test_matcher(_matcher) as ctx:
|
||||
@ -245,9 +292,14 @@ async def test_add_plugin_extra(
|
||||
result=None,
|
||||
bot=bot,
|
||||
)
|
||||
if is_commit:
|
||||
assert mocked_api["github_sub_plugin_file_init_commit"].called
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
else:
|
||||
assert mocked_api["github_sub_plugin_file_init"].called
|
||||
assert mocked_api["basic_plugins_no_commit"].called
|
||||
assert mocked_api["extra_plugins_no_commit"].called
|
||||
assert (mock_base_path / "plugins" / "github_sub" / "__init__.py").is_file()
|
||||
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ async def test_plugin_store_fail(
|
||||
|
||||
init_mocked_api(mocked_api=mocked_api)
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/main/plugins.json",
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/b101fbc/plugins.json",
|
||||
name="basic_plugins",
|
||||
).respond(404)
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ async def test_update_all_plugin_basic_need_update(
|
||||
)
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
assert mocked_api["search_image_plugin_file_init"].called
|
||||
assert mocked_api["search_image_plugin_file_init_commit"].called
|
||||
assert (mock_base_path / "plugins" / "search_image" / "__init__.py").is_file()
|
||||
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ async def test_update_plugin_basic_need_update(
|
||||
)
|
||||
assert mocked_api["basic_plugins"].called
|
||||
assert mocked_api["extra_plugins"].called
|
||||
assert mocked_api["search_image_plugin_file_init"].called
|
||||
assert mocked_api["search_image_plugin_file_init_commit"].called
|
||||
assert (mock_base_path / "plugins" / "search_image" / "__init__.py").is_file()
|
||||
|
||||
|
||||
|
||||
@ -30,6 +30,10 @@ def init_mocked_api(mocked_api: MockRouter) -> None:
|
||||
"https://data.jsdelivr.com/v1/packages/gh/zhenxun-org/zhenxun_bot_plugins@b101fbc",
|
||||
name="zhenxun_bot_plugins_metadata_commit",
|
||||
).respond(json=get_response_json("zhenxun_bot_plugins_metadata.json"))
|
||||
mocked_api.get(
|
||||
"https://data.jsdelivr.com/v1/packages/gh/xuanerwa/zhenxun_github_sub@f524632f78d27f9893beebdf709e0e7885cd08f1",
|
||||
name="zhenxun_github_sub_metadata_commit",
|
||||
).respond(json=get_response_json("zhenxun_github_sub_metadata.json"))
|
||||
|
||||
# tree
|
||||
mocked_api.get(
|
||||
@ -44,6 +48,10 @@ def init_mocked_api(mocked_api: MockRouter) -> None:
|
||||
"https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/git/trees/b101fbc?recursive=1",
|
||||
name="zhenxun_bot_plugins_tree_commit",
|
||||
).respond(json=get_response_json("zhenxun_bot_plugins_tree.json"))
|
||||
mocked_api.get(
|
||||
"https://api.github.com/repos/xuanerwa/zhenxun_github_sub/git/trees/f524632f78d27f9893beebdf709e0e7885cd08f1?recursive=1",
|
||||
name="zhenxun_github_sub_tree_commit",
|
||||
).respond(json=get_response_json("zhenxun_github_sub_tree.json"))
|
||||
|
||||
mocked_api.head(
|
||||
"https://raw.githubusercontent.com/",
|
||||
@ -51,36 +59,89 @@ def init_mocked_api(mocked_api: MockRouter) -> None:
|
||||
).respond(200, text="")
|
||||
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/main/plugins.json",
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/b101fbc/plugins.json",
|
||||
name="basic_plugins",
|
||||
).respond(json=get_response_json("basic_plugins.json"))
|
||||
mocked_api.get(
|
||||
"https://cdn.jsdelivr.net/gh/zhenxun-org/zhenxun_bot_plugins@main/plugins.json",
|
||||
"https://cdn.jsdelivr.net/gh/zhenxun-org/zhenxun_bot_plugins@b101fbc/plugins.json",
|
||||
name="basic_plugins_jsdelivr",
|
||||
).respond(200, json=get_response_json("basic_plugins.json"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/main/plugins.json",
|
||||
name="basic_plugins_no_commit",
|
||||
).respond(json=get_response_json("basic_plugins.json"))
|
||||
mocked_api.get(
|
||||
"https://cdn.jsdelivr.net/gh/zhenxun-org/zhenxun_bot_plugins@main/plugins.json",
|
||||
name="basic_plugins_jsdelivr_no_commit",
|
||||
).respond(200, json=get_response_json("basic_plugins.json"))
|
||||
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins_index/index/plugins.json",
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins_index/2ed61284873c526802752b12a3fd3b5e1a59d948/plugins.json",
|
||||
name="extra_plugins",
|
||||
).respond(200, json=get_response_json("extra_plugins.json"))
|
||||
mocked_api.get(
|
||||
"https://cdn.jsdelivr.net/gh/zhenxun-org/zhenxun_bot_plugins_index@index/plugins.json",
|
||||
"https://cdn.jsdelivr.net/gh/zhenxun-org/zhenxun_bot_plugins_index@2ed61284873c526802752b12a3fd3b5e1a59d948/plugins.json",
|
||||
name="extra_plugins_jsdelivr",
|
||||
).respond(200, json=get_response_json("extra_plugins.json"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins_index/index/plugins.json",
|
||||
name="extra_plugins_no_commit",
|
||||
).respond(200, json=get_response_json("extra_plugins.json"))
|
||||
mocked_api.get(
|
||||
"https://cdn.jsdelivr.net/gh/zhenxun-org/zhenxun_bot_plugins_index@index/plugins.json",
|
||||
name="extra_plugins_jsdelivr_no_commit",
|
||||
).respond(200, json=get_response_json("extra_plugins.json"))
|
||||
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/main/plugins/search_image/__init__.py",
|
||||
name="search_image_plugin_file_init",
|
||||
).respond(content=get_content_bytes("search_image.py"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/b101fbc/plugins/search_image/__init__.py",
|
||||
name="search_image_plugin_file_init_commit",
|
||||
).respond(content=get_content_bytes("search_image.py"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/main/plugins/alapi/jitang.py",
|
||||
name="jitang_plugin_file",
|
||||
).respond(content=get_content_bytes("jitang.py"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/b101fbc/plugins/alapi/jitang.py",
|
||||
name="jitang_plugin_file_commit",
|
||||
).respond(content=get_content_bytes("jitang.py"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/xuanerwa/zhenxun_github_sub/main/github_sub/__init__.py",
|
||||
name="github_sub_plugin_file_init",
|
||||
).respond(content=get_content_bytes("github_sub.py"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/xuanerwa/zhenxun_github_sub/f524632f78d27f9893beebdf709e0e7885cd08f1/github_sub/__init__.py",
|
||||
name="github_sub_plugin_file_init_commit",
|
||||
).respond(content=get_content_bytes("github_sub.py"))
|
||||
mocked_api.get(
|
||||
"https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot_plugins/b101fbc/plugins/bilibili_sub/__init__.py",
|
||||
name="bilibili_sub_plugin_file_init",
|
||||
).respond(content=get_content_bytes("bilibili_sub.py"))
|
||||
|
||||
mocked_api.get(
|
||||
"https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/commits/main",
|
||||
name="zhenxun_bot_plugins_commit",
|
||||
).respond(json=get_response_json("zhenxun_bot_plugins_commit.json"))
|
||||
mocked_api.get(
|
||||
"https://git-api.zhenxun.org/repos/zhenxun-org/zhenxun_bot_plugins/commits/main",
|
||||
name="zhenxun_bot_plugins_commit_proxy",
|
||||
).respond(json=get_response_json("zhenxun_bot_plugins_commit.json"))
|
||||
mocked_api.get(
|
||||
"https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/commits/index",
|
||||
name="zhenxun_bot_plugins_index_commit",
|
||||
).respond(json=get_response_json("zhenxun_bot_plugins_index_commit.json"))
|
||||
mocked_api.get(
|
||||
"https://git-api.zhenxun.org/repos/zhenxun-org/zhenxun_bot_plugins_index/commits/index",
|
||||
name="zhenxun_bot_plugins_index_commit_proxy",
|
||||
).respond(json=get_response_json("zhenxun_bot_plugins_index_commit.json"))
|
||||
mocked_api.get(
|
||||
"https://api.github.com/repos/xuanerwa/zhenxun_github_sub/commits/main",
|
||||
name="zhenxun_github_sub_commit",
|
||||
).respond(json=get_response_json("zhenxun_github_sub_commit.json"))
|
||||
mocked_api.get(
|
||||
"https://git-api.zhenxun.org/repos/xuanerwa/zhenxun_github_sub/commits/main",
|
||||
name="zhenxun_github_sub_commit_proxy",
|
||||
).respond(json=get_response_json("zhenxun_github_sub_commit.json"))
|
||||
|
||||
101
tests/response/plugin_store/zhenxun_bot_plugins_commit.json
Normal file
101
tests/response/plugin_store/zhenxun_bot_plugins_commit.json
Normal file
@ -0,0 +1,101 @@
|
||||
{
|
||||
"sha": "b101fbc",
|
||||
"node_id": "C_kwDOMndPGNoAKGIxMDFmYmNlODg4NjA4ZTJiYmU1YjVmZDI3OWUxNDY1MTY4ODEyYzc",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "xuaner",
|
||||
"email": "xuaner_wa@qq.com",
|
||||
"date": "2024-09-20T12:08:27Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "xuaner",
|
||||
"email": "xuaner_wa@qq.com",
|
||||
"date": "2024-09-20T12:08:27Z"
|
||||
},
|
||||
"message": "🐛修复B站订阅bug",
|
||||
"tree": {
|
||||
"sha": "0566306219a434f7122798647498faef692c1879",
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/git/trees/0566306219a434f7122798647498faef692c1879"
|
||||
},
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/git/commits/b101fbce888608e2bbe5b5fd279e1465168812c7",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": false,
|
||||
"reason": "unsigned",
|
||||
"signature": null,
|
||||
"payload": null,
|
||||
"verified_at": null
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/commits/b101fbce888608e2bbe5b5fd279e1465168812c7",
|
||||
"html_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins/commit/b101fbce888608e2bbe5b5fd279e1465168812c7",
|
||||
"comments_url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/commits/b101fbce888608e2bbe5b5fd279e1465168812c7/comments",
|
||||
"author": {
|
||||
"login": "xuanerwa",
|
||||
"id": 58063798,
|
||||
"node_id": "MDQ6VXNlcjU4MDYzNzk4",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/58063798?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/xuanerwa",
|
||||
"html_url": "https://github.com/xuanerwa",
|
||||
"followers_url": "https://api.github.com/users/xuanerwa/followers",
|
||||
"following_url": "https://api.github.com/users/xuanerwa/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/xuanerwa/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/xuanerwa/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/xuanerwa/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/xuanerwa/orgs",
|
||||
"repos_url": "https://api.github.com/users/xuanerwa/repos",
|
||||
"events_url": "https://api.github.com/users/xuanerwa/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/xuanerwa/received_events",
|
||||
"type": "User",
|
||||
"user_view_type": "public",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "xuanerwa",
|
||||
"id": 58063798,
|
||||
"node_id": "MDQ6VXNlcjU4MDYzNzk4",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/58063798?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/xuanerwa",
|
||||
"html_url": "https://github.com/xuanerwa",
|
||||
"followers_url": "https://api.github.com/users/xuanerwa/followers",
|
||||
"following_url": "https://api.github.com/users/xuanerwa/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/xuanerwa/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/xuanerwa/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/xuanerwa/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/xuanerwa/orgs",
|
||||
"repos_url": "https://api.github.com/users/xuanerwa/repos",
|
||||
"events_url": "https://api.github.com/users/xuanerwa/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/xuanerwa/received_events",
|
||||
"type": "User",
|
||||
"user_view_type": "public",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "a545dfa0c4e149595f7ddd50dc34c55513738fb9",
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/commits/a545dfa0c4e149595f7ddd50dc34c55513738fb9",
|
||||
"html_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins/commit/a545dfa0c4e149595f7ddd50dc34c55513738fb9"
|
||||
}
|
||||
],
|
||||
"stats": {
|
||||
"total": 4,
|
||||
"additions": 2,
|
||||
"deletions": 2
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"sha": "0fbc9695db04c56174e3bff933f670d8d2df2abc",
|
||||
"filename": "plugins/bilibili_sub/data_source.py",
|
||||
"status": "modified",
|
||||
"additions": 2,
|
||||
"deletions": 2,
|
||||
"changes": 4,
|
||||
"blob_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins/blob/b101fbce888608e2bbe5b5fd279e1465168812c7/plugins%2Fbilibili_sub%2Fdata_source.py",
|
||||
"raw_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins/raw/b101fbce888608e2bbe5b5fd279e1465168812c7/plugins%2Fbilibili_sub%2Fdata_source.py",
|
||||
"contents_url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins/contents/plugins%2Fbilibili_sub%2Fdata_source.py?ref=b101fbce888608e2bbe5b5fd279e1465168812c7",
|
||||
"patch": "@@ -271,14 +271,14 @@ async def _get_live_status(id_: int) -> list:\n sub = await BilibiliSub.get_or_none(sub_id=id_)\n msg_list = []\n if sub.live_status != live_status:\n+ await BilibiliSub.sub_handle(id_, live_status=live_status)\n image = None\n try:\n image_bytes = await fetch_image_bytes(cover)\n image = BuildImage(background = image_bytes)\n except Exception as e:\n logger.error(f\"图片构造失败,错误信息:{e}\")\n if sub.live_status in [0, 2] and live_status == 1 and image:\n- await BilibiliSub.sub_handle(id_, live_status=live_status)\n msg_list = [\n image,\n \"\\n\",\n@@ -322,7 +322,7 @@ async def _get_up_status(id_: int) -> list:\n video = video_info[\"list\"][\"vlist\"][0]\n latest_video_created = video[\"created\"]\n msg_list = []\n- if dynamic_img:\n+ if dynamic_img and _user.dynamic_upload_time < dynamic_upload_time:\n await BilibiliSub.sub_handle(id_, dynamic_upload_time=dynamic_upload_time)\n msg_list = [f\"{uname} 发布了动态!📢\\n\", dynamic_img, f\"\\n查看详情:{link}\"]\n if ("
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
{
|
||||
"sha": "2ed61284873c526802752b12a3fd3b5e1a59d948",
|
||||
"node_id": "C_kwDOGK5Du9oAKDJlZDYxMjg0ODczYzUyNjgwMjc1MmIxMmEzZmQzYjVlMWE1OWQ5NDg",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "zhenxunflow[bot]",
|
||||
"email": "179375394+zhenxunflow[bot]@users.noreply.github.com",
|
||||
"date": "2025-01-26T09:04:55Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "GitHub",
|
||||
"email": "noreply@github.com",
|
||||
"date": "2025-01-26T09:04:55Z"
|
||||
},
|
||||
"message": ":beers: publish plugin AI全家桶 (#235) (#236)\n\nCo-authored-by: molanp <molanp@users.noreply.github.com>",
|
||||
"tree": {
|
||||
"sha": "64ea463e084b6ab0def0322c6ad53799054ec9b3",
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/git/trees/64ea463e084b6ab0def0322c6ad53799054ec9b3"
|
||||
},
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/git/commits/2ed61284873c526802752b12a3fd3b5e1a59d948",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": true,
|
||||
"reason": "valid",
|
||||
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJnlfq3CRC1aQ7uu5UhlAAA+n0QADPVjQQIHFlNcTEgdq3LGQ1X\nm8+H5N07E5JD+83LdyU9/YOvqY/WURwFsQ0T4+23icUWEOD4LB5qZIdVJBYHseto\nbJNmYd1kZxpvsONoiK/2Uk6JoeVnEQIR+dTbB0wBlbL0lRt1WtTXHpLQbFXuXn3q\nJh4SdSj283UZ6D2sBADblPZ7DqaTmLlpgwrTPx0OH5wIhcuORkzOl6x0DabcVAYu\nu5zHSKM9c7g+jEmrqRuVy+ZlZMDPN4S3gDNzEhoTn4tn+KNzSIja4n7ZMRD+1a5X\nMIP3aXcVBqCyuYc6DU76IvjlaL/MjnlPwfOtx1zu+pNxZKNaSpojtqopp3blfk0E\n8s8lD9utDgUaUrdPWgpiMDjj+oNMye91CGomNDfv0fNGUlBGT6r48qaq1z8BwAAR\nzgDsF13kDuKTTkT/6T8CdgCpJtwvxMptUr2XFRtn4xwf/gJdqrbEc4fHTOSHqxzh\ncDfXuP+Sorla4oJ0duygTsulpr/zguX8RJWJml35VjERw54ARAVvhZn19G9qQVJo\n2QIp+xtyTjkM3yTeN4UDXFt4lDuxz3+l1MBduj+CHn+WTgxyJUpX2TA1GVfni9xT\npOMOtzuDQfDIxTNB6hFjSWATb1/E5ys1lfK09n+dRhmvC/Be+b5M4WlyX3cqy/za\ns0XxuZ+CHzLfHaPxFUem\n=VYpl\n-----END PGP SIGNATURE-----\n",
|
||||
"payload": "tree 64ea463e084b6ab0def0322c6ad53799054ec9b3\nparent 5df26081d40e3000a7beedb73954d4df397c93fa\nauthor zhenxunflow[bot] <179375394+zhenxunflow[bot]@users.noreply.github.com> 1737882295 +0800\ncommitter GitHub <noreply@github.com> 1737882295 +0800\n\n:beers: publish plugin AI全家桶 (#235) (#236)\n\nCo-authored-by: molanp <molanp@users.noreply.github.com>",
|
||||
"verified_at": "2025-01-26T09:04:58Z"
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/commits/2ed61284873c526802752b12a3fd3b5e1a59d948",
|
||||
"html_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins_index/commit/2ed61284873c526802752b12a3fd3b5e1a59d948",
|
||||
"comments_url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/commits/2ed61284873c526802752b12a3fd3b5e1a59d948/comments",
|
||||
"author": {
|
||||
"login": "zhenxunflow[bot]",
|
||||
"id": 179375394,
|
||||
"node_id": "BOT_kgDOCrENIg",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/in/978723?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/zhenxunflow%5Bbot%5D",
|
||||
"html_url": "https://github.com/apps/zhenxunflow",
|
||||
"followers_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/followers",
|
||||
"following_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/orgs",
|
||||
"repos_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/repos",
|
||||
"events_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/zhenxunflow%5Bbot%5D/received_events",
|
||||
"type": "Bot",
|
||||
"user_view_type": "public",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "web-flow",
|
||||
"id": 19864447,
|
||||
"node_id": "MDQ6VXNlcjE5ODY0NDQ3",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/web-flow",
|
||||
"html_url": "https://github.com/web-flow",
|
||||
"followers_url": "https://api.github.com/users/web-flow/followers",
|
||||
"following_url": "https://api.github.com/users/web-flow/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/web-flow/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/web-flow/orgs",
|
||||
"repos_url": "https://api.github.com/users/web-flow/repos",
|
||||
"events_url": "https://api.github.com/users/web-flow/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/web-flow/received_events",
|
||||
"type": "User",
|
||||
"user_view_type": "public",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "5df26081d40e3000a7beedb73954d4df397c93fa",
|
||||
"url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/commits/5df26081d40e3000a7beedb73954d4df397c93fa",
|
||||
"html_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins_index/commit/5df26081d40e3000a7beedb73954d4df397c93fa"
|
||||
}
|
||||
],
|
||||
"stats": {
|
||||
"total": 11,
|
||||
"additions": 11,
|
||||
"deletions": 0
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"sha": "3d98392c25d38f5d375b830aed6e2298e47e5601",
|
||||
"filename": "plugins.json",
|
||||
"status": "modified",
|
||||
"additions": 11,
|
||||
"deletions": 0,
|
||||
"changes": 11,
|
||||
"blob_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins_index/blob/2ed61284873c526802752b12a3fd3b5e1a59d948/plugins.json",
|
||||
"raw_url": "https://github.com/zhenxun-org/zhenxun_bot_plugins_index/raw/2ed61284873c526802752b12a3fd3b5e1a59d948/plugins.json",
|
||||
"contents_url": "https://api.github.com/repos/zhenxun-org/zhenxun_bot_plugins_index/contents/plugins.json?ref=2ed61284873c526802752b12a3fd3b5e1a59d948",
|
||||
"patch": "@@ -53,5 +53,16 @@\n \"plugin_type\": \"NORMAL\",\n \"is_dir\": true,\n \"github_url\": \"https://github.com/PackageInstaller/zhenxun_plugin_draw_painting/tree/master\"\n+ },\n+ \"AI全家桶\": {\n+ \"module\": \"zhipu_toolkit\",\n+ \"module_path\": \"zhipu_toolkit\",\n+ \"description\": \"AI全家桶,一次安装,到处使用,省时省力省心\",\n+ \"usage\": \"AI全家桶,一次安装,到处使用,省时省力省心\\n usage:\\n 生成图片 <prompt>\\n 生成视频 <prompt>\\n 清理我的会话: 用于清理你与AI的聊天记录\\n 或者与机器人聊天,\\n 例如;\\n @Bot抱抱\\n 小真寻老婆\",\n+ \"author\": \"molanp\",\n+ \"version\": \"0.1\",\n+ \"plugin_type\": \"NORMAL\",\n+ \"is_dir\": true,\n+ \"github_url\": \"https://github.com/molanp/zhenxun_plugin_zhipu_toolkit\"\n }\n }"
|
||||
}
|
||||
]
|
||||
}
|
||||
101
tests/response/plugin_store/zhenxun_github_sub_commit.json
Normal file
101
tests/response/plugin_store/zhenxun_github_sub_commit.json
Normal file
@ -0,0 +1,101 @@
|
||||
{
|
||||
"sha": "f524632f78d27f9893beebdf709e0e7885cd08f1",
|
||||
"node_id": "C_kwDOJAjBPdoAKGY1MjQ2MzJmNzhkMjdmOTg5M2JlZWJkZjcwOWUwZTc4ODVjZDA4ZjE",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "xuaner",
|
||||
"email": "xuaner_wa@qq.com",
|
||||
"date": "2024-11-18T18:17:15Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "xuaner",
|
||||
"email": "xuaner_wa@qq.com",
|
||||
"date": "2024-11-18T18:17:15Z"
|
||||
},
|
||||
"message": "fix bug",
|
||||
"tree": {
|
||||
"sha": "b6b1b4f06cc869b9f38d7b51bdca3a2c575255e4",
|
||||
"url": "https://api.github.com/repos/xuanerwa/zhenxun_github_sub/git/trees/b6b1b4f06cc869b9f38d7b51bdca3a2c575255e4"
|
||||
},
|
||||
"url": "https://api.github.com/repos/xuanerwa/zhenxun_github_sub/git/commits/f524632f78d27f9893beebdf709e0e7885cd08f1",
|
||||
"comment_count": 0,
|
||||
"verification": {
|
||||
"verified": false,
|
||||
"reason": "unsigned",
|
||||
"signature": null,
|
||||
"payload": null,
|
||||
"verified_at": null
|
||||
}
|
||||
},
|
||||
"url": "https://api.github.com/repos/xuanerwa/zhenxun_github_sub/commits/f524632f78d27f9893beebdf709e0e7885cd08f1",
|
||||
"html_url": "https://github.com/xuanerwa/zhenxun_github_sub/commit/f524632f78d27f9893beebdf709e0e7885cd08f1",
|
||||
"comments_url": "https://api.github.com/repos/xuanerwa/zhenxun_github_sub/commits/f524632f78d27f9893beebdf709e0e7885cd08f1/comments",
|
||||
"author": {
|
||||
"login": "xuanerwa",
|
||||
"id": 58063798,
|
||||
"node_id": "MDQ6VXNlcjU4MDYzNzk4",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/58063798?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/xuanerwa",
|
||||
"html_url": "https://github.com/xuanerwa",
|
||||
"followers_url": "https://api.github.com/users/xuanerwa/followers",
|
||||
"following_url": "https://api.github.com/users/xuanerwa/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/xuanerwa/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/xuanerwa/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/xuanerwa/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/xuanerwa/orgs",
|
||||
"repos_url": "https://api.github.com/users/xuanerwa/repos",
|
||||
"events_url": "https://api.github.com/users/xuanerwa/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/xuanerwa/received_events",
|
||||
"type": "User",
|
||||
"user_view_type": "public",
|
||||
"site_admin": false
|
||||
},
|
||||
"committer": {
|
||||
"login": "xuanerwa",
|
||||
"id": 58063798,
|
||||
"node_id": "MDQ6VXNlcjU4MDYzNzk4",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/58063798?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/xuanerwa",
|
||||
"html_url": "https://github.com/xuanerwa",
|
||||
"followers_url": "https://api.github.com/users/xuanerwa/followers",
|
||||
"following_url": "https://api.github.com/users/xuanerwa/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/xuanerwa/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/xuanerwa/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/xuanerwa/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/xuanerwa/orgs",
|
||||
"repos_url": "https://api.github.com/users/xuanerwa/repos",
|
||||
"events_url": "https://api.github.com/users/xuanerwa/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/xuanerwa/received_events",
|
||||
"type": "User",
|
||||
"user_view_type": "public",
|
||||
"site_admin": false
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "91e5e2c792e79193830441d555769aa54acd2d15",
|
||||
"url": "https://api.github.com/repos/xuanerwa/zhenxun_github_sub/commits/91e5e2c792e79193830441d555769aa54acd2d15",
|
||||
"html_url": "https://github.com/xuanerwa/zhenxun_github_sub/commit/91e5e2c792e79193830441d555769aa54acd2d15"
|
||||
}
|
||||
],
|
||||
"stats": {
|
||||
"total": 2,
|
||||
"additions": 1,
|
||||
"deletions": 1
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"sha": "764a5f7b81554c4c10d29486ea5d9105e505cec3",
|
||||
"filename": "github_sub/__init__.py",
|
||||
"status": "modified",
|
||||
"additions": 1,
|
||||
"deletions": 1,
|
||||
"changes": 2,
|
||||
"blob_url": "https://github.com/xuanerwa/zhenxun_github_sub/blob/f524632f78d27f9893beebdf709e0e7885cd08f1/github_sub%2F__init__.py",
|
||||
"raw_url": "https://github.com/xuanerwa/zhenxun_github_sub/raw/f524632f78d27f9893beebdf709e0e7885cd08f1/github_sub%2F__init__.py",
|
||||
"contents_url": "https://api.github.com/repos/xuanerwa/zhenxun_github_sub/contents/github_sub%2F__init__.py?ref=f524632f78d27f9893beebdf709e0e7885cd08f1",
|
||||
"patch": "@@ -168,7 +168,7 @@ async def _(session: EventSession):\n # 推送\n @scheduler.scheduled_job(\n \"interval\",\n- seconds=base_config.get(\"CHECK_API_TIME\") if base_config.get(\"CHECK_TIME\") else 30,\n+ seconds=base_config.get(\"CHECK_API_TIME\") if base_config.get(\"CHECK_API_TIME\") else 30,\n )\n async def _():\n bots = nonebot.get_bots()"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -48,7 +48,11 @@ async def _(matcher: Matcher, message: UniMsg, session: EventSession):
|
||||
return
|
||||
if text := message.extract_plain_text().strip():
|
||||
if plugin := await PluginInfo.get_or_none(
|
||||
name=text, load_status=True, plugin_type=PluginType.NORMAL
|
||||
name=text,
|
||||
load_status=True,
|
||||
plugin_type=PluginType.NORMAL,
|
||||
block_type__isnull=True,
|
||||
status=True,
|
||||
):
|
||||
image = None
|
||||
if _path.exists():
|
||||
|
||||
@ -15,6 +15,7 @@ from zhenxun.models.group_console import GroupConsole
|
||||
from zhenxun.models.level_user import LevelUser
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
from zhenxun.models.plugin_limit import PluginLimit
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
from zhenxun.models.user_console import UserConsole
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import (
|
||||
@ -210,7 +211,9 @@ class AuthChecker:
|
||||
return False
|
||||
if plugin.plugin_type == PluginType.DEPENDANT:
|
||||
return False
|
||||
return plugin.module != "ai" if self._flmt_s.check(sid) else False
|
||||
if plugin.ignore_prompt:
|
||||
return False
|
||||
return self._flmt_s.check(sid)
|
||||
|
||||
async def auth(
|
||||
self,
|
||||
@ -358,14 +361,28 @@ class AuthChecker:
|
||||
group_id = channel_id
|
||||
channel_id = None
|
||||
if user_id := session.id1:
|
||||
is_poke = isinstance(event, PokeNotifyEvent)
|
||||
if plugin.impression > 0:
|
||||
sign_user = await SignUser.get_user(user_id)
|
||||
if float(sign_user.impression) < plugin.impression:
|
||||
if self.is_send_limit_message(plugin, user_id):
|
||||
self._flmt_s.start_cd(user_id)
|
||||
await MessageUtils.build_message(
|
||||
f"好感度不足哦,当前功能需要好感度: {plugin.impression},"
|
||||
"请继续签到提升好感度吧!"
|
||||
).send(reply_to=True)
|
||||
logger.debug(
|
||||
f"{plugin.name}({plugin.module}) 用户好感度不足...",
|
||||
"AuthChecker",
|
||||
session=session,
|
||||
)
|
||||
raise IgnoredException("好感度不足...")
|
||||
if group_id:
|
||||
sid = group_id or user_id
|
||||
if await GroupConsole.is_superuser_block_plugin(
|
||||
group_id, plugin.module
|
||||
):
|
||||
"""超级用户群组插件状态"""
|
||||
if self.is_send_limit_message(plugin, sid) and not is_poke:
|
||||
if self.is_send_limit_message(plugin, sid):
|
||||
self._flmt_s.start_cd(group_id or user_id)
|
||||
await MessageUtils.build_message(
|
||||
"超级管理员禁用了该群此功能..."
|
||||
@ -378,7 +395,7 @@ class AuthChecker:
|
||||
raise IgnoredException("超级管理员禁用了该群此功能...")
|
||||
if await GroupConsole.is_normal_block_plugin(group_id, plugin.module):
|
||||
"""群组插件状态"""
|
||||
if self.is_send_limit_message(plugin, sid) and not is_poke:
|
||||
if self.is_send_limit_message(plugin, sid):
|
||||
self._flmt_s.start_cd(group_id or user_id)
|
||||
await MessageUtils.build_message("该群未开启此功能...").send(
|
||||
reply_to=True
|
||||
@ -392,7 +409,7 @@ class AuthChecker:
|
||||
if plugin.block_type == BlockType.GROUP:
|
||||
"""全局群组禁用"""
|
||||
try:
|
||||
if self.is_send_limit_message(plugin, sid) and not is_poke:
|
||||
if self.is_send_limit_message(plugin, sid):
|
||||
self._flmt_c.start_cd(group_id)
|
||||
await MessageUtils.build_message(
|
||||
"该功能在群组中已被禁用..."
|
||||
@ -415,7 +432,7 @@ class AuthChecker:
|
||||
if plugin.block_type == BlockType.PRIVATE:
|
||||
"""全局私聊禁用"""
|
||||
try:
|
||||
if self.is_send_limit_message(plugin, sid) and not is_poke:
|
||||
if self.is_send_limit_message(plugin, sid):
|
||||
self._flmt_c.start_cd(user_id)
|
||||
await MessageUtils.build_message(
|
||||
"该功能在私聊中已被禁用..."
|
||||
@ -442,7 +459,7 @@ class AuthChecker:
|
||||
"AuthChecker",
|
||||
session=session,
|
||||
)
|
||||
if self.is_send_limit_message(plugin, sid) and not is_poke:
|
||||
if self.is_send_limit_message(plugin, sid):
|
||||
self._flmt_s.start_cd(group_id or user_id)
|
||||
await MessageUtils.build_message("全局未开启此功能...").send()
|
||||
raise IgnoredException("全局未开启此功能...")
|
||||
|
||||
@ -75,6 +75,7 @@ async def _handle_setting(
|
||||
is_show=extra_data.is_show,
|
||||
ignore_prompt=extra_data.ignore_prompt,
|
||||
parent=(plugin.parent_plugin.module_name if plugin.parent_plugin else None),
|
||||
impression=setting.impression,
|
||||
)
|
||||
)
|
||||
if extra_data.limits:
|
||||
@ -123,7 +124,6 @@ async def _():
|
||||
"admin_level",
|
||||
"plugin_type",
|
||||
"is_show",
|
||||
"ignore_prompt",
|
||||
]
|
||||
)
|
||||
update_list.append(plugin)
|
||||
|
||||
@ -80,12 +80,17 @@ class ShopManage:
|
||||
返回:
|
||||
dict: 插件信息数据
|
||||
"""
|
||||
default_github_url = await GithubUtils.parse_github_url(
|
||||
DEFAULT_GITHUB_URL
|
||||
).get_raw_download_urls("plugins.json")
|
||||
extra_github_url = await GithubUtils.parse_github_url(
|
||||
EXTRA_GITHUB_URL
|
||||
).get_raw_download_urls("plugins.json")
|
||||
default_github_repo = GithubUtils.parse_github_url(DEFAULT_GITHUB_URL)
|
||||
extra_github_repo = GithubUtils.parse_github_url(EXTRA_GITHUB_URL)
|
||||
for repo_info in [default_github_repo, extra_github_repo]:
|
||||
if await repo_info.update_repo_commit():
|
||||
logger.info(f"获取最新提交: {repo_info.branch}", "插件管理")
|
||||
else:
|
||||
logger.warning(f"获取最新提交失败: {repo_info}", "插件管理")
|
||||
default_github_url = await default_github_repo.get_raw_download_urls(
|
||||
"plugins.json"
|
||||
)
|
||||
extra_github_url = await extra_github_repo.get_raw_download_urls("plugins.json")
|
||||
res = await AsyncHttpx.get(default_github_url)
|
||||
res2 = await AsyncHttpx.get(extra_github_url)
|
||||
|
||||
@ -218,6 +223,10 @@ class ShopManage:
|
||||
files: list[str]
|
||||
repo_api: RepoAPI
|
||||
repo_info = GithubUtils.parse_github_url(github_url)
|
||||
if await repo_info.update_repo_commit():
|
||||
logger.info(f"获取最新提交: {repo_info.branch}", "插件管理")
|
||||
else:
|
||||
logger.warning(f"获取最新提交失败: {repo_info}", "插件管理")
|
||||
logger.debug(f"成功获取仓库信息: {repo_info}", "插件管理")
|
||||
for repo_api in GithubUtils.iter_api_strategies():
|
||||
try:
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
import random
|
||||
import time
|
||||
|
||||
from nonebot import on_message, on_request
|
||||
@ -40,7 +42,15 @@ __plugin_meta__ = PluginMetadata(
|
||||
help="是否自动同意好友添加",
|
||||
type=bool,
|
||||
default_value=False,
|
||||
)
|
||||
),
|
||||
RegisterConfig(
|
||||
module="invite_manager",
|
||||
key="AUTO_ADD_GROUP",
|
||||
value=False,
|
||||
help="是否自动同意邀请入群",
|
||||
type=bool,
|
||||
default_value=False,
|
||||
),
|
||||
],
|
||||
).to_dict(),
|
||||
)
|
||||
@ -81,6 +91,7 @@ async def _(bot: v12Bot | v11Bot, event: FriendRequestEvent, session: EventSessi
|
||||
"好友请求",
|
||||
target=event.user_id,
|
||||
)
|
||||
await asyncio.sleep(random.randint(1, 10))
|
||||
await bot.set_friend_add_request(flag=event.flag, approve=True)
|
||||
await FriendUser.create(
|
||||
user_id=str(user["user_id"]), user_name=user["nickname"]
|
||||
@ -104,7 +115,7 @@ async def _(bot: v12Bot | v11Bot, event: FriendRequestEvent, session: EventSessi
|
||||
await PlatformUtils.send_superuser(
|
||||
bot,
|
||||
f"*****一份好友申请*****\n"
|
||||
f"ID: {f.id}"
|
||||
f"ID: {f.id}\n"
|
||||
f"昵称:{nickname}({event.user_id})\n"
|
||||
f"自动同意:{'√' if base_config.get('AUTO_ADD_FRIEND') else '×'}\n"
|
||||
f"日期:{str(datetime.now()).split('.')[0]}\n"
|
||||
@ -118,10 +129,10 @@ async def _(bot: v12Bot | v11Bot, event: FriendRequestEvent, session: EventSessi
|
||||
async def _(bot: v12Bot | v11Bot, event: GroupRequestEvent, session: EventSession):
|
||||
if event.sub_type != "invite":
|
||||
return
|
||||
if str(event.user_id) in bot.config.superusers:
|
||||
if str(event.user_id) in bot.config.superusers or base_config.get("AUTO_ADD_GROUP"):
|
||||
try:
|
||||
logger.debug(
|
||||
"超级用户自动同意加入群聊",
|
||||
"超级用户自动同意加入群聊或开启自动同意入群",
|
||||
"群聊请求",
|
||||
session=event.user_id,
|
||||
target=event.group_id,
|
||||
@ -154,12 +165,42 @@ async def _(bot: v12Bot | v11Bot, event: GroupRequestEvent, session: EventSessio
|
||||
)
|
||||
except ActionFailed as e:
|
||||
logger.error(
|
||||
"超级用户自动同意加入群聊发生错误",
|
||||
"超超级用户自动同意加入群聊或开启自动同意入群,加入群组发生错误",
|
||||
"群聊请求",
|
||||
session=event.user_id,
|
||||
target=event.group_id,
|
||||
e=e,
|
||||
)
|
||||
if str(event.user_id) not in bot.config.superusers and base_config.get(
|
||||
"AUTO_ADD_GROUP"
|
||||
):
|
||||
# 非超级用户邀请自动加入群组
|
||||
nickname = await FriendUser.get_user_name(str(event.user_id))
|
||||
f = await FgRequest.create(
|
||||
request_type=RequestType.GROUP,
|
||||
platform=session.platform,
|
||||
bot_id=bot.self_id,
|
||||
flag=event.flag,
|
||||
user_id=str(event.user_id),
|
||||
nickname=nickname,
|
||||
group_id=str(event.group_id),
|
||||
handle_type=RequestHandleType.APPROVE,
|
||||
)
|
||||
await PlatformUtils.send_superuser(
|
||||
bot,
|
||||
f"*****一份入群申请*****\n"
|
||||
f"ID:{f.id}\n"
|
||||
f"申请人:{nickname}({event.user_id})\n群聊:"
|
||||
f"{event.group_id}\n邀请日期:{datetime.now().replace(microsecond=0)}\n"
|
||||
"注: 该请求已自动同意",
|
||||
)
|
||||
await asyncio.sleep(random.randint(1, 5))
|
||||
await bot.send_private_msg(
|
||||
user_id=event.user_id,
|
||||
message=f"管理员已开启自动同意群组邀请,请不要让{BotConfig.self_nickname}受委屈哦(狠狠监控)"
|
||||
"\n在群组中 群组管理员与群主 允许使用管理员帮助"
|
||||
"(包括ban与功能开关等)\n请在群组中发送 '管理员帮助'",
|
||||
)
|
||||
elif Timer.check(f"{event.user_id}:{event.group_id}"):
|
||||
logger.debug(
|
||||
f"收录 用户[{event.user_id}] 群聊[{event.group_id}] 群聊请求",
|
||||
|
||||
@ -18,6 +18,7 @@ from nonebot_plugin_uninfo import Uninfo
|
||||
|
||||
from zhenxun.configs.utils import BaseBlock, Command, PluginExtraData, RegisterConfig
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.decorator.shop import NotMeetUseConditionsException
|
||||
from zhenxun.utils.depends import UserName
|
||||
from zhenxun.utils.enum import BlockType, PluginType
|
||||
from zhenxun.utils.exception import GoodsNotFound
|
||||
@ -202,6 +203,12 @@ async def _(
|
||||
await MessageUtils.build_message(
|
||||
f"没有找到道具 {name.result} 或道具数量不足..."
|
||||
).send(reply_to=True)
|
||||
except NotMeetUseConditionsException as e:
|
||||
if info := e.get_info():
|
||||
await MessageUtils.build_message(info).finish() # type: ignore
|
||||
await MessageUtils.build_message(
|
||||
f"使用道具 {name.result} 的条件不满足..."
|
||||
).send(reply_to=True)
|
||||
|
||||
|
||||
@_matcher.assign("gold-list")
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
from dataclasses import field
|
||||
from datetime import datetime, timedelta
|
||||
import inspect
|
||||
import time
|
||||
@ -11,7 +10,7 @@ from nonebot.adapters import Bot, Event
|
||||
from nonebot.compat import model_dump
|
||||
from nonebot_plugin_alconna import UniMessage, UniMsg
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from pydantic import BaseModel, create_model
|
||||
from pydantic import BaseModel, Field, create_model
|
||||
from tortoise.expressions import Q
|
||||
|
||||
from zhenxun.models.friend_user import FriendUser
|
||||
@ -33,9 +32,9 @@ from .normal_image import normal_image
|
||||
class Goods(BaseModel):
|
||||
name: str
|
||||
"""商品名称"""
|
||||
before_handle: list[Callable] = field(default_factory=list)
|
||||
before_handle: list[Callable] = Field(default_factory=list)
|
||||
"""使用前函数"""
|
||||
after_handle: list[Callable] = field(default_factory=list)
|
||||
after_handle: list[Callable] = Field(default_factory=list)
|
||||
"""使用后函数"""
|
||||
func: Callable | None = None
|
||||
"""使用函数"""
|
||||
@ -195,7 +194,6 @@ class ShopManage:
|
||||
"num": num,
|
||||
"text": text,
|
||||
"goods_name": goods.name,
|
||||
"message": message,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@ -204,8 +202,9 @@ class ShopManage:
|
||||
args: MappingProxyType,
|
||||
param: ShopParam,
|
||||
session: Uninfo,
|
||||
message: UniMsg,
|
||||
**kwargs,
|
||||
) -> list[Any]:
|
||||
) -> dict:
|
||||
"""解析参数
|
||||
|
||||
参数:
|
||||
@ -213,31 +212,30 @@ class ShopManage:
|
||||
param: ShopParam
|
||||
|
||||
返回:
|
||||
list[Any]: 参数
|
||||
dict: 参数
|
||||
"""
|
||||
param_list = []
|
||||
_bot = param.bot
|
||||
param.bot = None
|
||||
param_json = {**param.to_dict(), **param.extra_data}
|
||||
param_json["bot"] = _bot
|
||||
for par in args.keys():
|
||||
if par in ["shop_param"]:
|
||||
param_list.append(param)
|
||||
elif par in ["session"]:
|
||||
param_list.append(session)
|
||||
elif par in ["message"]:
|
||||
param_list.append(kwargs.get("message"))
|
||||
elif par not in ["args", "kwargs"]:
|
||||
param_list.append(param_json.get(par))
|
||||
if kwargs.get(par) is not None:
|
||||
del kwargs[par]
|
||||
return param_list
|
||||
param_json = {
|
||||
"bot": _bot,
|
||||
"kwargs": kwargs,
|
||||
**param.to_dict(),
|
||||
**param.extra_data,
|
||||
"session": session,
|
||||
"message": message,
|
||||
}
|
||||
for key in list(param_json.keys()):
|
||||
if key not in args:
|
||||
del param_json[key]
|
||||
return param_json
|
||||
|
||||
@classmethod
|
||||
async def run_before_after(
|
||||
cls,
|
||||
goods: Goods,
|
||||
param: ShopParam,
|
||||
session: Uninfo,
|
||||
message: UniMsg,
|
||||
run_type: Literal["after", "before"],
|
||||
**kwargs,
|
||||
):
|
||||
@ -251,16 +249,19 @@ class ShopManage:
|
||||
fun_list = goods.before_handle if run_type == "before" else goods.after_handle
|
||||
if fun_list:
|
||||
for func in fun_list:
|
||||
args = inspect.signature(func).parameters
|
||||
if args and next(iter(args.keys())) != "kwargs":
|
||||
if args := inspect.signature(func).parameters:
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
await func(*cls.__parse_args(args, param, **kwargs))
|
||||
await func(
|
||||
**cls.__parse_args(args, param, session, message, **kwargs)
|
||||
)
|
||||
else:
|
||||
func(*cls.__parse_args(args, param, **kwargs))
|
||||
func(
|
||||
**cls.__parse_args(args, param, session, message, **kwargs)
|
||||
)
|
||||
elif asyncio.iscoroutinefunction(func):
|
||||
await func(**kwargs)
|
||||
await func()
|
||||
else:
|
||||
func(**kwargs)
|
||||
func()
|
||||
|
||||
@classmethod
|
||||
async def __run(
|
||||
@ -268,6 +269,7 @@ class ShopManage:
|
||||
goods: Goods,
|
||||
param: ShopParam,
|
||||
session: Uninfo,
|
||||
message: UniMsg,
|
||||
**kwargs,
|
||||
) -> str | UniMessage | None:
|
||||
"""运行道具函数
|
||||
@ -281,18 +283,20 @@ class ShopManage:
|
||||
"""
|
||||
args = inspect.signature(goods.func).parameters # type: ignore
|
||||
if goods.func:
|
||||
if args and next(iter(args.keys())) != "kwargs":
|
||||
if args:
|
||||
return (
|
||||
await goods.func(*cls.__parse_args(args, param, session, **kwargs))
|
||||
await goods.func(
|
||||
**cls.__parse_args(args, param, session, message, **kwargs)
|
||||
)
|
||||
if asyncio.iscoroutinefunction(goods.func)
|
||||
else goods.func(*cls.__parse_args(args, param, session, **kwargs))
|
||||
else goods.func(
|
||||
**cls.__parse_args(args, param, session, message, **kwargs)
|
||||
)
|
||||
)
|
||||
if asyncio.iscoroutinefunction(goods.func):
|
||||
return await goods.func(
|
||||
**kwargs,
|
||||
)
|
||||
return await goods.func()
|
||||
else:
|
||||
return goods.func(**kwargs)
|
||||
return goods.func()
|
||||
|
||||
@classmethod
|
||||
async def use(
|
||||
@ -340,12 +344,12 @@ class ShopManage:
|
||||
)
|
||||
if num > param.max_num_limit:
|
||||
return f"{goods_info.goods_name} 单次使用最大数量为{param.max_num_limit}..."
|
||||
await cls.run_before_after(goods, param, "before", **kwargs)
|
||||
result = await cls.__run(goods, param, session, **kwargs)
|
||||
await cls.run_before_after(goods, param, session, message, "before", **kwargs)
|
||||
result = await cls.__run(goods, param, session, message, **kwargs)
|
||||
await UserConsole.use_props(
|
||||
session.user.id, goods_info.uuid, num, PlatformUtils.get_platform(session)
|
||||
)
|
||||
await cls.run_before_after(goods, param, "after", **kwargs)
|
||||
await cls.run_before_after(goods, param, session, message, "after", **kwargs)
|
||||
if not result and param.send_success_msg:
|
||||
result = f"使用道具 {goods.name} {num} 次成功!"
|
||||
return result
|
||||
|
||||
@ -83,7 +83,7 @@ class SignManage:
|
||||
)
|
||||
data_list.append(
|
||||
[
|
||||
f"{i+1}",
|
||||
f"{i + 1}",
|
||||
(bytes, 30, 30) if user[3] == "qq" else "",
|
||||
uid2name.get(user[0]),
|
||||
user[1],
|
||||
|
||||
@ -16,6 +16,7 @@ from nonebot_plugin_alconna import (
|
||||
)
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.models.fg_request import FgRequest
|
||||
@ -134,14 +135,15 @@ async def _(
|
||||
"r": RequestHandleType.REFUSED,
|
||||
"i": RequestHandleType.IGNORE,
|
||||
}
|
||||
req = None
|
||||
handle_type = type_dict[handle[-1]]
|
||||
try:
|
||||
if handle_type == RequestHandleType.APPROVE:
|
||||
await FgRequest.approve(bot, id)
|
||||
req = await FgRequest.approve(bot, id)
|
||||
if handle_type == RequestHandleType.REFUSED:
|
||||
await FgRequest.refused(bot, id)
|
||||
req = await FgRequest.refused(bot, id)
|
||||
if handle_type == RequestHandleType.IGNORE:
|
||||
await FgRequest.ignore(id)
|
||||
req = await FgRequest.ignore(id)
|
||||
except NotFoundError:
|
||||
await MessageUtils.build_message("未发现此id的请求...").finish(reply_to=True)
|
||||
except Exception:
|
||||
@ -149,7 +151,14 @@ async def _(
|
||||
reply_to=True
|
||||
)
|
||||
logger.info("处理请求", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message("成功处理请求!").finish(reply_to=True)
|
||||
await MessageUtils.build_message("成功处理请求!").send(reply_to=True)
|
||||
if req and handle_type == RequestHandleType.APPROVE:
|
||||
await bot.send_private_msg(
|
||||
user_id=req.user_id,
|
||||
message=f"管理员已同意此次群组邀请,请不要让{BotConfig.self_nickname}受委屈哦(狠狠监控)"
|
||||
"\n在群组中 群组管理员与群主 允许使用管理员帮助"
|
||||
"(包括ban与功能开关等)\n请在群组中发送 '管理员帮助'",
|
||||
)
|
||||
|
||||
|
||||
@_read_matcher.handle()
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta
|
||||
import time
|
||||
|
||||
@ -11,6 +12,7 @@ from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.bot_connect_log import BotConnectLog
|
||||
from zhenxun.models.chat_history import ChatHistory
|
||||
from zhenxun.models.statistics import Statistics
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
|
||||
from ....base_model import BaseResultModel, QueryModel
|
||||
@ -63,10 +65,17 @@ class ApiDataSource:
|
||||
bot_info = BotInfo(
|
||||
self_id=bot.self_id, nickname=nickname, ava_url=ava_url, platform=platform
|
||||
)
|
||||
group_list, _ = await PlatformUtils.get_group_list(bot, True)
|
||||
friend_list, _ = await PlatformUtils.get_friend_list(bot)
|
||||
bot_info.group_count = len(group_list)
|
||||
bot_info.friend_count = len(friend_list)
|
||||
try:
|
||||
group, friend = await asyncio.gather(
|
||||
PlatformUtils.get_group_list(bot, True),
|
||||
PlatformUtils.get_friend_list(bot),
|
||||
)
|
||||
bot_info.group_count = len(group[0])
|
||||
bot_info.friend_count = len(friend[0])
|
||||
except Exception as e:
|
||||
logger.warning("获取bot好友/群组信息失败...", "WebUi", e=e)
|
||||
bot_info.group_count = 0
|
||||
bot_info.friend_count = 0
|
||||
bot_info.day_call = await Statistics.filter(
|
||||
create_time__gte=now - timedelta(hours=now.hour, minutes=now.minute),
|
||||
bot_id=bot.self_id,
|
||||
|
||||
@ -110,11 +110,18 @@ class ApiDataSource:
|
||||
create_time__gte=now - timedelta(hours=now.hour),
|
||||
).count()
|
||||
# 群聊数量
|
||||
select_bot.group_count = len(await PlatformUtils.get_group_list(select_bot.bot))
|
||||
try:
|
||||
select_bot.group_count = len(
|
||||
(await PlatformUtils.get_group_list(select_bot.bot, True))[0]
|
||||
)
|
||||
# 好友数量
|
||||
select_bot.friend_count = len(
|
||||
await PlatformUtils.get_friend_list(select_bot.bot)
|
||||
(await PlatformUtils.get_friend_list(select_bot.bot))[0]
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning("获取bot好友/群组信息失败...", "WebUi", e=e)
|
||||
select_bot.group_count = 0
|
||||
select_bot.friend_count = 0
|
||||
select_bot.status = await BotConsole.get_bot_status(select_bot.self_id)
|
||||
# 连接时间
|
||||
select_bot.connect_time = bot_live.get(select_bot.self_id) or 0
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
from dataclasses import field
|
||||
|
||||
from nonebot.compat import model_dump
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from zhenxun.utils.enum import RequestType
|
||||
|
||||
@ -174,9 +172,9 @@ class ReqResult(BaseModel):
|
||||
好友/群组请求列表
|
||||
"""
|
||||
|
||||
friend: list[FriendRequestResult] = field(default_factory=list)
|
||||
friend: list[FriendRequestResult] = Field(default_factory=list)
|
||||
"""好友请求列表"""
|
||||
group: list[GroupRequestResult] = field(default_factory=list)
|
||||
group: list[GroupRequestResult] = Field(default_factory=list)
|
||||
"""群组请求列表"""
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
from dataclasses import field
|
||||
from pathlib import Path
|
||||
|
||||
import nonebot
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from .utils import ConfigsManager
|
||||
|
||||
@ -16,9 +15,9 @@ class BotSetting(BaseModel):
|
||||
"""系统代理"""
|
||||
db_url: str = ""
|
||||
"""数据库链接"""
|
||||
platform_superusers: dict[str, list[str]] = field(default_factory=dict)
|
||||
platform_superusers: dict[str, list[str]] = Field(default_factory=dict)
|
||||
"""平台超级用户"""
|
||||
qbot_id_data: dict[str, str] = field(default_factory=dict)
|
||||
qbot_id_data: dict[str, str] = Field(default_factory=dict)
|
||||
"""官bot id:账号id"""
|
||||
|
||||
def get_qbot_uid(self, qbot_id: str) -> str | None:
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
from collections.abc import Callable
|
||||
import copy
|
||||
from dataclasses import field
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Literal
|
||||
|
||||
import cattrs
|
||||
from nonebot.compat import model_dump
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
from ruamel.yaml import YAML
|
||||
from ruamel.yaml.scanner import ScannerError
|
||||
|
||||
@ -38,11 +37,11 @@ class Command(BaseModel):
|
||||
|
||||
command: str
|
||||
"""命令名称"""
|
||||
params: list[str] = field(default_factory=list)
|
||||
params: list[str] = Field(default_factory=list)
|
||||
"""参数"""
|
||||
description: str = ""
|
||||
"""描述"""
|
||||
examples: list[Example] = field(default_factory=list)
|
||||
examples: list[Example] = Field(default_factory=list)
|
||||
"""示例列表"""
|
||||
|
||||
|
||||
@ -96,7 +95,7 @@ class ConfigGroup(BaseModel):
|
||||
"""模块名"""
|
||||
name: str | None = None
|
||||
"""插件名"""
|
||||
configs: dict[str, ConfigModel] = field(default_factory=dict)
|
||||
configs: dict[str, ConfigModel] = Field(default_factory=dict)
|
||||
"""配置项列表"""
|
||||
|
||||
def get(self, c: str, default: Any = None) -> Any:
|
||||
@ -167,6 +166,42 @@ class PluginSetting(BaseModel):
|
||||
"""是否限制超级用户"""
|
||||
cost_gold: int = 0
|
||||
"""调用插件花费金币"""
|
||||
impression: float = 0.0
|
||||
"""调用插件好感度限制"""
|
||||
|
||||
|
||||
class AICallableProperties(BaseModel):
|
||||
type: str
|
||||
"""参数类型"""
|
||||
description: str
|
||||
"""参数描述"""
|
||||
enums: list[str] | None = None
|
||||
"""参数枚举"""
|
||||
|
||||
|
||||
class AICallableParam(BaseModel):
|
||||
type: str
|
||||
"""类型"""
|
||||
properties: dict[str, AICallableProperties]
|
||||
"""参数列表"""
|
||||
required: list[str]
|
||||
"""必要参数"""
|
||||
|
||||
|
||||
class AICallableTag(BaseModel):
|
||||
name: str
|
||||
"""工具名称"""
|
||||
parameters: AICallableParam | None = None
|
||||
"""工具参数"""
|
||||
description: str
|
||||
"""工具描述"""
|
||||
func: Callable | None = None
|
||||
"""工具函数"""
|
||||
|
||||
def to_dict(self):
|
||||
result = model_dump(self)
|
||||
del result["func"]
|
||||
return result
|
||||
|
||||
|
||||
class SchedulerModel(BaseModel):
|
||||
@ -209,7 +244,7 @@ class Task(BaseBlock):
|
||||
"""运行函数"""
|
||||
check: Callable | None = None
|
||||
"""检查函数"""
|
||||
check_args: list = field(default_factory=list)
|
||||
check_args: list = Field(default_factory=list)
|
||||
"""检查函数参数"""
|
||||
|
||||
|
||||
@ -234,7 +269,7 @@ class PluginExtraData(BaseModel):
|
||||
"""插件基本配置"""
|
||||
limits: list[BaseBlock | PluginCdBlock | PluginCountBlock] | None = None
|
||||
"""插件限制"""
|
||||
commands: list[Command] = field(default_factory=list)
|
||||
commands: list[Command] = Field(default_factory=list)
|
||||
"""命令列表,用于说明帮助"""
|
||||
ignore_prompt: bool = False
|
||||
"""是否忽略阻断提示"""
|
||||
@ -242,12 +277,14 @@ class PluginExtraData(BaseModel):
|
||||
"""技能被动"""
|
||||
superuser_help: str | None = None
|
||||
"""超级用户帮助"""
|
||||
aliases: set[str] = field(default_factory=set)
|
||||
aliases: set[str] = Field(default_factory=set)
|
||||
"""额外名称"""
|
||||
sql_list: list[str] | None = None
|
||||
"""常用sql"""
|
||||
is_show: bool = True
|
||||
"""是否显示在菜单中"""
|
||||
smart_tools: list[AICallableTag] | None = None
|
||||
"""智能模式函数工具集"""
|
||||
|
||||
def to_dict(self, **kwargs):
|
||||
return model_dump(self, **kwargs)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from typing_extensions import Self
|
||||
|
||||
from nonebot.adapters import Bot
|
||||
from tortoise import fields
|
||||
|
||||
@ -38,7 +40,7 @@ class FgRequest(Model):
|
||||
table_description = "好友群组请求"
|
||||
|
||||
@classmethod
|
||||
async def approve(cls, bot: Bot, id: int):
|
||||
async def approve(cls, bot: Bot, id: int) -> Self:
|
||||
"""同意请求
|
||||
|
||||
参数:
|
||||
@ -48,10 +50,10 @@ class FgRequest(Model):
|
||||
异常:
|
||||
NotFoundError: 未发现请求
|
||||
"""
|
||||
await cls._handle_request(bot, id, RequestHandleType.APPROVE)
|
||||
return await cls._handle_request(bot, id, RequestHandleType.APPROVE)
|
||||
|
||||
@classmethod
|
||||
async def refused(cls, bot: Bot, id: int):
|
||||
async def refused(cls, bot: Bot, id: int) -> Self:
|
||||
"""拒绝请求
|
||||
|
||||
参数:
|
||||
@ -61,10 +63,10 @@ class FgRequest(Model):
|
||||
异常:
|
||||
NotFoundError: 未发现请求
|
||||
"""
|
||||
await cls._handle_request(bot, id, RequestHandleType.REFUSED)
|
||||
return await cls._handle_request(bot, id, RequestHandleType.REFUSED)
|
||||
|
||||
@classmethod
|
||||
async def ignore(cls, id: int):
|
||||
async def ignore(cls, id: int) -> Self:
|
||||
"""忽略请求
|
||||
|
||||
参数:
|
||||
@ -73,7 +75,7 @@ class FgRequest(Model):
|
||||
异常:
|
||||
NotFoundError: 未发现请求
|
||||
"""
|
||||
await cls._handle_request(None, id, RequestHandleType.IGNORE)
|
||||
return await cls._handle_request(None, id, RequestHandleType.IGNORE)
|
||||
|
||||
@classmethod
|
||||
async def expire(cls, id: int):
|
||||
@ -93,7 +95,7 @@ class FgRequest(Model):
|
||||
bot: Bot | None,
|
||||
id: int,
|
||||
handle_type: RequestHandleType,
|
||||
):
|
||||
) -> Self:
|
||||
"""处理请求
|
||||
|
||||
参数:
|
||||
@ -126,3 +128,4 @@ class FgRequest(Model):
|
||||
sub_type="invite",
|
||||
approve=handle_type == RequestHandleType.APPROVE,
|
||||
)
|
||||
return req
|
||||
|
||||
@ -52,6 +52,8 @@ class PluginInfo(Model):
|
||||
"""父插件"""
|
||||
is_show = fields.BooleanField(default=True, description="是否显示在帮助中")
|
||||
"""是否显示在帮助中"""
|
||||
impression = fields.FloatField(default=0, description="插件好感度限制")
|
||||
"""插件好感度限制"""
|
||||
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
table = "plugin_info"
|
||||
@ -87,4 +89,5 @@ class PluginInfo(Model):
|
||||
"ALTER TABLE plugin_info ADD COLUMN parent character varying(255);",
|
||||
"ALTER TABLE plugin_info ADD COLUMN is_show boolean DEFAULT true;",
|
||||
"ALTER TABLE plugin_info ADD COLUMN ignore_prompt boolean DEFAULT false;",
|
||||
"ALTER TABLE plugin_info ADD COLUMN impression float DEFAULT 0;",
|
||||
]
|
||||
|
||||
@ -36,6 +36,24 @@ class SignUser(Model):
|
||||
table = "sign_users"
|
||||
table_description = "用户签到数据表"
|
||||
|
||||
@classmethod
|
||||
async def get_user(cls, user_id: str, platform: str | None = None) -> "SignUser":
|
||||
"""获取签到用户
|
||||
|
||||
参数:
|
||||
user_id: 用户id
|
||||
platform: 平台.
|
||||
|
||||
返回:
|
||||
Self: SignUser
|
||||
"""
|
||||
user_console = await UserConsole.get_user(user_id, platform)
|
||||
user, _ = await SignUser.get_or_create(
|
||||
user_id=user_id,
|
||||
defaults={"user_console": user_console, "platform": platform},
|
||||
)
|
||||
return user
|
||||
|
||||
@classmethod
|
||||
async def sign(
|
||||
cls,
|
||||
|
||||
@ -5,3 +5,4 @@ require("nonebot_plugin_alconna")
|
||||
require("nonebot_plugin_session")
|
||||
require("nonebot_plugin_htmlrender")
|
||||
require("nonebot_plugin_uninfo")
|
||||
require("nonebot_plugin_waiter")
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
from dataclasses import field
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
import random
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
from strenum import StrEnum
|
||||
|
||||
from ._build_image import BuildImage
|
||||
@ -21,15 +20,15 @@ class MatType(StrEnum):
|
||||
class BuildMatData(BaseModel):
|
||||
mat_type: MatType
|
||||
"""类型"""
|
||||
data: list[int | float] = field(default_factory=list)
|
||||
data: list[int | float] = Field(default_factory=list)
|
||||
"""数据"""
|
||||
x_name: str | None = None
|
||||
"""X轴坐标名称"""
|
||||
y_name: str | None = None
|
||||
"""Y轴坐标名称"""
|
||||
x_index: list[str] = field(default_factory=list)
|
||||
x_index: list[str] = Field(default_factory=list)
|
||||
"""显示轴坐标值"""
|
||||
y_index: list[int | float] = field(default_factory=list)
|
||||
y_index: list[int | float] = Field(default_factory=list)
|
||||
"""数据轴坐标值"""
|
||||
space: tuple[int, int] = (20, 20)
|
||||
"""坐标值间隔(X, Y)"""
|
||||
@ -49,7 +48,7 @@ class BuildMatData(BaseModel):
|
||||
"""背景颜色"""
|
||||
background: Path | bytes | None = None
|
||||
"""背景图片"""
|
||||
bar_color: list[str] = field(default_factory=lambda: ["*"])
|
||||
bar_color: list[str] = Field(default_factory=lambda: ["*"])
|
||||
"""柱状图柱子颜色, 多个时随机, 使用 * 时七色随机"""
|
||||
padding: tuple[int, int] = (50, 50)
|
||||
"""图表上下左右边距"""
|
||||
|
||||
@ -106,3 +106,19 @@ class SqlUtils:
|
||||
f"Unsupported database type: {db_class_name}", query.__module__
|
||||
)
|
||||
return query
|
||||
|
||||
@classmethod
|
||||
def add_column(
|
||||
cls,
|
||||
table_name: str,
|
||||
column_name: str,
|
||||
column_type: str,
|
||||
default: str | None = None,
|
||||
not_null: bool = False,
|
||||
) -> str:
|
||||
sql = f"ALTER TABLE {table_name} ADD COLUMN {column_name} {column_type}"
|
||||
if default:
|
||||
sql += f" DEFAULT {default}"
|
||||
if not_null:
|
||||
sql += " NOT NULL"
|
||||
return sql
|
||||
|
||||
@ -5,13 +5,20 @@ from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fi
|
||||
|
||||
class Retry:
|
||||
@staticmethod
|
||||
def api():
|
||||
def api(
|
||||
retry_count: int = 3, wait: int = 1, exception: tuple[type[Exception], ...] = ()
|
||||
):
|
||||
"""接口调用重试"""
|
||||
base_exceptions = (
|
||||
TimeoutException,
|
||||
ConnectError,
|
||||
HTTPStatusError,
|
||||
EndOfStream,
|
||||
*exception,
|
||||
)
|
||||
return retry(
|
||||
reraise=True,
|
||||
stop=stop_after_attempt(3),
|
||||
wait=wait_fixed(1),
|
||||
retry=retry_if_exception_type(
|
||||
(TimeoutException, ConnectError, HTTPStatusError, EndOfStream)
|
||||
),
|
||||
stop=stop_after_attempt(retry_count),
|
||||
wait=wait_fixed(wait),
|
||||
retry=retry_if_exception_type(base_exceptions),
|
||||
)
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
from collections.abc import Callable
|
||||
from dataclasses import field
|
||||
|
||||
from nonebot.adapters.onebot.v11 import Message, MessageSegment
|
||||
from nonebot.plugin import require
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from zhenxun.models.goods_info import GoodsInfo
|
||||
|
||||
|
||||
class Goods(BaseModel):
|
||||
before_handle: list[Callable] = field(default_factory=list)
|
||||
after_handle: list[Callable] = field(default_factory=list)
|
||||
before_handle: list[Callable] = Field(default_factory=list)
|
||||
after_handle: list[Callable] = Field(default_factory=list)
|
||||
price: int
|
||||
des: str = ""
|
||||
discount: float
|
||||
@ -20,7 +19,7 @@ class Goods(BaseModel):
|
||||
is_passive: bool
|
||||
partition: str | None
|
||||
func: Callable
|
||||
kwargs: dict[str, str] = field(default_factory=dict)
|
||||
kwargs: dict[str, str] = Field(default_factory=dict)
|
||||
send_success_msg: bool
|
||||
max_num_limit: int
|
||||
|
||||
|
||||
@ -33,3 +33,11 @@ RELEASE_SOURCE_FORMAT = (
|
||||
"https://codeload.github.com/{owner}/{repo}/legacy.{compress}/refs/tags/{version}"
|
||||
)
|
||||
"""release 源码格式"""
|
||||
|
||||
GIT_API_COMMIT_FORMAT = "https://api.github.com/repos/{owner}/{repo}/commits/{branch}"
|
||||
"""git api commit地址格式"""
|
||||
|
||||
GIT_API_PROXY_COMMIT_FORMAT = (
|
||||
"https://git-api.zhenxun.org/repos/{owner}/{repo}/commits/{branch}"
|
||||
)
|
||||
"""git api commit地址格式 (代理)"""
|
||||
|
||||
@ -1,14 +1,20 @@
|
||||
from dataclasses import field
|
||||
import contextlib
|
||||
from typing import Protocol
|
||||
|
||||
from aiocache import cached
|
||||
from nonebot.compat import model_dump
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field
|
||||
from strenum import StrEnum
|
||||
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
|
||||
from .const import CACHED_API_TTL, GIT_API_TREES_FORMAT, JSD_PACKAGE_API_FORMAT
|
||||
from .const import (
|
||||
CACHED_API_TTL,
|
||||
GIT_API_COMMIT_FORMAT,
|
||||
GIT_API_PROXY_COMMIT_FORMAT,
|
||||
GIT_API_TREES_FORMAT,
|
||||
JSD_PACKAGE_API_FORMAT,
|
||||
)
|
||||
from .func import (
|
||||
get_fastest_archive_formats,
|
||||
get_fastest_raw_formats,
|
||||
@ -59,9 +65,29 @@ class RepoInfo(BaseModel):
|
||||
for url_format in url_formats
|
||||
]
|
||||
|
||||
async def update_repo_commit(self):
|
||||
with contextlib.suppress(Exception):
|
||||
newest_commit = await self.get_newest_commit(
|
||||
self.owner, self.repo, self.branch
|
||||
)
|
||||
if newest_commit:
|
||||
self.branch = newest_commit
|
||||
return True
|
||||
return False
|
||||
|
||||
def to_dict(self, **kwargs):
|
||||
return model_dump(self, **kwargs)
|
||||
|
||||
@classmethod
|
||||
@cached(ttl=CACHED_API_TTL)
|
||||
async def get_newest_commit(cls, owner: str, repo: str, branch: str) -> str:
|
||||
commit_url = GIT_API_COMMIT_FORMAT.format(owner=owner, repo=repo, branch=branch)
|
||||
commit_url_proxy = GIT_API_PROXY_COMMIT_FORMAT.format(
|
||||
owner=owner, repo=repo, branch=branch
|
||||
)
|
||||
resp = await AsyncHttpx().get([commit_url, commit_url_proxy])
|
||||
return "" if resp.status_code != 200 else resp.json()["sha"]
|
||||
|
||||
|
||||
class APIStrategy(Protocol):
|
||||
"""API策略"""
|
||||
@ -100,7 +126,7 @@ class FileInfo(BaseModel):
|
||||
|
||||
type: FileType
|
||||
name: str
|
||||
files: list["FileInfo"] = field(default_factory=list)
|
||||
files: list["FileInfo"] = Field(default_factory=list)
|
||||
|
||||
|
||||
class JsdelivrStrategy:
|
||||
|
||||
@ -204,9 +204,9 @@ class AsyncHttpx:
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def get_content(cls, url: str, **kwargs) -> bytes | None:
|
||||
async def get_content(cls, url: str, **kwargs) -> bytes:
|
||||
res = await cls.get(url, **kwargs)
|
||||
return res.content if res and res.status_code == 200 else None
|
||||
return res.content
|
||||
|
||||
@classmethod
|
||||
async def download_file(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user