🔀 Merge pull request #9 from nonebot/dev

This commit is contained in:
Ju4tCode 2020-09-08 17:01:15 +08:00 committed by GitHub
commit b4d7fded7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View File

@ -3,6 +3,7 @@
import hmac
import json
import asyncio
import logging
import uvicorn
@ -151,7 +152,7 @@ class Driver(BaseDriver):
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail="adapter not found")
await bot.handle_message(data)
asyncio.create_task(bot.handle_message(data))
return Response("", 204)
@overrides(BaseDriver)
@ -203,7 +204,7 @@ class Driver(BaseDriver):
if not data:
continue
await bot.handle_message(data)
asyncio.create_task(bot.handle_message(data))
finally:
del self._clients[x_self_id]

View File

@ -60,9 +60,15 @@ class TrieRule:
def get_value(cls, bot: Bot, event: Event,
state: dict) -> Tuple[Dict[str, Any], Dict[str, Any]]:
if event.type != "message":
state["_prefix"] = {}
state["_suffix"] = {}
return {}, {}
state["_prefix"] = {"raw_command": None, "command": None}
state["_suffix"] = {"raw_command": None, "command": None}
return {
"raw_command": None,
"command": None
}, {
"raw_command": None,
"command": None
}
prefix = None
suffix = None
@ -77,19 +83,31 @@ class TrieRule:
state["_prefix"] = {
"raw_command": prefix.key,
"command": prefix.value
} if prefix else {}
} if prefix else {
"raw_command": None,
"command": None
}
state["_suffix"] = {
"raw_command": suffix.key,
"command": suffix.value
} if suffix else {}
} if suffix else {
"raw_command": None,
"command": None
}
return ({
"raw_command": prefix.key,
"command": prefix.value
} if prefix else {}, {
} if prefix else {
"raw_command": None,
"command": None
}, {
"raw_command": suffix.key,
"command": suffix.value
} if suffix else {})
} if suffix else {
"raw_command": None,
"command": None
})
def startswith(msg: str) -> Rule: