🔀 Merge pull request #64

修复了at机器人时的IndexError
This commit is contained in:
Ju4tCode 2020-11-19 14:46:57 +08:00 committed by GitHub
commit 73ce79472e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,7 +112,8 @@ async def _check_reply(bot: "Bot", event: "Event"):
return
msg_seg = event.message[index]
event.reply = await bot.get_msg(message_id=msg_seg.data["id"])
if event.reply["sender"]["user_id"] == event.self_id:
# ensure string comparation
if str(event.reply["sender"]["user_id"]) == str(event.self_id):
event.to_me = True
del event.message[index]
if not event.message:
@ -142,14 +143,14 @@ def _check_at_me(bot: "Bot", event: "Event"):
if event.message[0] == at_me_seg:
event.to_me = True
del event.message[0]
if event.message[0].type == "text":
if event.message and 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 event.message[0] == at_me_seg:
if event.message and event.message[0] == at_me_seg:
del event.message[0]
if event.message[0].type == "text":
if event.message and event.message[0].type == "text":
event.message[0].data["text"] = event.message[0].data[
"text"].lstrip()
if not event.message[0].data["text"]: