优化admin 内容
This commit is contained in:
@@ -144,6 +144,9 @@ class GroupBotManager:
|
||||
"group_list": set() # 用于缓存 group:list
|
||||
}
|
||||
|
||||
# 管理员列表缓存
|
||||
admin_list = [] # 用于缓存管理员列表
|
||||
|
||||
@staticmethod
|
||||
def display_menu_status(group_id):
|
||||
"""显示所有功能列表及其在指定群组中的当前状态,带emoji"""
|
||||
@@ -159,8 +162,9 @@ class GroupBotManager:
|
||||
def load_local_cache():
|
||||
r = get_redis_connection()
|
||||
"""从 Redis 加载数据到本地缓存"""
|
||||
# 加载管理员列表
|
||||
group_list = r.smembers("group:list")
|
||||
# 输出group_list 列表
|
||||
# 输出group_list 列表
|
||||
logger.debug(f"group_list: {group_list}")
|
||||
GroupBotManager.local_cache["group_list"] = set(group_list)
|
||||
|
||||
@@ -334,17 +338,10 @@ class GroupBotManager:
|
||||
@staticmethod
|
||||
def get_admin_list() -> List[str]:
|
||||
"""获取管理员列表
|
||||
|
||||
返回系统管理员的微信ID列表
|
||||
直接返回缓存的 admin_list,性能更好
|
||||
"""
|
||||
# 从配置文件中获取管理员列表
|
||||
pwd = os.path.dirname(os.path.abspath(__file__))
|
||||
with open(f"{pwd}/config.yaml", "rb") as fp:
|
||||
yconfig = yaml.safe_load(fp)
|
||||
wx_config = yconfig.get("wx_config", {})
|
||||
config_admin_list = wx_config.get("admin") # self.config.get("admin_list", [])
|
||||
|
||||
return config_admin_list
|
||||
return GroupBotManager.admin_list
|
||||
|
||||
|
||||
# 示例命令
|
||||
|
||||
Reference in New Issue
Block a user