mirror of
https://github.com/snowy-yang/qqbotsdk.git
synced 2026-10-21 10:08:50 +00:00
feat: 按钮快捷构造、event_id 语义修正与 TokenError
This commit is contained in:
1 parent
cff0c142c2
commit
097bc96d8b
16 files changed
+431
-35
No files matched your search
@@ -3,6 +3,7 @@ from qqbotsdk.model import Opcode
|
||||
from qqbotsdk.payloads import (
|
||||
C2CMessage,
|
||||
GroupAtMessage,
|
||||
Interaction,
|
||||
Ready,
|
||||
parse_event,
|
||||
)
|
||||
@@ -62,6 +63,27 @@ def test_parse_non_dict_d_returns_dict():
|
||||
assert parse_event("GROUP_AT_MESSAGE_CREATE", d) == 42
|
||||
|
||||
|
||||
def test_interaction_button_data():
|
||||
inter = parse_event(
|
||||
"INTERACTION_CREATE",
|
||||
{
|
||||
"id": "i1",
|
||||
"chat_type": 1,
|
||||
"group_openid": "G1",
|
||||
"data": {"resolved": {"button_data": "btn|like"}},
|
||||
},
|
||||
)
|
||||
assert isinstance(inter, Interaction)
|
||||
assert inter.button_data == "btn|like"
|
||||
|
||||
|
||||
def test_interaction_button_data_defaults_to_empty():
|
||||
inter = Interaction(id="i2", data=None)
|
||||
assert inter.button_data == ""
|
||||
inter = Interaction(id="i3", data={"resolved": None})
|
||||
assert inter.button_data == ""
|
||||
|
||||
|
||||
async def test_typed_annotation_receives_dataclass():
|
||||
queue = EventQueue()
|
||||
emitter = EventEmitter(queue)
|
||||
|
||||
Reference in new issue
Block a user