🔀 Merge pull request #300

Fix: mirai empty message chain when check at
This commit is contained in:
Ju4tCode 2021-03-30 02:55:02 -05:00 committed by GitHub
commit 5db819738e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -214,5 +214,21 @@
"desc": "基于 import hook 的插件管理",
"author": "Jigsaw111",
"repo": "Jigsaw111/nonebot_plugin_manager"
},
{
"id": "nonebot_plugin_analysis_bilibili",
"link": "nonebot-plugin-analysis-bilibili",
"name": "bilibili视频、番剧解析",
"desc": "自动解析bilibili视频、番剧解析",
"author": "mengshouer",
"repo": "mengshouer/nonebot_plugin_analysis_bilibili"
},
{
"id": "nonebot_plugin_localstore",
"link": "nonebot-plugin-localstore",
"name": "本地数据存储",
"desc": "存储插件数据至本地文件",
"author": "yanyongyu",
"repo": "nonebot/plugin-localstore"
}
]

View File

@ -11,7 +11,7 @@ from nonebot.message import handle_event
from nonebot.utils import escape_tag, logger_wrapper
from .event import Event, GroupMessage, MessageEvent, MessageSource
from .message import MessageType
from .message import MessageType, MessageSegment
if TYPE_CHECKING:
from .bot import Bot
@ -64,7 +64,7 @@ class ActionFailed(exception.ActionFailed):
class InvalidArgument(exception.AdapterException):
"""
:说明:
调用API的参数出错
"""
@ -106,7 +106,7 @@ def argument_validation(function: _AnyCallable) -> _AnyCallable:
:说明:
通过函数签名中的类型注解来对传入参数进行运行时校验
会在参数出错时释放 ``InvalidArgument`` 异常
"""
function = validate_arguments(config={
@ -138,6 +138,8 @@ def process_at(bot: "Bot", event: GroupMessage) -> GroupMessage:
event.to_me = True
else:
event.message_chain.insert(0, at)
if not event.message_chain:
event.message_chain.append(MessageSegment.plain(''))
return event
@ -175,4 +177,4 @@ async def process_event(bot: "Bot", event: Event) -> None:
event = process_nick(bot, event)
event = process_at(bot, event)
event = process_reply(bot, event)
await handle_event(bot, event)
await handle_event(bot, event)