mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 08:12:14 +08:00
🔀 Merge pull request #9 from nonebot/dev
This commit is contained in:
commit
b4d7fded7f
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import hmac
|
import hmac
|
||||||
import json
|
import json
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
@ -151,7 +152,7 @@ class Driver(BaseDriver):
|
|||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail="adapter not found")
|
detail="adapter not found")
|
||||||
|
|
||||||
await bot.handle_message(data)
|
asyncio.create_task(bot.handle_message(data))
|
||||||
return Response("", 204)
|
return Response("", 204)
|
||||||
|
|
||||||
@overrides(BaseDriver)
|
@overrides(BaseDriver)
|
||||||
@ -203,7 +204,7 @@ class Driver(BaseDriver):
|
|||||||
if not data:
|
if not data:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
await bot.handle_message(data)
|
asyncio.create_task(bot.handle_message(data))
|
||||||
finally:
|
finally:
|
||||||
del self._clients[x_self_id]
|
del self._clients[x_self_id]
|
||||||
|
|
||||||
|
@ -60,9 +60,15 @@ class TrieRule:
|
|||||||
def get_value(cls, bot: Bot, event: Event,
|
def get_value(cls, bot: Bot, event: Event,
|
||||||
state: dict) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
state: dict) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
||||||
if event.type != "message":
|
if event.type != "message":
|
||||||
state["_prefix"] = {}
|
state["_prefix"] = {"raw_command": None, "command": None}
|
||||||
state["_suffix"] = {}
|
state["_suffix"] = {"raw_command": None, "command": None}
|
||||||
return {}, {}
|
return {
|
||||||
|
"raw_command": None,
|
||||||
|
"command": None
|
||||||
|
}, {
|
||||||
|
"raw_command": None,
|
||||||
|
"command": None
|
||||||
|
}
|
||||||
|
|
||||||
prefix = None
|
prefix = None
|
||||||
suffix = None
|
suffix = None
|
||||||
@ -77,19 +83,31 @@ class TrieRule:
|
|||||||
state["_prefix"] = {
|
state["_prefix"] = {
|
||||||
"raw_command": prefix.key,
|
"raw_command": prefix.key,
|
||||||
"command": prefix.value
|
"command": prefix.value
|
||||||
} if prefix else {}
|
} if prefix else {
|
||||||
|
"raw_command": None,
|
||||||
|
"command": None
|
||||||
|
}
|
||||||
state["_suffix"] = {
|
state["_suffix"] = {
|
||||||
"raw_command": suffix.key,
|
"raw_command": suffix.key,
|
||||||
"command": suffix.value
|
"command": suffix.value
|
||||||
} if suffix else {}
|
} if suffix else {
|
||||||
|
"raw_command": None,
|
||||||
|
"command": None
|
||||||
|
}
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
"raw_command": prefix.key,
|
"raw_command": prefix.key,
|
||||||
"command": prefix.value
|
"command": prefix.value
|
||||||
} if prefix else {}, {
|
} if prefix else {
|
||||||
|
"raw_command": None,
|
||||||
|
"command": None
|
||||||
|
}, {
|
||||||
"raw_command": suffix.key,
|
"raw_command": suffix.key,
|
||||||
"command": suffix.value
|
"command": suffix.value
|
||||||
} if suffix else {})
|
} if suffix else {
|
||||||
|
"raw_command": None,
|
||||||
|
"command": None
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def startswith(msg: str) -> Rule:
|
def startswith(msg: str) -> Rule:
|
||||||
|
Loading…
Reference in New Issue
Block a user