加入权限判断
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import Callable, Dict, Any, Tuple, Union
|
||||
|
||||
from db.connection import DBConnectionManager
|
||||
from db.points_db import PointsDBOperator, PointSource
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
|
||||
|
||||
def points_reward_decorator(points_calculator: Union[int, Callable], source_type: str = "other",
|
||||
@@ -28,8 +28,9 @@ def points_reward_decorator(points_calculator: Union[int, Callable], source_type
|
||||
def wrapper(self, message: Dict[str, Any]) -> Tuple[bool, str]:
|
||||
# 检查权限
|
||||
roomid = message.get("roomid", "")
|
||||
if feature and roomid and hasattr(self, 'gbm'):
|
||||
if self.gbm.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
|
||||
if feature and roomid:
|
||||
if GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 调用原始方法
|
||||
@@ -113,8 +114,8 @@ def plugin_points_cost(points: int, description: str = None, feature: Feature =
|
||||
try:
|
||||
# 检查权限
|
||||
roomid = message.get("roomid", "")
|
||||
if feature and roomid and hasattr(self, 'gbm'):
|
||||
if self.gbm.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
if feature and roomid:
|
||||
if GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 获取消息信息
|
||||
|
||||
Reference in New Issue
Block a user