Skip to content

Commit

Permalink
🔀 Merge pull request #138
Browse files Browse the repository at this point in the history
PreRelease 2.0.0a8.post2
  • Loading branch information
yanyongyu authored Jan 2, 2021
2 parents f036057 + 17960b2 commit 3ea2c27
Show file tree
Hide file tree
Showing 42 changed files with 15 additions and 11 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/.vuepress/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
"2.0.0a8.post1",
"2.0.0a8.post2",
"2.0.0a7"
]
10 changes: 5 additions & 5 deletions nonebot/adapters/cqhttp/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,19 @@ async def send(self,
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!")
Expand Down
12 changes: 8 additions & 4 deletions nonebot/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ async def _check(Matcher: Type[Matcher], 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

Expand All @@ -128,14 +127,19 @@ async def _check_expire(Matcher: Type[Matcher]) -> Optional[Type[Matcher]]:
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",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 3ea2c27

Please sign in to comment.