mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-01 09:39:59 +08:00
优化manager代码
This commit is contained in:
@@ -67,7 +67,7 @@ async def _():
|
||||
gl = [g["group_id"] for g in gl]
|
||||
msg_list, code = await get_epic_free(bot, "Group")
|
||||
for g in gl:
|
||||
if await group_manager.check_group_task_status(g, "epic_free_game"):
|
||||
if group_manager.check_group_task_status(g, "epic_free_game"):
|
||||
try:
|
||||
if msg_list and code == 200:
|
||||
await bot.send_group_forward_msg(group_id=g, messages=msg_list)
|
||||
|
||||
@@ -71,5 +71,5 @@ async def _():
|
||||
if alc_img:
|
||||
mes = "[[_task|genshin_alc]]" + alc_img + "\n ※ 黄历数据来源于 genshin.pub"
|
||||
for gid in gl:
|
||||
if await group_manager.check_group_task_status(gid, "genshin_alc"):
|
||||
if group_manager.check_group_task_status(gid, "genshin_alc"):
|
||||
await bot.send_group_msg(group_id=int(gid), message="" + mes)
|
||||
|
||||
@@ -172,7 +172,7 @@ async def generate_statistics_img(
|
||||
data: dict, arg: str, name: str, plugin: str, day_index: int
|
||||
):
|
||||
try:
|
||||
plugin = plugins2settings_manager.get_plugin_data(plugin)['cmd'][0]
|
||||
plugin = plugins2settings_manager.get_plugin_data(plugin).cmd[0]
|
||||
except (KeyError, IndexError):
|
||||
pass
|
||||
bar_graph = None
|
||||
|
||||
@@ -107,8 +107,8 @@ async def _(
|
||||
group_id = "total"
|
||||
user_id = str(event.user_id)
|
||||
plugin_name = plugins2settings_manager.get_plugin_data(module)
|
||||
if plugin_name and plugin_name.get('cmd'):
|
||||
plugin_name = plugin_name.get('cmd')[0]
|
||||
if plugin_name and plugin_name.cmd:
|
||||
plugin_name = plugin_name.cmd[0]
|
||||
check_exists_key(group_id, user_id, plugin_name)
|
||||
for data in [_prefix_count_dict, _prefix_user_count_dict]:
|
||||
data["total_statistics"]["total"][plugin_name] += 1
|
||||
|
||||
@@ -23,11 +23,11 @@ gConfig.add_plugin_config("web-ui", "password", None, name="web-ui", help_="前
|
||||
async def _(matcher: Matcher, bot: Bot, event: MessageEvent, state: T_State):
|
||||
flag = False
|
||||
for module in plugins2settings_manager.keys():
|
||||
if isinstance(plugins2settings_manager.get_plugin_data(module).get("cmd"), str):
|
||||
if isinstance(plugins2settings_manager.get_plugin_data(module).cmd, str):
|
||||
plugins2settings_manager.set_module_data(
|
||||
module,
|
||||
"cmd",
|
||||
plugins2settings_manager.get_plugin_data(module).get("cmd").split(","),
|
||||
plugins2settings_manager.get_plugin_data(module).cmd.split(","),
|
||||
False
|
||||
)
|
||||
flag = True
|
||||
|
||||
@@ -61,8 +61,8 @@ def _(type_: Optional[str], user: User = Depends(token_to_user)) -> Result:
|
||||
)
|
||||
data["plugin_manager"] = PluginManager(**x)
|
||||
if x := plugins2settings_manager.get(model):
|
||||
if x.get("cmd") and isinstance(x.get("cmd"), list):
|
||||
x["cmd"] = ",".join(x["cmd"])
|
||||
if x.cmd and isinstance(x.cmd, list):
|
||||
x.cmd = ",".join(x.cmd)
|
||||
data["plugin_settings"] = PluginSettings(**x)
|
||||
if x := plugins2cd_manager.get(model):
|
||||
data["cd_limit"] = CdLimit(**x)
|
||||
|
||||
Reference in New Issue
Block a user