Skip to content

Commit

Permalink
Revert "u"
Browse files Browse the repository at this point in the history
This reverts commit 6237e18.
  • Loading branch information
DoroWolf committed Sep 20, 2024
1 parent 6237e18 commit b782370
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bots/aiocqhttp/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def message_handler(event: Event):
return await bot.send(event, Locale(default_locale).t('qq.prompt.disable_temp_session'))
if event.user_id in ignore_ids:
return

if string_post:
filter_msg = re.match(r'.*?\[CQ:(?:json|xml).*?\].*?|.*?<\?xml.*?>.*?', event.message, re.MULTILINE | re.DOTALL)
if filter_msg:
Expand All @@ -63,17 +63,21 @@ async def message_handler(event: Event):
else:
return
else:
if event.message[0]["type"] in ["json", "xml"]:
filter_msg = False
for item in event.message:
if re.match(r'.*?<\?xml.*?>.*?', item["data"].get("text", ""), re.MULTILINE | re.DOTALL):
filter_msg = True
if event.message[0]["type"] in ["json", "xml"] or filter_msg:
match_json = event.message[0]["type"] == "json"
if match_json:
load_json = json.loads(html.unescape(event.message[0]["data"]["data"]))
if load_json['app'] == 'com.tencent.multimsg':
event.message = [{"type": "forward", "data": {"id": f"{load_json["meta"]["detail"]["resid"]}"}}]
event.message = [{"type": "forward","data": {"id": f"{load_json["meta"]["detail"]["resid"]}"}}]
else:
return
else:
return

reply_id = None
if string_post:
match_reply = re.match(r'^\[CQ:reply,id=(-?\d+).*\].*', event.message)
Expand All @@ -82,7 +86,7 @@ async def message_handler(event: Event):
else:
if event.message[0]["type"] == "reply":
reply_id = int(event.message[0]["data"]["id"])

prefix = None
if string_post:
if match_at := re.match(r'^\[CQ:at,qq=(\d+).*\](.*)', event.message):
Expand All @@ -97,7 +101,7 @@ async def message_handler(event: Event):
event.message = event.message[1:]
if not event.message:
event.message = [{"type": "text", "data": {"text": "help"}}]
prefix = ['']
prefix = ['']

target_id = f'Group|{str(event.group_id)}' if event.detail_type == 'group' else f'Private|{str(event.user_id)}'

Expand Down

0 comments on commit b782370

Please sign in to comment.