nonebot-adapter-qq 1.4.4__tar.gz → 1.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/PKG-INFO +2 -3
  2. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/adapter.py +6 -2
  3. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/event.py +3 -0
  4. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/message.py +4 -0
  5. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/models/payload.py +2 -1
  6. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/pyproject.toml +3 -3
  7. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/LICENSE +0 -0
  8. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/README.md +0 -0
  9. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/__init__.py +0 -0
  10. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/bot.py +4 -4
  11. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/compat.py +0 -0
  12. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/config.py +0 -0
  13. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/exception.py +0 -0
  14. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/models/__init__.py +0 -0
  15. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/models/common.py +0 -0
  16. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/models/guild.py +0 -0
  17. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/models/qq.py +0 -0
  18. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/permission.py +0 -0
  19. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/store.py +0 -0
  20. {nonebot_adapter_qq-1.4.4 → nonebot_adapter_qq-1.5.1}/nonebot/adapters/qq/utils.py +0 -0
@@ -1,20 +1,19 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-adapter-qq
3
- Version: 1.4.4
3
+ Version: 1.5.1
4
4
  Summary: QQ adapter for nonebot2
5
5
  Home-page: https://github.com/nonebot/adapter-qq
6
6
  License: MIT
7
7
  Keywords: bot,qq,qqbot,qqguild
8
8
  Author: yanyongyu
9
9
  Author-email: yyy@nonebot.dev
10
- Requires-Python: >=3.8,<4.0
10
+ Requires-Python: >=3.9,<4.0
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Framework :: Robot Framework
13
13
  Classifier: Framework :: Robot Framework :: Library
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Operating System :: OS Independent
16
16
  Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
17
  Classifier: Programming Language :: Python :: 3.9
19
18
  Classifier: Programming Language :: Python :: 3.10
20
19
  Classifier: Programming Language :: Python :: 3.11
@@ -405,10 +405,14 @@ class Adapter(BaseAdapter):
405
405
  EventClass = EVENT_CLASSES.get(payload.type, None)
406
406
  if EventClass is None:
407
407
  log("WARNING", f"Unknown payload type: {payload.type}")
408
- event = type_validate_python(Event, payload.data)
408
+ event = type_validate_python(
409
+ Event, {"event_id": payload.id, **payload.data}
410
+ )
409
411
  event.__type__ = payload.type # type: ignore
410
412
  return event
411
- return type_validate_python(EventClass, payload.data)
413
+ return type_validate_python(
414
+ EventClass, {"event_id": payload.id, **payload.data}
415
+ )
412
416
 
413
417
  @override
414
418
  async def _call_api(self, bot: Bot, api: str, **data: Any) -> Any:
@@ -117,6 +117,9 @@ class EventType(str, Enum):
117
117
  class Event(BaseEvent):
118
118
  __type__: EventType
119
119
 
120
+ # event id from payload id
121
+ event_id: Optional[str] = None
122
+
120
123
  @override
121
124
  def get_event_name(self) -> str:
122
125
  return self.__type__
@@ -428,3 +428,7 @@ class Message(BaseMessage[MessageSegment]):
428
428
  if seg.type
429
429
  in ("text", "emoji", "mention_user", "mention_everyone", "mention_channel")
430
430
  )
431
+
432
+ @override
433
+ def extract_plain_text(self) -> str:
434
+ return "".join(seg.data["text"] for seg in self if seg.is_text())
@@ -1,5 +1,5 @@
1
1
  from enum import IntEnum
2
- from typing import Tuple, Union
2
+ from typing import Tuple, Union, Optional
3
3
  from typing_extensions import Literal, Annotated
4
4
 
5
5
  from pydantic import Field, BaseModel
@@ -43,6 +43,7 @@ class Dispatch(Payload):
43
43
  data: dict
44
44
  sequence: int
45
45
  type: str
46
+ id: Optional[str] = None
46
47
 
47
48
 
48
49
  class Heartbeat(Payload):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nonebot-adapter-qq"
3
- version = "1.4.4"
3
+ version = "1.5.1"
4
4
  description = "QQ adapter for nonebot2"
5
5
  authors = ["yanyongyu <yyy@nonebot.dev>"]
6
6
  license = "MIT"
@@ -19,14 +19,14 @@ classifiers = [
19
19
  packages = [{ include = "nonebot" }]
20
20
 
21
21
  [tool.poetry.dependencies]
22
- python = "^3.8"
22
+ python = "^3.9"
23
23
  yarl = "^1.9.0"
24
24
  nonebot2 = "^2.2.1"
25
25
  typing-extensions = ">=4.4.0, <5.0.0"
26
26
  pydantic = ">=1.10.0,<3.0.0,!=2.5.0,!=2.5.1"
27
27
 
28
28
  [tool.poetry.group.dev.dependencies]
29
- ruff = "^0.4.0"
29
+ ruff = "^0.6.0"
30
30
  isort = "^5.10.1"
31
31
  black = "^24.0.0"
32
32
  nonemoji = "^0.1.3"
@@ -327,12 +327,12 @@ class Bot(BaseBot):
327
327
  elif file_image := message["file_image"]:
328
328
  kwargs["file_type"] = 1
329
329
  kwargs["file_data"] = file_image[-1].data["content"]
330
- elif file_audio := message["file_audio"]:
331
- kwargs["file_type"] = 2
332
- kwargs["file_data"] = file_audio[-1].data["content"]
333
330
  elif file_video := message["file_video"]:
334
- kwargs["file_type"] = 3
331
+ kwargs["file_type"] = 2
335
332
  kwargs["file_data"] = file_video[-1].data["content"]
333
+ elif file_audio := message["file_audio"]:
334
+ kwargs["file_type"] = 3
335
+ kwargs["file_data"] = file_audio[-1].data["content"]
336
336
  elif file_file := message["file_file"]:
337
337
  kwargs["file_type"] = 4
338
338
  kwargs["file_data"] = file_file[-1].data["content"]