onebot-protocol 0.0.2__py3-none-any.whl

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.
@@ -0,0 +1,27 @@
1
+ from .models import (
2
+ MessagePayload,
3
+ MessageSegment,
4
+ TextMessageSegment,
5
+ MentionMessageSegment,
6
+ MentionAllMessageSegment,
7
+ ImageMessageSegment,
8
+ VoiceMessageSegment,
9
+ AudioMessageSegment,
10
+ VideoMessageSegment,
11
+ FileMessageSegment,
12
+ LocationMessageSegment,
13
+ )
14
+
15
+ __all__ = [
16
+ "MessagePayload",
17
+ "MessageSegment",
18
+ "TextMessageSegment",
19
+ "MentionMessageSegment",
20
+ "MentionAllMessageSegment",
21
+ "ImageMessageSegment",
22
+ "VoiceMessageSegment",
23
+ "AudioMessageSegment",
24
+ "VideoMessageSegment",
25
+ "FileMessageSegment",
26
+ "LocationMessageSegment",
27
+ ]
@@ -0,0 +1,110 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Literal, List, Annotated, Union
3
+
4
+ class TextSegmentData(BaseModel):
5
+ """纯文本"""
6
+ text: str
7
+
8
+ class MentionSegmentData(BaseModel):
9
+ """@某人"""
10
+ user_id: str
11
+
12
+ class MentionAllSegmentData(BaseModel):
13
+ """@所有人"""
14
+ pass
15
+
16
+ class ImageSegmentData(BaseModel):
17
+ """图片"""
18
+ file_id: str
19
+
20
+ class VoiceSegmentData(BaseModel):
21
+ """语音"""
22
+ file_id: str
23
+
24
+ class AudioSegmentData(BaseModel):
25
+ """音频"""
26
+ file_id: str
27
+
28
+ class VideoSegmentData(BaseModel):
29
+ """视频"""
30
+ file_id: str
31
+
32
+ class FileSegmentData(BaseModel):
33
+ """文件"""
34
+ file_id: str
35
+
36
+ class LocationSegmentData(BaseModel):
37
+ """位置"""
38
+ latitude: float
39
+ longitude: float
40
+ title: str
41
+ content: str
42
+
43
+ class ReplySegmentData(BaseModel):
44
+ """回复"""
45
+ message_id: str
46
+ user_id: str | None = None # 可选
47
+
48
+ class TextMessageSegment(BaseModel):
49
+ type: Literal["text"] = "text"
50
+ data: TextSegmentData
51
+
52
+ class MentionMessageSegment(BaseModel):
53
+ type: Literal["mention"] = "mention"
54
+ data: MentionSegmentData
55
+
56
+ class MentionAllMessageSegment(BaseModel):
57
+ type: Literal["mention_all"] = "mention_all"
58
+ data: MentionAllSegmentData = Field(default_factory=MentionAllSegmentData)
59
+
60
+ class ImageMessageSegment(BaseModel):
61
+ type: Literal["image"] = "image"
62
+ data: ImageSegmentData
63
+
64
+ class VoiceMessageSegment(BaseModel):
65
+ type: Literal["voice"] = "voice"
66
+ data: VoiceSegmentData
67
+
68
+ class AudioMessageSegment(BaseModel):
69
+ type: Literal["audio"] = "audio"
70
+ data: AudioSegmentData
71
+
72
+ class VideoMessageSegment(BaseModel):
73
+ type: Literal["video"] = "video"
74
+ data: VideoSegmentData
75
+
76
+ class FileMessageSegment(BaseModel):
77
+ type: Literal["file"] = "file"
78
+ data: FileSegmentData
79
+
80
+ class LocationMessageSegment(BaseModel):
81
+ type: Literal["location"] = "location"
82
+ data: LocationSegmentData
83
+
84
+ class ReplyMessageSegment(BaseModel):
85
+ type: Literal["reply"] = "reply"
86
+ data: ReplySegmentData
87
+
88
+ MessageSegment = Annotated[
89
+ Union[
90
+ TextMessageSegment,
91
+ MentionMessageSegment,
92
+ MentionAllMessageSegment,
93
+ ImageMessageSegment,
94
+ VoiceMessageSegment,
95
+ AudioMessageSegment,
96
+ VideoMessageSegment,
97
+ FileMessageSegment,
98
+ LocationMessageSegment,
99
+ ReplyMessageSegment,
100
+ ],
101
+ Field(discriminator="type"),
102
+ ]
103
+
104
+ class MessagePayload(BaseModel):
105
+ """消息载体"""
106
+ source_type: Literal['group', 'private'] = Field(..., description="消息来源类型")
107
+ session_id: str = Field(..., description="会话 ID")
108
+ bot_id: str = Field(..., description="机器人 ID")
109
+ user_id: str = Field(..., description="用户 ID")
110
+ messages: List[MessageSegment] = Field(..., description="消息列表")
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: onebot-protocol
3
+ Version: 0.0.2
4
+ Summary: OneBot 通信协议,定义消息收发的公共数据结构
5
+ Project-URL: Repository, https://github.com/XiaoHui2023/onebot-protocol
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: pydantic>=2.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # onebot-protocol
@@ -0,0 +1,5 @@
1
+ onebot_protocol/__init__.py,sha256=fEiJHC_KifG-PUD-xiyy8RBJPYfz2iRKyV4T4z6AUcc,634
2
+ onebot_protocol/models.py,sha256=UBVN5B09Zea8MMB4dXJDYpbOfTYfu1s_dJ47VoIX-h8,2888
3
+ onebot_protocol-0.0.2.dist-info/METADATA,sha256=b6N-8wKvA9qgrj8nrubeTbKUe6ew1VJjpIHiu3KotRI,337
4
+ onebot_protocol-0.0.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
5
+ onebot_protocol-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any