Skip to content

Commit

Permalink
🐛 优化Bot管理插件,更新使用说明及代码结构 (#1767)
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier authored Dec 13, 2024
1 parent b010eac commit e363d29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 14 additions & 5 deletions zhenxun/builtin_plugins/superuser/bot_manage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
from typing import cast

import nonebot
Expand All @@ -15,21 +14,31 @@

driver = nonebot.get_driver()

_sub_plugins = set()
_sub_plugins |= nonebot.load_plugins(str(Path(__file__).parent.resolve()))

__plugin_meta__ = PluginMetadata(
name="Bot管理",
description="指定bot对象的功能/被动开关和状态",
usage="""
指令:
bot被动状态 : bot的被动技能状态
bot开启/关闭被动[被动名称] : 被动技能开关
bot开启/关闭所有被动 : 所有被动技能开关
bot插件列表: bot插件列表状态 : bot插件列表
bot开启/关闭所有插件 : 所有插件开关
bot开启/关闭插件[插件名称] : 插件开关
bot休眠 : bot休眠,屏蔽所有消息
bot醒来 : bot醒来
""".strip(),
extra=PluginExtraData(
author="",
version="0.1",
plugin_type=PluginType.PARENT,
plugin_type=PluginType.SUPERUSER,
).dict(),
)

from .bot_switch import * # noqa: F403
from .plugin import * # noqa: F403
from .task import * # noqa: F403


@driver.on_bot_connect
async def init_bot_console(bot: Bot):
Expand Down
3 changes: 2 additions & 1 deletion zhenxun/models/user_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ async def reduce_gold(
InsufficientGold: 金币不足
"""
user, _ = await cls.get_or_create(
user_id=user_id, defaults={"platform": platform, "uid": cls.get_new_uid()}
user_id=user_id,
defaults={"platform": platform, "uid": await cls.get_new_uid()},
)
if user.gold < gold:
raise InsufficientGold()
Expand Down

0 comments on commit e363d29

Please sign in to comment.