结构调整

视频解析多图/多媒体结构 消息体适配
This commit is contained in:
2026-09-08 14:25:32 +08:00
parent 30899688a7
commit 131b92b319
72 changed files with 433 additions and 186 deletions
+43
View File
@@ -0,0 +1,43 @@
from nonebot.adapters.onebot.v11 import MessageSegment
class TextMessage:
def __init__(self, text):
self.text = text
class ImageMessage:
def __init__(self, image):
self.image = image
class UnknownMessage:
def __init__(self, raw):
self.raw = raw
class MessageState:
def __init__(self, data_dict):
self.data_dict = data_dict
# 获取命令头
def get_command(self):
return self.data_dict['_prefix']['command']
# 获取回复
def get_reply(self):
return self.data_dict['reply']
# 获取回复对象的文本
# 获取命令参数
def get_command_arg(self):
command_arg_list = self.data_dict['_prefix']['command_arg']
if command_arg_list:
command_arg = command_arg_list[0]
if isinstance(command_arg, MessageSegment):
if command_arg.type == 'text':
return TextMessage(command_arg.data['text'])
elif command_arg.type == 'image':
return ImageMessage(command_arg.data['url'])
return None # 返回 None 表示命令参数为空或无法解析