mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-31 15:41:34 +08:00
🐛 fix reply
This commit is contained in:
parent
f79eabdc61
commit
b36acc94f1
@ -61,13 +61,16 @@ async def _check_reply(bot: "Bot", event: "Event"):
|
|||||||
if event.type != "message":
|
if event.type != "message":
|
||||||
return
|
return
|
||||||
|
|
||||||
first_msg_seg = event.message[0]
|
try:
|
||||||
if first_msg_seg.type == "reply":
|
index = list(map(lambda x: x.type == "reply",
|
||||||
msg_id = first_msg_seg.data["id"]
|
event.message)).index(True)
|
||||||
event.reply = await bot.get_msg(message_id=msg_id)
|
except ValueError:
|
||||||
if event.reply["sender"]["user_id"] == event.self_id:
|
return
|
||||||
event.to_me = True
|
msg_seg = event.message[index]
|
||||||
del event.message[0]
|
event.reply = await bot.get_msg(message_id=msg_seg.data["id"])
|
||||||
|
if event.reply["sender"]["user_id"] == event.self_id:
|
||||||
|
event.to_me = True
|
||||||
|
del event.message[index]
|
||||||
|
|
||||||
|
|
||||||
def _check_at_me(bot: "Bot", event: "Event"):
|
def _check_at_me(bot: "Bot", event: "Event"):
|
||||||
@ -87,6 +90,15 @@ def _check_at_me(bot: "Bot", event: "Event"):
|
|||||||
if event.message[0].type == "text":
|
if event.message[0].type == "text":
|
||||||
event.message[0].data["text"] = event.message[0].data[
|
event.message[0].data["text"] = event.message[0].data[
|
||||||
"text"].lstrip()
|
"text"].lstrip()
|
||||||
|
if not event.message[0].data["text"]:
|
||||||
|
del event.message[0]
|
||||||
|
if event.message[0] == at_me_seg:
|
||||||
|
del event.message[0]
|
||||||
|
if event.message[0].type == "text":
|
||||||
|
event.message[0].data["text"] = event.message[0].data[
|
||||||
|
"text"].lstrip()
|
||||||
|
if not event.message[0].data["text"]:
|
||||||
|
del event.message[0]
|
||||||
|
|
||||||
if not event.to_me:
|
if not event.to_me:
|
||||||
# check the last segment
|
# check the last segment
|
||||||
|
Loading…
x
Reference in New Issue
Block a user