mirror of https://github.com/Mai-with-u/MaiBot.git
提高健壮性
parent
d0df05d60c
commit
8c346377cb
|
|
@ -80,7 +80,10 @@ class MessageRecv(Message):
|
||||||
pattern = r'\[CQ:json,data=(?P<json_data>.+?)\]'
|
pattern = r'\[CQ:json,data=(?P<json_data>.+?)\]'
|
||||||
match = re.search(pattern, message_dict.get('raw_message',''))
|
match = re.search(pattern, message_dict.get('raw_message',''))
|
||||||
raw_json = html.unescape(match.group('json_data'))
|
raw_json = html.unescape(match.group('json_data'))
|
||||||
json_message = json.loads(raw_json)
|
try:
|
||||||
|
json_message = json.loads(raw_json)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
json_message = {}
|
||||||
message_segment['data'] = json_message.get('prompt','')
|
message_segment['data'] = json_message.get('prompt','')
|
||||||
|
|
||||||
self.message_segment = Seg.from_dict(message_dict.get('message_segment', {}))
|
self.message_segment = Seg.from_dict(message_dict.get('message_segment', {}))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue