diff --git a/archive/2.0.0a8.post1/README.md b/archive/2.0.0a8.post2/README.md similarity index 100% rename from archive/2.0.0a8.post1/README.md rename to archive/2.0.0a8.post2/README.md diff --git a/archive/2.0.0a8.post1/advanced/README.md b/archive/2.0.0a8.post2/advanced/README.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/README.md rename to archive/2.0.0a8.post2/advanced/README.md diff --git a/archive/2.0.0a8.post1/advanced/export-and-require.md b/archive/2.0.0a8.post2/advanced/export-and-require.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/export-and-require.md rename to archive/2.0.0a8.post2/advanced/export-and-require.md diff --git a/archive/2.0.0a8.post1/advanced/overloaded-handlers.md b/archive/2.0.0a8.post2/advanced/overloaded-handlers.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/overloaded-handlers.md rename to archive/2.0.0a8.post2/advanced/overloaded-handlers.md diff --git a/archive/2.0.0a8.post1/advanced/permission.md b/archive/2.0.0a8.post2/advanced/permission.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/permission.md rename to archive/2.0.0a8.post2/advanced/permission.md diff --git a/archive/2.0.0a8.post1/advanced/publish-plugin.md b/archive/2.0.0a8.post2/advanced/publish-plugin.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/publish-plugin.md rename to archive/2.0.0a8.post2/advanced/publish-plugin.md diff --git a/archive/2.0.0a8.post1/advanced/runtime-hook.md b/archive/2.0.0a8.post2/advanced/runtime-hook.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/runtime-hook.md rename to archive/2.0.0a8.post2/advanced/runtime-hook.md diff --git a/archive/2.0.0a8.post1/advanced/scheduler.md b/archive/2.0.0a8.post2/advanced/scheduler.md similarity index 100% rename from archive/2.0.0a8.post1/advanced/scheduler.md rename to archive/2.0.0a8.post2/advanced/scheduler.md diff --git a/archive/2.0.0a8.post1/api/README.md b/archive/2.0.0a8.post2/api/README.md similarity index 100% rename from archive/2.0.0a8.post1/api/README.md rename to archive/2.0.0a8.post2/api/README.md diff --git a/archive/2.0.0a8.post1/api/adapters/README.md b/archive/2.0.0a8.post2/api/adapters/README.md similarity index 100% rename from archive/2.0.0a8.post1/api/adapters/README.md rename to archive/2.0.0a8.post2/api/adapters/README.md diff --git a/archive/2.0.0a8.post1/api/adapters/cqhttp.md b/archive/2.0.0a8.post2/api/adapters/cqhttp.md similarity index 100% rename from archive/2.0.0a8.post1/api/adapters/cqhttp.md rename to archive/2.0.0a8.post2/api/adapters/cqhttp.md diff --git a/archive/2.0.0a8.post1/api/adapters/ding.md b/archive/2.0.0a8.post2/api/adapters/ding.md similarity index 100% rename from archive/2.0.0a8.post1/api/adapters/ding.md rename to archive/2.0.0a8.post2/api/adapters/ding.md diff --git a/archive/2.0.0a8.post1/api/config.md b/archive/2.0.0a8.post2/api/config.md similarity index 100% rename from archive/2.0.0a8.post1/api/config.md rename to archive/2.0.0a8.post2/api/config.md diff --git a/archive/2.0.0a8.post1/api/drivers/README.md b/archive/2.0.0a8.post2/api/drivers/README.md similarity index 100% rename from archive/2.0.0a8.post1/api/drivers/README.md rename to archive/2.0.0a8.post2/api/drivers/README.md diff --git a/archive/2.0.0a8.post1/api/drivers/fastapi.md b/archive/2.0.0a8.post2/api/drivers/fastapi.md similarity index 100% rename from archive/2.0.0a8.post1/api/drivers/fastapi.md rename to archive/2.0.0a8.post2/api/drivers/fastapi.md diff --git a/archive/2.0.0a8.post1/api/exception.md b/archive/2.0.0a8.post2/api/exception.md similarity index 100% rename from archive/2.0.0a8.post1/api/exception.md rename to archive/2.0.0a8.post2/api/exception.md diff --git a/archive/2.0.0a8.post1/api/log.md b/archive/2.0.0a8.post2/api/log.md similarity index 100% rename from archive/2.0.0a8.post1/api/log.md rename to archive/2.0.0a8.post2/api/log.md diff --git a/archive/2.0.0a8.post1/api/matcher.md b/archive/2.0.0a8.post2/api/matcher.md similarity index 100% rename from archive/2.0.0a8.post1/api/matcher.md rename to archive/2.0.0a8.post2/api/matcher.md diff --git a/archive/2.0.0a8.post1/api/message.md b/archive/2.0.0a8.post2/api/message.md similarity index 100% rename from archive/2.0.0a8.post1/api/message.md rename to archive/2.0.0a8.post2/api/message.md diff --git a/archive/2.0.0a8.post1/api/nonebot.md b/archive/2.0.0a8.post2/api/nonebot.md similarity index 100% rename from archive/2.0.0a8.post1/api/nonebot.md rename to archive/2.0.0a8.post2/api/nonebot.md diff --git a/archive/2.0.0a8.post1/api/permission.md b/archive/2.0.0a8.post2/api/permission.md similarity index 100% rename from archive/2.0.0a8.post1/api/permission.md rename to archive/2.0.0a8.post2/api/permission.md diff --git a/archive/2.0.0a8.post1/api/plugin.md b/archive/2.0.0a8.post2/api/plugin.md similarity index 100% rename from archive/2.0.0a8.post1/api/plugin.md rename to archive/2.0.0a8.post2/api/plugin.md diff --git a/archive/2.0.0a8.post1/api/rule.md b/archive/2.0.0a8.post2/api/rule.md similarity index 100% rename from archive/2.0.0a8.post1/api/rule.md rename to archive/2.0.0a8.post2/api/rule.md diff --git a/archive/2.0.0a8.post1/api/typing.md b/archive/2.0.0a8.post2/api/typing.md similarity index 100% rename from archive/2.0.0a8.post1/api/typing.md rename to archive/2.0.0a8.post2/api/typing.md diff --git a/archive/2.0.0a8.post1/api/utils.md b/archive/2.0.0a8.post2/api/utils.md similarity index 100% rename from archive/2.0.0a8.post1/api/utils.md rename to archive/2.0.0a8.post2/api/utils.md diff --git a/archive/2.0.0a8.post1/guide/README.md b/archive/2.0.0a8.post2/guide/README.md similarity index 100% rename from archive/2.0.0a8.post1/guide/README.md rename to archive/2.0.0a8.post2/guide/README.md diff --git a/archive/2.0.0a8.post1/guide/basic-configuration.md b/archive/2.0.0a8.post2/guide/basic-configuration.md similarity index 100% rename from archive/2.0.0a8.post1/guide/basic-configuration.md rename to archive/2.0.0a8.post2/guide/basic-configuration.md diff --git a/archive/2.0.0a8.post1/guide/cqhttp-guide.md b/archive/2.0.0a8.post2/guide/cqhttp-guide.md similarity index 100% rename from archive/2.0.0a8.post1/guide/cqhttp-guide.md rename to archive/2.0.0a8.post2/guide/cqhttp-guide.md diff --git a/archive/2.0.0a8.post1/guide/creating-a-handler.md b/archive/2.0.0a8.post2/guide/creating-a-handler.md similarity index 100% rename from archive/2.0.0a8.post1/guide/creating-a-handler.md rename to archive/2.0.0a8.post2/guide/creating-a-handler.md diff --git a/archive/2.0.0a8.post1/guide/creating-a-matcher.md b/archive/2.0.0a8.post2/guide/creating-a-matcher.md similarity index 100% rename from archive/2.0.0a8.post1/guide/creating-a-matcher.md rename to archive/2.0.0a8.post2/guide/creating-a-matcher.md diff --git a/archive/2.0.0a8.post1/guide/creating-a-plugin.md b/archive/2.0.0a8.post2/guide/creating-a-plugin.md similarity index 100% rename from archive/2.0.0a8.post1/guide/creating-a-plugin.md rename to archive/2.0.0a8.post2/guide/creating-a-plugin.md diff --git a/archive/2.0.0a8.post1/guide/creating-a-project.md b/archive/2.0.0a8.post2/guide/creating-a-project.md similarity index 100% rename from archive/2.0.0a8.post1/guide/creating-a-project.md rename to archive/2.0.0a8.post2/guide/creating-a-project.md diff --git a/archive/2.0.0a8.post1/guide/ding-guide.md b/archive/2.0.0a8.post2/guide/ding-guide.md similarity index 100% rename from archive/2.0.0a8.post1/guide/ding-guide.md rename to archive/2.0.0a8.post2/guide/ding-guide.md diff --git a/archive/2.0.0a8.post1/guide/end-or-start.md b/archive/2.0.0a8.post2/guide/end-or-start.md similarity index 100% rename from archive/2.0.0a8.post1/guide/end-or-start.md rename to archive/2.0.0a8.post2/guide/end-or-start.md diff --git a/archive/2.0.0a8.post1/guide/getting-started.md b/archive/2.0.0a8.post2/guide/getting-started.md similarity index 100% rename from archive/2.0.0a8.post1/guide/getting-started.md rename to archive/2.0.0a8.post2/guide/getting-started.md diff --git a/archive/2.0.0a8.post1/guide/installation.md b/archive/2.0.0a8.post2/guide/installation.md similarity index 100% rename from archive/2.0.0a8.post1/guide/installation.md rename to archive/2.0.0a8.post2/guide/installation.md diff --git a/archive/2.0.0a8.post1/guide/loading-a-plugin.md b/archive/2.0.0a8.post2/guide/loading-a-plugin.md similarity index 100% rename from archive/2.0.0a8.post1/guide/loading-a-plugin.md rename to archive/2.0.0a8.post2/guide/loading-a-plugin.md diff --git a/archive/2.0.0a8.post1/sidebar.config.json b/archive/2.0.0a8.post2/sidebar.config.json similarity index 100% rename from archive/2.0.0a8.post1/sidebar.config.json rename to archive/2.0.0a8.post2/sidebar.config.json diff --git a/docs/.vuepress/versions.json b/docs/.vuepress/versions.json index 361c0744..6ae5e41b 100644 --- a/docs/.vuepress/versions.json +++ b/docs/.vuepress/versions.json @@ -1,4 +1,4 @@ [ - "2.0.0a8.post1", + "2.0.0a8.post2", "2.0.0a7" ] \ No newline at end of file diff --git a/nonebot/adapters/cqhttp/bot.py b/nonebot/adapters/cqhttp/bot.py index aa2783f3..1aff6d5d 100644 --- a/nonebot/adapters/cqhttp/bot.py +++ b/nonebot/adapters/cqhttp/bot.py @@ -421,19 +421,19 @@ class Bot(BaseBot): message = escape(message) if isinstance(message, str) else message msg = message if isinstance(message, Message) else Message(message) - at_sender = at_sender and hasattr(event, "user_id") + at_sender = at_sender and getattr(event, "user_id", None) params = {} - if hasattr(event, "user_id"): + if getattr(event, "user_id", None): params["user_id"] = getattr(event, "user_id") - if hasattr(event, "group_id"): + if getattr(event, "group_id", None): params["group_id"] = getattr(event, "group_id") params.update(kwargs) if "message_type" not in params: - if "group_id" in params: + if params.get("group_id", None): params["message_type"] = "group" - elif "user_id" in params: + elif params.get("user_id", None): params["message_type"] = "private" else: raise ValueError("Cannot guess message type to reply!") diff --git a/nonebot/message.py b/nonebot/message.py index 5b3c8b6f..c6974b2c 100644 --- a/nonebot/message.py +++ b/nonebot/message.py @@ -117,8 +117,7 @@ async def _check_matcher(priority: int, bot: "Bot", event: "Event", return None async def _check_expire(Matcher: Type[Matcher]) -> Optional[Type[Matcher]]: - if Matcher.temp or (Matcher.expire_time and - datetime.now() > Matcher.expire_time): + if Matcher.expire_time and datetime.now() > Matcher.expire_time: return Matcher return None @@ -128,14 +127,19 @@ async def _check_matcher(priority: int, bot: "Bot", event: "Event", checking_expire_tasks = [ _check_expire(Matcher) for Matcher in current_matchers ] - results = await asyncio.gather(*checking_tasks, return_exceptions=True) + results = await asyncio.gather(*checking_tasks) expired = await asyncio.gather(*checking_expire_tasks) for expired_matcher in filter(lambda x: x, expired): try: matchers[priority].remove(expired_matcher) # type: ignore except Exception: pass - return filter(lambda x: x, results) + for temp_matcher in filter(lambda x: x and x.temp, results): + try: + matchers[priority].remove(temp_matcher) # type: ignore + except Exception: + pass + return filter(lambda x: x, results) # type: ignore async def _run_matcher(Matcher: Type[Matcher], bot: "Bot", event: "Event", diff --git a/pyproject.toml b/pyproject.toml index e3de0817..23f8e799 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nonebot2" -version = "2.0.0-alpha.8.post1" +version = "2.0.0-alpha.8.post2" description = "An asynchronous python bot framework." authors = ["yanyongyu "] license = "MIT"