mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🐛 修复获取群组时会修改群组插件关闭状态
This commit is contained in:
parent
f1d32bff89
commit
4dc7d78ee5
@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from zhenxun.configs.path_config import DATA_PATH, IMAGE_PATH
|
||||
from zhenxun.models.group_console import GroupConsole
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
@ -14,9 +16,9 @@ GROUP_HELP_PATH = DATA_PATH / "group_help"
|
||||
def delete_help_image(gid: str | None = None):
|
||||
"""删除帮助图片"""
|
||||
if gid:
|
||||
file = GROUP_HELP_PATH / f"{gid}.png"
|
||||
if file.exists():
|
||||
file.unlink()
|
||||
for file in os.listdir(GROUP_HELP_PATH):
|
||||
if file.startswith(f"{gid}"):
|
||||
os.remove(GROUP_HELP_PATH / file)
|
||||
else:
|
||||
if HELP_FILE.exists():
|
||||
HELP_FILE.unlink()
|
||||
@ -196,7 +198,7 @@ class PluginManage:
|
||||
await PluginInfo.filter(plugin_type=PluginType.NORMAL).update(
|
||||
default_status=status
|
||||
)
|
||||
return f'成功将所有功能进群默认状态修改为: {"开启" if status else "关闭"}'
|
||||
return f"成功将所有功能进群默认状态修改为: {'开启' if status else '关闭'}"
|
||||
if group_id:
|
||||
if group := await GroupConsole.get_or_none(
|
||||
group_id=group_id, channel_id__isnull=True
|
||||
@ -213,12 +215,12 @@ class PluginManage:
|
||||
module_list = [f"<{module}" for module in module_list]
|
||||
group.block_plugin = ",".join(module_list) + "," # type: ignore
|
||||
await group.save(update_fields=["block_plugin"])
|
||||
return f'成功将此群组所有功能状态修改为: {"开启" if status else "关闭"}'
|
||||
return f"成功将此群组所有功能状态修改为: {'开启' if status else '关闭'}"
|
||||
return "获取群组失败..."
|
||||
await PluginInfo.filter(plugin_type=PluginType.NORMAL).update(
|
||||
status=status, block_type=None if status else BlockType.ALL
|
||||
)
|
||||
return f'成功将所有功能全局状态修改为: {"开启" if status else "关闭"}'
|
||||
return f"成功将所有功能全局状态修改为: {'开启' if status else '关闭'}"
|
||||
|
||||
@classmethod
|
||||
async def is_wake(cls, group_id: str) -> bool:
|
||||
|
||||
@ -110,17 +110,17 @@ class GroupConsole(Model):
|
||||
group, is_create = await super().get_or_create(
|
||||
defaults=defaults, using_db=using_db, **kwargs
|
||||
)
|
||||
if is_create and (
|
||||
modules := await TaskInfo.filter(default_status=False).values_list(
|
||||
if is_create:
|
||||
if modules := await TaskInfo.filter(default_status=False).values_list(
|
||||
"module", flat=True
|
||||
)
|
||||
):
|
||||
group.block_task = cls.convert_module_format(modules) # type: ignore
|
||||
if modules := await PluginInfo.filter(
|
||||
plugin_type__in=[PluginType.NORMAL, PluginType.DEPENDANT],
|
||||
default_status=False,
|
||||
).values_list("module", flat=True):
|
||||
group.block_plugin = cls.convert_module_format(modules) # type: ignore
|
||||
):
|
||||
group.block_task = cls.convert_module_format(modules) # type: ignore
|
||||
if modules := await PluginInfo.filter(
|
||||
plugin_type__in=[PluginType.NORMAL, PluginType.DEPENDANT],
|
||||
default_status=False,
|
||||
load_status=True,
|
||||
).values_list("module", flat=True):
|
||||
group.block_plugin = cls.convert_module_format(modules) # type: ignore
|
||||
await group.save(
|
||||
using_db=using_db, update_fields=["block_plugin", "block_task"]
|
||||
)
|
||||
@ -137,17 +137,17 @@ class GroupConsole(Model):
|
||||
group, is_create = await super().update_or_create(
|
||||
defaults=defaults, using_db=using_db, **kwargs
|
||||
)
|
||||
if is_create and (
|
||||
modules := await TaskInfo.filter(default_status=False).values_list(
|
||||
if is_create:
|
||||
if modules := await TaskInfo.filter(default_status=False).values_list(
|
||||
"module", flat=True
|
||||
)
|
||||
):
|
||||
group.block_task = cls.convert_module_format(modules) # type: ignore
|
||||
if modules := await PluginInfo.filter(
|
||||
plugin_type__in=[PluginType.NORMAL, PluginType.DEPENDANT],
|
||||
default_status=False,
|
||||
).values_list("module", flat=True):
|
||||
group.block_plugin = cls.convert_module_format(modules) # type: ignore
|
||||
):
|
||||
group.block_task = cls.convert_module_format(modules) # type: ignore
|
||||
if modules := await PluginInfo.filter(
|
||||
plugin_type__in=[PluginType.NORMAL, PluginType.DEPENDANT],
|
||||
default_status=False,
|
||||
load_status=True,
|
||||
).values_list("module", flat=True):
|
||||
group.block_plugin = cls.convert_module_format(modules) # type: ignore
|
||||
await group.save(
|
||||
using_db=using_db, update_fields=["block_plugin", "block_task"]
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user