优化admin 内容

This commit is contained in:
liuwei
2026-01-16 16:31:46 +08:00
parent fb186096f3
commit 41535bda65

View File

@@ -250,15 +250,19 @@ class GroupBotManager:
# 如果第一个参数是序号,则转化为对应的功能 # 如果第一个参数是序号,则转化为对应的功能
if feature_str.isdigit(): if feature_str.isdigit():
feature_num = int(feature_str) feature_num = int(feature_str)
try: # 通过遍历查找匹配的枚举值
feature = Feature(feature_num, "") # 使用枚举序号查找功能 feature = None
except ValueError: for f in Feature:
return "无效的功能序号" if f.value == feature_num:
feature = f
break
if not feature:
return f"无效的功能序号: {feature_num}"
else: else:
try: try:
feature = Feature[feature_str] # 通过枚举名称获取功能枚举 feature = Feature[feature_str] # 通过枚举名称获取功能枚举
except KeyError: except KeyError:
return "无效功能名称" return f"无效功能名称: {feature_str}"
r = get_redis_connection() r = get_redis_connection()
# 处理群机器人的启用和关闭(特别操作:更新 group:list # 处理群机器人的启用和关闭(特别操作:更新 group:list