Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

版本更新 #1666

Merged
merged 73 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
a368121
✨ 父级插件加载
HibiKier Aug 30, 2024
7e7436f
:white_check_mark: 添加测试:更新与添加插件 (#1594)
AkashiCoin Sep 1, 2024
8fe0617
🐛 bug修复
HibiKier Sep 1, 2024
29c4876
🐛修复添加插件返回403的问题 (#1595)
AkashiCoin Sep 1, 2024
15ad90d
🎨 修改readme
HibiKier Sep 2, 2024
db75c4a
Update README.md
HibiKier Sep 2, 2024
133d4e1
🐛 修改bug与版本锁定
HibiKier Sep 2, 2024
a56d1f2
🐛 修复超级用户对群组功能开关
HibiKier Sep 2, 2024
9eca6a9
🐛 修复插件商店检查插件更新问题 (#1597)
AkashiCoin Sep 2, 2024
44e0f2d
🐛 增加插件状态检查 (#1598)
AkashiCoin Sep 2, 2024
8d071f8
🐛 修复更新群组成员信息
HibiKier Sep 2, 2024
02aba68
🎨 代码优化
HibiKier Sep 2, 2024
405e2d3
:rocket: 更新Dockerfile (#1599)
fanyinrumeng Sep 2, 2024
a2549a0
🎨 更新requirements
HibiKier Sep 3, 2024
a619346
:heavy_plus_sign: 添加依赖aiocache
AkashiCoin Sep 3, 2024
8615eb2
:zap: 添加github镜像
AkashiCoin Sep 3, 2024
7288d5b
✨ 添加仓库目录多获取渠道
AkashiCoin Sep 3, 2024
8911bbf
🐛 修复测试用例
AkashiCoin Sep 3, 2024
c3927c7
✨ 添加API缓存
AkashiCoin Sep 3, 2024
682d19a
🎨 采取Sourcery建议
AkashiCoin Sep 3, 2024
ce97ded
🐛 文件下载逻辑修改
AkashiCoin Sep 3, 2024
c36bb97
🎨 优化代码
HibiKier Sep 4, 2024
51371ba
🐛 修复插件开关有时出现错误
HibiKier Sep 5, 2024
3b4c206
✨ 重构自检ui
HibiKier Sep 6, 2024
db9153f
🐛 自检html修正
HibiKier Sep 6, 2024
3f4787d
修复签到逻辑bug,并使代码更灵活以适应签到好感度等级配置 (#1606)
McElaga Sep 7, 2024
0a5ab83
🎨 代码结构优化
HibiKier Sep 7, 2024
807b2f6
🐛 私聊时修改插件时删除私聊帮助
HibiKier Sep 7, 2024
62fd93c
🐛 过滤父插件
HibiKier Sep 7, 2024
e618b19
🐛 修复自检在ARM上的问题 (#1607)
AkashiCoin Sep 7, 2024
057001f
✨ 支持mysql,psql,sqlite随机函数
HibiKier Sep 7, 2024
1790a0b
✨提供sqlite和mysql连接url示例
HibiKier Sep 7, 2024
2b006b8
:wrench: VSCode配置修改
AkashiCoin Sep 7, 2024
fe11ff0
:wrench: VSCode配置修改
AkashiCoin Sep 7, 2024
440e7b5
✨ 添加金币排行
AkashiCoin Sep 8, 2024
342e70c
:memo: 修改README
AkashiCoin Sep 8, 2024
f11e9c5
:hammer: 提取GitHub相关操作 (#1609)
AkashiCoin Sep 8, 2024
e4a92ea
✨ 签到/金币排行限制最大数量 (#1616)
HibiKier Sep 9, 2024
4e42d1d
🐛 修复超级用户id获取问题
HibiKier Sep 9, 2024
95762bd
🐛 修复路径解压与挂载 (#1619)
HibiKier Sep 10, 2024
a8355fb
🐛 修复功能少时zhenxun帮助图片排序问题 (#1620)
HibiKier Sep 11, 2024
94ef332
🐛 签到文本适应 (#1622)
HibiKier Sep 11, 2024
8a688eb
🐛 好感度排行提供默认值 (#1624)
HibiKier Sep 12, 2024
d97e437
🎈 优先使用github api (#1625)
AkashiCoin Sep 13, 2024
029a731
✨ 重构帮助,限制普通用户查询管理插件 (#1626)
HibiKier Sep 13, 2024
f1354c6
🐛 修复群权限与插件等级匹配 (#1627)
HibiKier Sep 14, 2024
f2e354e
✨ 当管理员尝试ban真寻时将被反杀 (#1628)
HibiKier Sep 14, 2024
e41e163
✨ 群组发言时间检测提供开关配置 (#1630)
HibiKier Sep 14, 2024
cd88d80
🐳 chore: 支持自动修改版本号 (#1629)
AkashiCoin Sep 16, 2024
51c010d
🎈 perf(github_utils): 支持github url下载遍历 (#1632)
AkashiCoin Sep 16, 2024
60f4406
🧪 test(auto_update): 修复测试用例 (#1633)
AkashiCoin Sep 16, 2024
fcfaf56
🐛 修复商店商品为空时报错 (#1634)
HibiKier Sep 16, 2024
6f635ed
🐛 修复群权限与插件等级匹配 (#1635)
HibiKier Sep 16, 2024
9832483
✨ message_build支持AtAll (#1639)
HibiKier Sep 19, 2024
f2c20b8
🎈 perf: 使用commit号下载插件 (#1641)
AkashiCoin Sep 21, 2024
3897658
🐳 chore: 修改运行检查触发路径 (#1642)
AkashiCoin Sep 21, 2024
a04475a
✨ 重构qq群事件处理 (#1643)
HibiKier Sep 21, 2024
3fc4eaa
🐛 签到名称自适应 (#1644)
HibiKier Sep 21, 2024
32c11b9
🎨 更新README (#1645)
HibiKier Sep 21, 2024
207f947
:bug: fix(http_utils): 流式下载Content-Length错误 (#1647)
AkashiCoin Sep 22, 2024
6be9e47
🐛 修复群组中帮助功能状态显示问题 (#1650)
HibiKier Sep 25, 2024
e89d1d4
🐛 修复群欢迎消息设置 (#1651)
HibiKier Sep 25, 2024
7ec1bc9
🐛 修复webui下载后首次启动错误 (#1652)
HibiKier Sep 25, 2024
b14220e
✨ 移除默认图片文件夹:爬 (#1653)
HibiKier Sep 27, 2024
7890cc5
✨ 安装/移除插件提供插件安装/卸载方法用于插件初始化 (#1654)
HibiKier Sep 27, 2024
28b61e5
✨ 新增超级用户与管理员帮助模板 (#1655)
HibiKier Sep 27, 2024
a3311ad
✨ 新增个人信息命令 (#1657)
HibiKier Sep 29, 2024
e8425f3
✨ 修改个人信息菜单名称 (#1658)
HibiKier Sep 29, 2024
d68a409
✨ 新增插件商店api (#1659)
HibiKier Sep 29, 2024
717a973
✨ 将cd,block,count限制复原配置文件 (#1662)
HibiKier Sep 30, 2024
2c8c46d
🎨 修改README (#1663)
HibiKier Sep 30, 2024
94e0594
🎨 修改版本号 (#1664)
HibiKier Sep 30, 2024
482eb1a
🎨 修改requirements (#1665)
HibiKier Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🐛 修复插件商店检查插件更新问题 (#1597)
* 🐛 修复插件商店检查插件更新问题

* 🐛 恶意命令检测问题
  • Loading branch information
AkashiCoin authored Sep 2, 2024
commit 9eca6a97ca13cec97031e1a78f1a357134464494
232 changes: 225 additions & 7 deletions tests/builtin_plugins/plugin_store/test_plugin_store.py
Original file line number Diff line number Diff line change
@@ -13,13 +13,18 @@

from tests.utils import _v11_group_message_event
from tests.config import BotId, UserId, GroupId, MessageId
from tests.utils import get_content_bytes as _get_content_bytes
from tests.utils import get_response_json as _get_response_json


def get_response_json(file: str) -> dict:
return _get_response_json(Path() / "plugin_store", file=file)


def get_content_bytes(file: str) -> bytes:
return _get_content_bytes(Path() / "plugin_store", file)


def init_mocked_api(mocked_api: MockRouter) -> None:
mocked_api.get(
"https://data.jsdelivr.com/v1/packages/gh/xuanerwa/zhenxun_github_sub@main",
@@ -40,15 +45,15 @@ def init_mocked_api(mocked_api: MockRouter) -> None:
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=b"")
).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=b"")
).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=b"")
).respond(content=get_content_bytes("github_sub.py"))


async def test_add_plugin_basic(
@@ -207,15 +212,15 @@ async def test_add_plugin_extra(
assert (mock_base_path / "plugins" / "github_sub" / "__init__.py").is_file()


async def test_update_plugin_basic(
async def test_update_plugin_basic_need_update(
app: App,
mocker: MockerFixture,
mocked_api: MockRouter,
create_bot: Callable,
tmp_path: Path,
) -> None:
"""
测试更新基础插件
测试更新基础插件,插件需要更新
"""
from zhenxun.builtin_plugins.plugin_store import _matcher

@@ -224,6 +229,10 @@ async def test_update_plugin_basic(
"zhenxun.builtin_plugins.plugin_store.data_source.BASE_PATH",
new=tmp_path / "zhenxun",
)
mock_base_path = mocker.patch(
"zhenxun.builtin_plugins.plugin_store.data_source.ShopManage.get_loaded_plugins",
return_value=[("search_image", "0.0")],
)

plugin_id = 1

@@ -259,6 +268,59 @@ async def test_update_plugin_basic(
assert (mock_base_path / "plugins" / "search_image" / "__init__.py").is_file()


async def test_update_plugin_basic_is_new(
app: App,
mocker: MockerFixture,
mocked_api: MockRouter,
create_bot: Callable,
tmp_path: Path,
) -> None:
"""
测试更新基础插件,插件是最新版
"""
from zhenxun.builtin_plugins.plugin_store import _matcher

init_mocked_api(mocked_api=mocked_api)
mocker.patch(
"zhenxun.builtin_plugins.plugin_store.data_source.BASE_PATH",
new=tmp_path / "zhenxun",
)
mocker.patch(
"zhenxun.builtin_plugins.plugin_store.data_source.ShopManage.get_loaded_plugins",
return_value=[("search_image", "0.1")],
)

plugin_id = 1

async with app.test_matcher(_matcher) as ctx:
bot = create_bot(ctx)
bot: Bot = cast(Bot, bot)
raw_message = f"更新插件 {plugin_id}"
event: GroupMessageEvent = _v11_group_message_event(
message=raw_message,
self_id=BotId.QQ_BOT,
user_id=UserId.SUPERUSER,
group_id=GroupId.GROUP_ID_LEVEL_5,
message_id=MessageId.MESSAGE_ID,
to_me=True,
)
ctx.receive_event(bot=bot, event=event)
ctx.should_call_send(
event=event,
message=Message(message=f"正在更新插件 Id: {plugin_id}"),
result=None,
bot=bot,
)
ctx.should_call_send(
event=event,
message=Message(message="插件 识图 已是最新版本"),
result=None,
bot=bot,
)
assert mocked_api["basic_plugins"].called
assert mocked_api["extra_plugins"].called


async def test_remove_plugin(
app: App,
mocker: MockerFixture,
@@ -280,8 +342,8 @@ async def test_remove_plugin(
plugin_path = mock_base_path / "plugins" / "search_image"
plugin_path.mkdir(parents=True, exist_ok=True)

with open(plugin_path / "__init__.py", "w") as f:
f.write("")
with open(plugin_path / "__init__.py", "wb") as f:
f.write(get_content_bytes("search_image.py"))

plugin_id = 1

@@ -307,3 +369,159 @@ async def test_remove_plugin(
assert mocked_api["basic_plugins"].called
assert mocked_api["extra_plugins"].called
assert not (mock_base_path / "plugins" / "search_image" / "__init__.py").is_file()


async def test_plugin_not_exist_add(
app: App,
mocker: MockerFixture,
mocked_api: MockRouter,
create_bot: Callable,
tmp_path: Path,
) -> None:
"""
测试插件不存在,添加插件
"""
from zhenxun.builtin_plugins.plugin_store import _matcher

init_mocked_api(mocked_api=mocked_api)
plugin_id = -1

async with app.test_matcher(_matcher) as ctx:
bot = create_bot(ctx)
bot: Bot = cast(Bot, bot)
raw_message = f"添加插件 {plugin_id}"
event: GroupMessageEvent = _v11_group_message_event(
message=raw_message,
self_id=BotId.QQ_BOT,
user_id=UserId.SUPERUSER,
group_id=GroupId.GROUP_ID_LEVEL_5,
message_id=MessageId.MESSAGE_ID,
to_me=True,
)
ctx.receive_event(bot=bot, event=event)
ctx.should_call_send(
event=event,
message=Message(message=f"正在添加插件 Id: {plugin_id}"),
result=None,
bot=bot,
)
ctx.should_call_send(
event=event,
message=Message(message="插件ID不存在..."),
result=None,
bot=bot,
)


async def test_plugin_not_exist_update(
app: App,
mocker: MockerFixture,
mocked_api: MockRouter,
create_bot: Callable,
tmp_path: Path,
) -> None:
"""
测试插件不存在,更新插件
"""
from zhenxun.builtin_plugins.plugin_store import _matcher

init_mocked_api(mocked_api=mocked_api)
plugin_id = -1

async with app.test_matcher(_matcher) as ctx:
bot = create_bot(ctx)
bot: Bot = cast(Bot, bot)
raw_message = f"更新插件 {plugin_id}"
event: GroupMessageEvent = _v11_group_message_event(
message=raw_message,
self_id=BotId.QQ_BOT,
user_id=UserId.SUPERUSER,
group_id=GroupId.GROUP_ID_LEVEL_5,
message_id=MessageId.MESSAGE_ID_2,
to_me=True,
)
ctx.receive_event(bot=bot, event=event)
ctx.should_call_send(
event=event,
message=Message(message=f"正在更新插件 Id: {plugin_id}"),
result=None,
bot=bot,
)
ctx.should_call_send(
event=event,
message=Message(message="插件ID不存在..."),
result=None,
bot=bot,
)


async def test_plugin_not_exist_remove(
app: App,
mocker: MockerFixture,
mocked_api: MockRouter,
create_bot: Callable,
tmp_path: Path,
) -> None:
"""
测试插件不存在,移除插件
"""
from zhenxun.builtin_plugins.plugin_store import _matcher

init_mocked_api(mocked_api=mocked_api)
plugin_id = -1

async with app.test_matcher(_matcher) as ctx:
bot = create_bot(ctx)
bot: Bot = cast(Bot, bot)
raw_message = f"移除插件 {plugin_id}"
event: GroupMessageEvent = _v11_group_message_event(
message=raw_message,
self_id=BotId.QQ_BOT,
user_id=UserId.SUPERUSER,
group_id=GroupId.GROUP_ID_LEVEL_5,
message_id=MessageId.MESSAGE_ID_2,
to_me=True,
)
ctx.receive_event(bot=bot, event=event)
ctx.should_call_send(
event=event,
message=Message(message="插件ID不存在..."),
result=None,
bot=bot,
)


async def test_plugin_not_exist_search(
app: App,
mocker: MockerFixture,
mocked_api: MockRouter,
create_bot: Callable,
tmp_path: Path,
) -> None:
"""
测试插件不存在,搜索插件
"""
from zhenxun.builtin_plugins.plugin_store import _matcher

init_mocked_api(mocked_api=mocked_api)
plugin_id = -1

async with app.test_matcher(_matcher) as ctx:
bot = create_bot(ctx)
bot: Bot = cast(Bot, bot)
raw_message = f"搜索插件 {plugin_id}"
event: GroupMessageEvent = _v11_group_message_event(
message=raw_message,
self_id=BotId.QQ_BOT,
user_id=UserId.SUPERUSER,
group_id=GroupId.GROUP_ID_LEVEL_5,
message_id=MessageId.MESSAGE_ID_3,
to_me=True,
)
ctx.receive_event(bot=bot, event=event)
ctx.should_call_send(
event=event,
message=Message(message="未找到相关插件..."),
result=None,
bot=bot,
)
2 changes: 2 additions & 0 deletions tests/config.py
Original file line number Diff line number Diff line change
@@ -18,3 +18,5 @@ class GroupId:
class MessageId:
MESSAGE_ID = 30001
MESSAGE_ID_2 = 30002
MESSAGE_ID_3 = 30003
MESSAGE_ID_4 = 30004
24 changes: 24 additions & 0 deletions tests/content/plugin_store/github_sub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from nonebot.plugin import PluginMetadata

from zhenxun.configs.utils import PluginExtraData

__plugin_meta__ = PluginMetadata(
name="github订阅",
description="订阅github用户或仓库",
usage="""
usage:
github新Comment,PR,Issue等提醒
指令:
添加github ['用户'/'仓库'] [用户名/{owner/repo}]
删除github [用户名/{owner/repo}]
查看github
示例:添加github订阅 用户 HibiKier
示例:添加gb订阅 仓库 HibiKier/zhenxun_bot
示例:添加github 用户 HibiKier
示例:删除gb订阅 HibiKier
""".strip(),
extra=PluginExtraData(
author="xuanerwa",
version="0.7",
).dict(),
)
17 changes: 17 additions & 0 deletions tests/content/plugin_store/jitang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from nonebot.plugin import PluginMetadata

from zhenxun.configs.utils import PluginExtraData

__plugin_meta__ = PluginMetadata(
name="鸡汤",
description="喏,亲手为你煮的鸡汤",
usage="""
不喝点什么感觉有点不舒服
指令:
鸡汤
""".strip(),
extra=PluginExtraData(
author="HibiKier",
version="0.1",
).dict(),
)
18 changes: 18 additions & 0 deletions tests/content/plugin_store/search_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from nonebot.plugin import PluginMetadata

from zhenxun.configs.utils import PluginExtraData

__plugin_meta__ = PluginMetadata(
name="识图",
description="以图搜图,看破本源",
usage="""
识别图片 [二次元图片]
指令:
识图 [图片]
""".strip(),
extra=PluginExtraData(
author="HibiKier",
version="0.1",
menu_type="一些工具",
).dict(),
)
Loading