Skip to main content

onebot_api/message/
receive_segment.rs

1use super::utils::*;
2use serde::Deserialize;
3
4#[derive(Deserialize, Debug, Clone)]
5#[serde(tag = "type")]
6pub enum ReceiveSegment {
7	#[serde(rename = "text")]
8	Text { data: TextData },
9
10	#[serde(rename = "face")]
11	Face { data: FaceData },
12
13	#[serde(rename = "image")]
14	Image { data: ImageData },
15
16	#[serde(rename = "record")]
17	Record { data: RecordData },
18
19	#[serde(rename = "video")]
20	Video { data: VideoData },
21
22	#[serde(rename = "at")]
23	At { data: AtData },
24
25	#[serde(rename = "rps")]
26	Rps { data: RpsData },
27
28	#[serde(rename = "dice")]
29	Dice { data: DiceData },
30
31	#[serde(rename = "shake")]
32	Shake { data: ShakeData },
33
34	#[serde(rename = "poke")]
35	Poke { data: PokeData },
36
37	#[serde(rename = "anonymous")]
38	Anonymous { data: AnonymousData },
39
40	#[serde(rename = "share")]
41	Share { data: ShareData },
42
43	#[serde(rename = "contact")]
44	Contact { data: ContactData },
45
46	#[serde(rename = "location")]
47	Location { data: LocationData },
48
49	#[serde(rename = "music")]
50	Music { data: MusicData },
51
52	#[serde(rename = "reply")]
53	Reply { data: ReplyData },
54
55	#[serde(rename = "forward")]
56	Forward { data: ForwardData },
57
58	#[serde(rename = "node")]
59	Node { data: NodeData },
60
61	#[serde(rename = "xml")]
62	Xml { data: XmlData },
63
64	#[serde(rename = "json")]
65	Json { data: JsonData },
66}
67
68#[derive(Deserialize, Debug, Clone)]
69pub struct TextData {
70	/// # 说明
71	/// 纯文本内容
72	pub text: String,
73}
74
75#[derive(Deserialize, Debug, Clone)]
76pub struct FaceData {
77	/// # 说明
78	/// QQ 表情 ID
79	/// # 可能的值
80	/// 见 [QQ 表情 ID 表](https://github.com/richardchien/coolq-http-api/wiki/%E8%A1%A8%E6%83%85-CQ-%E7%A0%81-ID-%E8%A1%A8)
81	pub id: String,
82}
83
84#[derive(Deserialize, Debug, Clone)]
85pub struct ImageData {
86	/// # 说明
87	/// 图片文件名
88	pub file: String,
89	#[serde(rename = "type")]
90	/// # 说明
91	/// 图片类型,`flash` 表示闪照,无此参数表示普通图片
92	/// # 可能的值
93	/// `flash`
94	pub image_type: Option<ImageType>,
95	/// # 说明
96	/// 图片 URL
97	pub url: String,
98}
99
100#[derive(Deserialize, Debug, Clone)]
101pub struct RecordData {
102	/// # 说明
103	/// 语音文件名
104	pub file: String,
105	/// # 说明
106	/// 发送时可选,默认 `0`,设置为 `1` 表示变声
107	/// # 可能的值
108	/// `0` `1`
109	pub magic: String,
110	/// # 说明
111	/// 语音 URL
112	pub url: String,
113}
114
115#[derive(Deserialize, Debug, Clone)]
116pub struct VideoData {
117	/// # 说明
118	/// 视频文件名
119	pub file: String,
120	/// # 说明
121	/// 视频 URL
122	pub url: String,
123}
124
125#[derive(Deserialize, Debug, Clone)]
126pub struct AtData {
127	/// # 说明
128	/// @的 QQ 号,`all` 表示全体成员
129	/// # 可能的值
130	/// QQ 号、`all`
131	pub qq: AtType,
132}
133
134#[derive(Deserialize, Debug, Clone)]
135pub struct RpsData {}
136
137#[derive(Deserialize, Debug, Clone)]
138pub struct DiceData {}
139
140#[derive(Deserialize, Debug, Clone)]
141pub struct ShakeData {}
142
143#[derive(Deserialize, Debug, Clone)]
144pub struct PokeData {
145	#[serde(rename = "type")]
146	/// # 说明
147	/// 类型
148	/// # 可能的值
149	/// 见 [Mirai 的 PokeMessage 类](https://github.com/mamoe/mirai/blob/f5eefae7ecee84d18a66afce3f89b89fe1584b78/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/HummerMessage.kt#L49)
150	pub poke_type: String,
151	/// # 说明
152	/// ID
153	/// # 可能的值
154	/// 同上
155	pub id: String,
156	/// # 说明
157	/// 表情名
158	/// # 可能的值
159	/// 同上
160	pub name: String,
161}
162
163#[derive(Deserialize, Debug, Clone)]
164pub struct AnonymousData {}
165
166#[derive(Deserialize, Debug, Clone)]
167pub struct ShareData {
168	/// # 说明
169	/// URL
170	pub url: String,
171	/// # 说明
172	/// 标题
173	pub title: String,
174	/// # 说明
175	/// 发送时可选,内容描述
176	pub content: String,
177	/// # 说明
178	/// 发送时可选,图片 URL
179	pub image: String,
180}
181
182#[derive(Deserialize, Debug, Clone)]
183pub struct ContactData {
184	#[serde(rename = "type")]
185	/// # 说明
186	/// 推荐好友/群
187	pub contact_type: ContactType,
188	/// # 说明
189	/// 被推荐人的 QQ 号/被推荐群的群号
190	pub id: String,
191}
192
193#[derive(Deserialize, Debug, Clone)]
194pub struct LocationData {
195	/// # 说明
196	/// 纬度
197	pub lat: String,
198	/// # 说明
199	/// 经度
200	pub lon: String,
201	/// # 说明
202	/// 发送时可选,标题
203	pub title: String,
204	/// # 说明
205	/// 发送时可选,内容描述
206	pub content: String,
207}
208
209#[derive(Deserialize, Debug, Clone)]
210pub struct MusicData {}
211
212#[derive(Deserialize, Debug, Clone)]
213pub struct ReplyData {
214	/// # 说明
215	/// 回复时引用的消息 ID
216	pub id: String,
217}
218
219#[derive(Deserialize, Debug, Clone)]
220pub struct ForwardData {
221	/// # 说明
222	/// 合并转发 ID,需通过 [`get_forward_msg` API](https://github.com/botuniverse/onebot-11/blob/master/api/public.md#get_forward_msg-%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF) 获取具体内容
223	pub id: String,
224}
225
226#[derive(Deserialize, Debug, Clone)]
227pub struct NodeData {
228	/// # 说明
229	/// 发送者 QQ 号
230	pub user_id: String,
231	/// # 说明
232	/// 发送者昵称
233	pub nickname: String,
234	/// # 说明
235	/// 消息内容,支持发送消息时的 `message` 数据类型,见 [API 的参数](https://github.com/botuniverse/onebot-11/blob/master/api/#%E5%8F%82%E6%95%B0)
236	pub content: Vec<ReceiveSegment>,
237}
238
239#[derive(Deserialize, Debug, Clone)]
240pub struct XmlData {
241	/// # 说明
242	/// XML 内容
243	pub data: String,
244}
245
246#[derive(Deserialize, Debug, Clone)]
247pub struct JsonData {
248	/// 说明
249	/// JSON 内容
250	pub data: String,
251}