mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-01 01:25:07 +08:00
🚧 update cqhttp event parse
This commit is contained in:
parent
783efeaf0e
commit
a57cd396fa
@ -302,7 +302,7 @@ class Bot(BaseBot):
|
|||||||
detail_type = f".{detail_type}" if detail_type else ""
|
detail_type = f".{detail_type}" if detail_type else ""
|
||||||
sub_type = message.get("sub_type")
|
sub_type = message.get("sub_type")
|
||||||
sub_type = f".{sub_type}" if sub_type else ""
|
sub_type = f".{sub_type}" if sub_type else ""
|
||||||
models = get_event_model(f".{post_type}{detail_type}{sub_type}")
|
models = get_event_model(post_type + detail_type + sub_type)
|
||||||
for model in models:
|
for model in models:
|
||||||
try:
|
try:
|
||||||
event = model.parse_obj(message)
|
event = model.parse_obj(message)
|
||||||
|
@ -237,6 +237,10 @@ class CQHTTPEvent(Event):
|
|||||||
def get_plaintext(self) -> str:
|
def get_plaintext(self) -> str:
|
||||||
raise ValueError("Event has no message!")
|
raise ValueError("Event has no message!")
|
||||||
|
|
||||||
|
@overrides(Event)
|
||||||
|
def get_session_id(self) -> str:
|
||||||
|
raise ValueError("Event has no message!")
|
||||||
|
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
class Sender(BaseModel):
|
class Sender(BaseModel):
|
||||||
@ -322,6 +326,10 @@ class MessageEvent(CQHTTPEvent):
|
|||||||
def get_plaintext(self) -> str:
|
def get_plaintext(self) -> str:
|
||||||
return self.message.extract_plain_text()
|
return self.message.extract_plain_text()
|
||||||
|
|
||||||
|
@overrides(CQHTTPEvent)
|
||||||
|
def get_session_id(self) -> str:
|
||||||
|
return str(self.user_id)
|
||||||
|
|
||||||
|
|
||||||
class PrivateMessageEvent(MessageEvent):
|
class PrivateMessageEvent(MessageEvent):
|
||||||
__event__ = "message.private"
|
__event__ = "message.private"
|
||||||
|
Loading…
Reference in New Issue
Block a user