Add files via upload
parent
51cbb2b227
commit
b5e7316b94
|
|
@ -72,6 +72,7 @@ class CommandType(Enum):
|
||||||
GROUP_BAN = "set_group_ban" # 禁言用户
|
GROUP_BAN = "set_group_ban" # 禁言用户
|
||||||
GROUP_WHOLE_BAN = "set_group_whole_ban" # 群全体禁言
|
GROUP_WHOLE_BAN = "set_group_whole_ban" # 群全体禁言
|
||||||
GROUP_KICK = "set_group_kick" # 踢出群聊
|
GROUP_KICK = "set_group_kick" # 踢出群聊
|
||||||
|
SEND_POKE = "send_poke" # 戳一戳
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.value
|
return self.value
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ class SendHandler:
|
||||||
command, args_dict = self.handle_whole_ban_command(seg_data.get("args"), group_info)
|
command, args_dict = self.handle_whole_ban_command(seg_data.get("args"), group_info)
|
||||||
case CommandType.GROUP_KICK.name:
|
case CommandType.GROUP_KICK.name:
|
||||||
command, args_dict = self.handle_kick_command(seg_data.get("args"), group_info)
|
command, args_dict = self.handle_kick_command(seg_data.get("args"), group_info)
|
||||||
|
case CommandType.SEND_POKE.name:
|
||||||
|
command, args_dict = self.handle_poke_command(seg_data.get("args"), group_info)
|
||||||
case _:
|
case _:
|
||||||
logger.error(f"未知命令: {command_name}")
|
logger.error(f"未知命令: {command_name}")
|
||||||
return
|
return
|
||||||
|
|
@ -295,6 +297,33 @@ class SendHandler:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def handle_poke_command(self, args: Dict[str, Any], group_info: GroupInfo) -> Tuple[str, Dict[str, Any]]:
|
||||||
|
"""处理戳一戳命令
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args (Dict[str, Any]): 参数字典
|
||||||
|
group_info (GroupInfo): 群聊信息(对应目标群聊)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Tuple[CommandType, Dict[str, Any]]
|
||||||
|
"""
|
||||||
|
user_id: int = int(args["qq_id"])
|
||||||
|
if group_info == None:
|
||||||
|
group_id = None
|
||||||
|
else:
|
||||||
|
group_id: int = int(group_info.group_id)
|
||||||
|
if group_id <= 0:
|
||||||
|
raise ValueError("群组ID无效")
|
||||||
|
if user_id <= 0:
|
||||||
|
raise ValueError("用户ID无效")
|
||||||
|
return (
|
||||||
|
CommandType.SEND_POKE.value,
|
||||||
|
{
|
||||||
|
"group_id": group_id,
|
||||||
|
"user_id": user_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
async def send_message_to_napcat(self, action: str, params: dict) -> dict:
|
async def send_message_to_napcat(self, action: str, params: dict) -> dict:
|
||||||
request_uuid = str(uuid.uuid4())
|
request_uuid = str(uuid.uuid4())
|
||||||
payload = json.dumps({"action": action, "params": params, "echo": request_uuid})
|
payload = json.dumps({"action": action, "params": params, "echo": request_uuid})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue