flow_bot/event/
notice.rs

1use std::collections::HashMap;
2
3use serde::Deserialize;
4use serde_json::Value;
5
6use crate::impl_from_event;
7
8#[derive(Deserialize, Debug, Clone)]
9pub struct GroupFile {
10    pub id: String,
11    pub name: String,
12    pub size: i64,
13    pub busid: i64,
14}
15
16#[derive(Deserialize, Debug, Clone)]
17pub struct GroupUpload {
18    pub group_id: i64,
19    pub user_id: i64,
20    pub file: GroupFile,
21}
22
23#[derive(Deserialize, Debug, Clone)]
24#[serde(rename_all = "snake_case")]
25pub enum GroupAdminSubType {
26    Set,
27    Unset,
28}
29
30#[derive(Deserialize, Debug, Clone)]
31pub struct GroupAdmin {
32    pub group_id: i64,
33    pub user_id: i64,
34    pub sub_type: GroupAdminSubType,
35}
36
37#[derive(Deserialize, Debug, Clone)]
38#[serde(rename_all = "snake_case")]
39pub enum GroupDecreaseSubType {
40    Leave,
41    Kick,
42    KickMe,
43}
44
45#[derive(Deserialize, Debug, Clone)]
46pub struct GroupDecrease {
47    pub group_id: i64,
48    pub user_id: i64,
49    pub operator_id: i64,
50    pub sub_type: GroupDecreaseSubType,
51}
52
53#[derive(Deserialize, Debug, Clone)]
54#[serde(rename_all = "snake_case")]
55pub enum GroupIncreaseSubType {
56    Approve,
57    Invite,
58}
59
60#[derive(Deserialize, Debug, Clone)]
61pub struct GroupIncrease {
62    pub group_id: i64,
63    pub user_id: i64,
64    pub operator_id: i64,
65    pub sub_type: GroupIncreaseSubType,
66}
67
68#[derive(Deserialize, Debug, Clone)]
69#[serde(rename_all = "snake_case")]
70pub enum GroupBanSubType {
71    Ban,
72    LiftBan,
73}
74
75#[derive(Deserialize, Debug, Clone)]
76pub struct GroupBan {
77    pub group_id: i64,
78    pub user_id: i64,
79    pub operator_id: i64,
80    pub sub_type: GroupBanSubType,
81    pub duration: i64,
82}
83
84#[derive(Deserialize, Debug, Clone)]
85pub struct FriendAdd {
86    pub user_id: i64,
87}
88
89#[derive(Deserialize, Debug, Clone)]
90pub struct GroupRecall {
91    pub group_id: i64,
92    pub user_id: i64,
93    pub operator_id: i64,
94    pub message_id: i64,
95}
96
97#[derive(Deserialize, Debug, Clone)]
98pub struct FriendRecall {
99    pub user_id: i64,
100    pub message_id: i64,
101}
102
103#[derive(Deserialize, Debug, Clone)]
104#[serde(tag = "notice_type")]
105#[serde(rename_all = "snake_case")]
106pub enum Notice {
107    GroupUpload(GroupUpload),
108    GroupAdmin(GroupAdmin),
109    GroupDecrease(GroupDecrease),
110    GroupIncrease(GroupIncrease),
111    GroupBan(GroupBan),
112    FriendAdd(FriendAdd),
113    GroupRecall(GroupRecall),
114    FriendRecall(FriendRecall),
115    Notify {
116        #[serde(flatten)]
117        data: HashMap<String, Value>,
118    },
119}
120
121impl_from_event!(Notice);
122
123impl_from_event!(Notice, GroupUpload);
124
125impl_from_event!(Notice, GroupAdmin);
126
127impl_from_event!(Notice, GroupDecrease);
128
129impl_from_event!(Notice, GroupIncrease);
130
131impl_from_event!(Notice, GroupBan);
132
133impl_from_event!(Notice, FriendAdd);
134
135impl_from_event!(Notice, GroupRecall);
136
137impl_from_event!(Notice, FriendRecall);