mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
Compare commits
4 Commits
96c0a8626c
...
f24f1e73cc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f24f1e73cc | ||
|
|
eb6d90ae88 | ||
|
|
e6f6ad0559 | ||
|
|
6815caf805 |
@ -263,10 +263,9 @@ class StoreManager:
|
||||
"""安装插件
|
||||
|
||||
参数:
|
||||
github_url: 仓库地址
|
||||
module_path: 模块路径
|
||||
is_dir: 是否是文件夹
|
||||
plugin_info: 插件信息
|
||||
is_external: 是否是外部仓库
|
||||
source: 源
|
||||
"""
|
||||
repo_type = RepoType.GITHUB if is_external else None
|
||||
if source == "ali":
|
||||
|
||||
@ -213,17 +213,31 @@ async def handle_info(name: Match[str], bot: Bot):
|
||||
msg += f"模式: {mode}\n"
|
||||
msg += f"描述: {details['description'] or '无'}\n"
|
||||
|
||||
if details["tag_type"] == "DYNAMIC":
|
||||
if details["tag_type"] == "STATIC" and details["is_blacklist"]:
|
||||
msg += f"排除群组 ({len(details['groups'])}个):\n"
|
||||
if details["groups"]:
|
||||
msg += "\n".join(f"- {gid}" for gid in details["groups"])
|
||||
else:
|
||||
msg += "无"
|
||||
msg += "\n\n"
|
||||
|
||||
if details["tag_type"] == "DYNAMIC" and details.get("dynamic_rule"):
|
||||
msg += f"动态规则: {details['dynamic_rule']}\n"
|
||||
if details["resolved_groups"] is not None:
|
||||
msg += f"当前匹配群组 ({len(details['resolved_groups'])}个):\n"
|
||||
if details["resolved_groups"]:
|
||||
msg += "\n".join(
|
||||
f"- {g_name} ({g_id})"
|
||||
for g_id, g_name in details["resolved_groups"]
|
||||
)
|
||||
else:
|
||||
msg += "无"
|
||||
|
||||
title = (
|
||||
"当前生效群组"
|
||||
if details["tag_type"] == "DYNAMIC" or details["is_blacklist"]
|
||||
else "关联群组"
|
||||
)
|
||||
|
||||
if details["resolved_groups"] is not None:
|
||||
msg += f"{title} ({len(details['resolved_groups'])}个):\n"
|
||||
if details["resolved_groups"]:
|
||||
msg += "\n".join(
|
||||
f"- {g_name} ({g_id})" for g_id, g_name in details["resolved_groups"]
|
||||
)
|
||||
else:
|
||||
msg += "无"
|
||||
else:
|
||||
msg += f"关联群组 ({len(details['groups'])}个):\n"
|
||||
if details["groups"]:
|
||||
|
||||
@ -468,9 +468,7 @@ class SchedulerManager:
|
||||
"required_permission": required_permission,
|
||||
"source": source,
|
||||
"is_one_off": is_one_off,
|
||||
"execution_options": model_dump(
|
||||
validated_options, exclude_none=True
|
||||
),
|
||||
"execution_options": model_dump(validated_options, exclude_none=True),
|
||||
}
|
||||
|
||||
defaults = {k: v for k, v in defaults.items() if v is not None}
|
||||
|
||||
@ -77,6 +77,7 @@ class Trigger:
|
||||
"""创建一个 Date 触发器配置。"""
|
||||
return DateTrigger(**kwargs)
|
||||
|
||||
|
||||
class ExecutionOptions(BaseModel):
|
||||
"""
|
||||
封装定时任务的执行策略,包括重试和回调。
|
||||
|
||||
@ -234,16 +234,13 @@ class TagManager:
|
||||
if not tag:
|
||||
return None
|
||||
|
||||
resolved_groups = None
|
||||
if tag.tag_type == "DYNAMIC" and bot:
|
||||
resolved_group_ids = await self.resolve_tag_to_group_ids(name, bot=bot)
|
||||
if resolved_group_ids:
|
||||
groups_from_db = await GroupConsole.filter(
|
||||
group_id__in=resolved_group_ids
|
||||
).all()
|
||||
resolved_groups = [(g.group_id, g.group_name) for g in groups_from_db]
|
||||
else:
|
||||
resolved_groups = []
|
||||
final_group_ids = await self.resolve_tag_to_group_ids(name, bot=bot)
|
||||
resolved_groups: list[tuple[str, str]] = []
|
||||
if final_group_ids:
|
||||
groups_from_db = await GroupConsole.filter(
|
||||
group_id__in=final_group_ids
|
||||
).all()
|
||||
resolved_groups = [(g.group_id, g.group_name) for g in groups_from_db]
|
||||
|
||||
return {
|
||||
"name": tag.name,
|
||||
@ -418,18 +415,37 @@ class TagManager:
|
||||
if not tag:
|
||||
return []
|
||||
|
||||
if tag.tag_type == "DYNAMIC":
|
||||
associated_groups: set[str] = set()
|
||||
if tag.tag_type == "STATIC":
|
||||
associated_groups = {str(link.group_id) for link in tag.groups}
|
||||
elif tag.tag_type == "DYNAMIC":
|
||||
if not tag.dynamic_rule or not isinstance(tag.dynamic_rule, dict | str):
|
||||
return []
|
||||
associated_groups = await self._resolve_dynamic_tag(tag.dynamic_rule, bot)
|
||||
dynamic_ids = await self._resolve_dynamic_tag(tag.dynamic_rule, bot)
|
||||
associated_groups = {str(gid) for gid in dynamic_ids}
|
||||
else:
|
||||
associated_groups = {link.group_id for link in tag.groups}
|
||||
associated_groups = {str(link.group_id) for link in tag.groups}
|
||||
|
||||
if tag.is_blacklist:
|
||||
all_group_ids_from_db = await GroupConsole.all().values_list(
|
||||
all_groups_query = GroupConsole.all()
|
||||
if bot:
|
||||
bot_groups, _ = await PlatformUtils.get_group_list(bot)
|
||||
bot_group_ids = {str(g.group_id) for g in bot_groups if g.group_id}
|
||||
if bot_group_ids:
|
||||
all_groups_query = all_groups_query.filter(
|
||||
group_id__in=bot_group_ids
|
||||
)
|
||||
else:
|
||||
return []
|
||||
|
||||
all_relevant_group_ids_from_db = await all_groups_query.values_list(
|
||||
"group_id", flat=True
|
||||
)
|
||||
return list({str(gid) for gid in all_group_ids_from_db} - associated_groups)
|
||||
all_relevant_group_ids = {
|
||||
str(gid) for gid in all_relevant_group_ids_from_db
|
||||
}
|
||||
|
||||
return list(all_relevant_group_ids - associated_groups)
|
||||
else:
|
||||
return list(associated_groups)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user