mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-20 17:46:51 +08:00
commit
3ea2c27e17
@ -1,4 +1,4 @@
|
||||
[
|
||||
"2.0.0a8.post1",
|
||||
"2.0.0a8.post2",
|
||||
"2.0.0a7"
|
||||
]
|
@ -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!")
|
||||
|
@ -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",
|
||||
|
@ -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 <yanyongyu_1@126.com>"]
|
||||
license = "MIT"
|
||||
|
Loading…
x
Reference in New Issue
Block a user