1#[cfg(feature = "selector")]
2use crate::selector::Selector;
3use serde::Deserialize;
4use strum::{Display, EnumIs};
5
6#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
7pub struct GroupFile {
8 pub id: String,
9 pub name: String,
10 pub size: i64,
11 pub busid: i64,
12}
13
14#[derive(Deserialize, Debug, Copy, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
15pub enum GroupAdminType {
16 #[serde(rename = "set")]
17 Set,
18 #[serde(rename = "unset")]
19 Unset,
20}
21
22#[derive(Deserialize, Debug, Copy, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
23pub enum GroupDecreaseType {
24 #[serde(rename = "leave")]
25 Leave,
26 #[serde(rename = "kick")]
27 Kick,
28 #[serde(rename = "kick_me")]
29 KickMe,
30}
31
32#[derive(Deserialize, Debug, Copy, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
33pub enum GroupIncreaseType {
34 #[serde(rename = "approve")]
35 Approve,
36 #[serde(rename = "invite")]
37 Invite,
38}
39
40#[derive(Deserialize, Debug, Copy, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
41pub enum GroupBanType {
42 #[serde(rename = "ban")]
43 Ban,
44 #[serde(rename = "lift_ban")]
45 LiftBan,
46}
47
48#[derive(Deserialize, Debug, Copy, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
49#[serde(tag = "sub_type")]
50pub enum NotifyType {
51 #[serde(rename = "poke")]
52 Poke { target_id: i64 },
53 #[serde(rename = "lucky_king")]
54 LuckyKing { target_id: i64 },
55 #[serde(rename = "honor")]
56 Honor { honor_type: HonorType },
57}
58
59#[derive(Deserialize, Debug, Copy, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
60pub enum HonorType {
61 #[serde(rename = "talkative")]
62 Talkative,
63 #[serde(rename = "performer")]
64 Performer,
65 #[serde(rename = "emotion")]
66 Emotion,
67}
68
69#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
70pub struct NoticeEventGroupUpload {
71 pub group_id: i64,
72 pub user_id: i64,
73 pub file: GroupFile,
74}
75
76impl NoticeEventGroupUpload {
77 #[cfg(feature = "selector")]
78 pub fn selector(&'_ self) -> Selector<'_, Self> {
79 Selector { data: Some(self) }
80 }
81}
82
83#[cfg(feature = "selector")]
84impl<'a> Selector<'a, NoticeEventGroupUpload> {
85 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventGroupUpload) -> bool) {
86 if let Some(data) = self.data
87 && !f(data)
88 {
89 self.data = None
90 }
91 }
92
93 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventGroupUpload) -> bool) -> Self {
94 self.filter(f);
95 self
96 }
97
98 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventGroupUpload) -> bool) {
99 if let Some(data) = self.data
100 && !f(data).await
101 {
102 self.data = None
103 }
104 }
105
106 pub async fn and_filter_async(
107 mut self,
108 f: impl AsyncFnOnce(&NoticeEventGroupUpload) -> bool,
109 ) -> Self {
110 self.filter_async(f).await;
111 self
112 }
113
114 pub fn filter_group_id(&mut self, f: impl FnOnce(i64) -> bool) {
115 if let Some(data) = self.data
116 && !f(data.group_id)
117 {
118 self.data = None
119 }
120 }
121
122 pub fn and_filter_group_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
123 self.filter_group_id(f);
124 self
125 }
126
127 pub async fn filter_group_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
128 if let Some(data) = self.data
129 && !f(data.group_id).await
130 {
131 self.data = None
132 }
133 }
134
135 pub async fn and_filter_group_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
136 self.filter_group_id_async(f).await;
137 self
138 }
139
140 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
141 if let Some(data) = self.data
142 && !f(data.user_id)
143 {
144 self.data = None
145 }
146 }
147
148 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
149 self.filter_user_id(f);
150 self
151 }
152
153 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
154 if let Some(data) = self.data
155 && !f(data.user_id).await
156 {
157 self.data = None
158 }
159 }
160
161 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
162 self.filter_user_id_async(f).await;
163 self
164 }
165
166 pub fn filter_file(&mut self, f: impl FnOnce(&GroupFile) -> bool) {
167 if let Some(data) = self.data
168 && !f(&data.file)
169 {
170 self.data = None
171 }
172 }
173
174 pub fn and_filter_file(mut self, f: impl FnOnce(&GroupFile) -> bool) -> Self {
175 self.filter_file(f);
176 self
177 }
178
179 pub async fn filter_file_async(&mut self, f: impl AsyncFnOnce(&GroupFile) -> bool) {
180 if let Some(data) = self.data
181 && !f(&data.file).await
182 {
183 self.data = None
184 }
185 }
186
187 pub async fn and_filter_file_async(mut self, f: impl AsyncFnOnce(&GroupFile) -> bool) -> Self {
188 self.filter_file_async(f).await;
189 self
190 }
191}
192
193#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
194pub struct NoticeEventGroupAdmin {
195 sub_type: GroupAdminType,
196 group_id: i64,
197 user_id: i64,
198}
199
200impl NoticeEventGroupAdmin {
201 #[cfg(feature = "selector")]
202 pub fn selector(&'_ self) -> Selector<'_, Self> {
203 Selector { data: Some(self) }
204 }
205}
206
207#[cfg(feature = "selector")]
208impl<'a> Selector<'a, NoticeEventGroupAdmin> {
209 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventGroupAdmin) -> bool) {
210 if let Some(data) = self.data
211 && !f(data)
212 {
213 self.data = None
214 }
215 }
216
217 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventGroupAdmin) -> bool) -> Self {
218 self.filter(f);
219 self
220 }
221
222 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventGroupAdmin) -> bool) {
223 if let Some(data) = self.data
224 && !f(data).await
225 {
226 self.data = None
227 }
228 }
229
230 pub async fn and_filter_async(
231 mut self,
232 f: impl AsyncFnOnce(&NoticeEventGroupAdmin) -> bool,
233 ) -> Self {
234 self.filter_async(f).await;
235 self
236 }
237
238 pub fn filter_sub_type(&mut self, f: impl FnOnce(GroupAdminType) -> bool) {
239 if let Some(data) = self.data
240 && !f(data.sub_type)
241 {
242 self.data = None
243 }
244 }
245
246 pub fn and_filter_sub_type(mut self, f: impl FnOnce(GroupAdminType) -> bool) -> Self {
247 self.filter_sub_type(f);
248 self
249 }
250
251 pub async fn filter_sub_type_async(&mut self, f: impl AsyncFnOnce(GroupAdminType) -> bool) {
252 if let Some(data) = self.data
253 && !f(data.sub_type).await
254 {
255 self.data = None
256 }
257 }
258
259 pub async fn and_filter_sub_type_async(
260 mut self,
261 f: impl AsyncFnOnce(GroupAdminType) -> bool,
262 ) -> Self {
263 self.filter_sub_type_async(f).await;
264 self
265 }
266
267 pub fn filter_group_id(&mut self, f: impl FnOnce(i64) -> bool) {
268 if let Some(data) = self.data
269 && !f(data.group_id)
270 {
271 self.data = None
272 }
273 }
274
275 pub fn and_filter_group_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
276 self.filter_group_id(f);
277 self
278 }
279
280 pub async fn filter_group_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
281 if let Some(data) = self.data
282 && !f(data.group_id).await
283 {
284 self.data = None
285 }
286 }
287
288 pub async fn and_filter_group_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
289 self.filter_group_id_async(f).await;
290 self
291 }
292
293 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
294 if let Some(data) = self.data
295 && !f(data.user_id)
296 {
297 self.data = None
298 }
299 }
300
301 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
302 self.filter_user_id(f);
303 self
304 }
305
306 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
307 if let Some(data) = self.data
308 && !f(data.user_id).await
309 {
310 self.data = None
311 }
312 }
313
314 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
315 self.filter_user_id_async(f).await;
316 self
317 }
318
319 pub fn set(&mut self) {
320 if let Some(data) = self.data
321 && !data.sub_type.is_set()
322 {
323 self.data = None
324 }
325 }
326
327 pub fn and_set(mut self) -> Self {
328 self.set();
329 self
330 }
331
332 pub fn not_set(&mut self) {
333 if let Some(data) = self.data
334 && data.sub_type.is_set()
335 {
336 self.data = None
337 }
338 }
339
340 pub fn and_not_set(mut self) -> Self {
341 self.not_set();
342 self
343 }
344
345 pub fn unset(&mut self) {
346 if let Some(data) = self.data
347 && !data.sub_type.is_unset()
348 {
349 self.data = None
350 }
351 }
352
353 pub fn and_unset(mut self) -> Self {
354 self.unset();
355 self
356 }
357
358 pub fn not_unset(&mut self) {
359 if let Some(data) = self.data
360 && data.sub_type.is_unset()
361 {
362 self.data = None
363 }
364 }
365
366 pub fn and_not_unset(mut self) -> Self {
367 self.not_unset();
368 self
369 }
370}
371
372#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
373pub struct NoticeEventGroupDecrease {
374 sub_type: GroupDecreaseType,
375 operator_id: i64,
376 user_id: i64,
377}
378
379impl NoticeEventGroupDecrease {
380 #[cfg(feature = "selector")]
381 pub fn selector(&'_ self) -> Selector<'_, Self> {
382 Selector { data: Some(self) }
383 }
384}
385
386#[cfg(feature = "selector")]
387impl<'a> Selector<'a, NoticeEventGroupDecrease> {
388 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventGroupDecrease) -> bool) {
389 if let Some(data) = self.data
390 && !f(data)
391 {
392 self.data = None
393 }
394 }
395
396 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventGroupDecrease) -> bool) -> Self {
397 self.filter(f);
398 self
399 }
400
401 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventGroupDecrease) -> bool) {
402 if let Some(data) = self.data
403 && !f(data).await
404 {
405 self.data = None
406 }
407 }
408
409 pub async fn and_filter_async(
410 mut self,
411 f: impl AsyncFnOnce(&NoticeEventGroupDecrease) -> bool,
412 ) -> Self {
413 self.filter_async(f).await;
414 self
415 }
416
417 pub fn filter_sub_type(&mut self, f: impl FnOnce(GroupDecreaseType) -> bool) {
418 if let Some(data) = self.data
419 && !f(data.sub_type)
420 {
421 self.data = None
422 }
423 }
424
425 pub fn and_filter_sub_type(mut self, f: impl FnOnce(GroupDecreaseType) -> bool) -> Self {
426 self.filter_sub_type(f);
427 self
428 }
429
430 pub async fn filter_sub_type_async(&mut self, f: impl AsyncFnOnce(GroupDecreaseType) -> bool) {
431 if let Some(data) = self.data
432 && !f(data.sub_type).await
433 {
434 self.data = None
435 }
436 }
437
438 pub async fn and_filter_sub_type_async(
439 mut self,
440 f: impl AsyncFnOnce(GroupDecreaseType) -> bool,
441 ) -> Self {
442 self.filter_sub_type_async(f).await;
443 self
444 }
445
446 pub fn filter_operator_id(&mut self, f: impl FnOnce(i64) -> bool) {
447 if let Some(data) = self.data
448 && !f(data.operator_id)
449 {
450 self.data = None
451 }
452 }
453
454 pub fn and_filter_operator_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
455 self.filter_operator_id(f);
456 self
457 }
458
459 pub async fn filter_operator_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
460 if let Some(data) = self.data
461 && !f(data.operator_id).await
462 {
463 self.data = None
464 }
465 }
466
467 pub async fn and_filter_operator_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
468 self.filter_operator_id_async(f).await;
469 self
470 }
471
472 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
473 if let Some(data) = self.data
474 && !f(data.user_id)
475 {
476 self.data = None
477 }
478 }
479
480 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
481 self.filter_user_id(f);
482 self
483 }
484
485 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
486 if let Some(data) = self.data
487 && !f(data.user_id).await
488 {
489 self.data = None
490 }
491 }
492
493 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
494 self.filter_user_id_async(f).await;
495 self
496 }
497
498 pub fn leave(&mut self) {
499 if let Some(data) = self.data
500 && !data.sub_type.is_leave()
501 {
502 self.data = None
503 }
504 }
505
506 pub fn and_leave(mut self) -> Self {
507 self.leave();
508 self
509 }
510
511 pub fn not_leave(&mut self) {
512 if let Some(data) = self.data
513 && data.sub_type.is_leave()
514 {
515 self.data = None
516 }
517 }
518
519 pub fn and_not_leave(mut self) -> Self {
520 self.not_leave();
521 self
522 }
523
524 pub fn kick(&mut self) {
525 if let Some(data) = self.data
526 && !data.sub_type.is_kick()
527 {
528 self.data = None
529 }
530 }
531
532 pub fn and_kick(mut self) -> Self {
533 self.kick();
534 self
535 }
536
537 pub fn not_kick(&mut self) {
538 if let Some(data) = self.data
539 && data.sub_type.is_kick()
540 {
541 self.data = None
542 }
543 }
544
545 pub fn and_not_kick(mut self) -> Self {
546 self.not_kick();
547 self
548 }
549
550 pub fn kick_me(&mut self) {
551 if let Some(data) = self.data
552 && !data.sub_type.is_kick_me()
553 {
554 self.data = None
555 }
556 }
557
558 pub fn and_kick_me(mut self) -> Self {
559 self.kick_me();
560 self
561 }
562
563 pub fn not_kick_me(&mut self) {
564 if let Some(data) = self.data
565 && data.sub_type.is_kick_me()
566 {
567 self.data = None
568 }
569 }
570
571 pub fn and_not_kick_me(mut self) -> Self {
572 self.not_kick_me();
573 self
574 }
575}
576
577#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
578pub struct NoticeEventGroupIncrease {
579 sub_type: GroupIncreaseType,
580 group_id: i64,
581 operator_id: i64,
582 user_id: i64,
583}
584
585impl NoticeEventGroupIncrease {
586 #[cfg(feature = "selector")]
587 pub fn selector(&'_ self) -> Selector<'_, Self> {
588 Selector { data: Some(self) }
589 }
590}
591
592#[cfg(feature = "selector")]
593impl<'a> Selector<'a, NoticeEventGroupIncrease> {
594 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventGroupIncrease) -> bool) {
595 if let Some(data) = self.data
596 && !f(data)
597 {
598 self.data = None
599 }
600 }
601
602 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventGroupIncrease) -> bool) -> Self {
603 self.filter(f);
604 self
605 }
606
607 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventGroupIncrease) -> bool) {
608 if let Some(data) = self.data
609 && !f(data).await
610 {
611 self.data = None
612 }
613 }
614
615 pub async fn and_filter_async(
616 mut self,
617 f: impl AsyncFnOnce(&NoticeEventGroupIncrease) -> bool,
618 ) -> Self {
619 self.filter_async(f).await;
620 self
621 }
622
623 pub fn filter_sub_type(&mut self, f: impl FnOnce(GroupIncreaseType) -> bool) {
624 if let Some(data) = self.data
625 && !f(data.sub_type)
626 {
627 self.data = None
628 }
629 }
630
631 pub fn and_filter_sub_type(mut self, f: impl FnOnce(GroupIncreaseType) -> bool) -> Self {
632 self.filter_sub_type(f);
633 self
634 }
635
636 pub async fn filter_sub_type_async(&mut self, f: impl AsyncFnOnce(GroupIncreaseType) -> bool) {
637 if let Some(data) = self.data
638 && !f(data.sub_type).await
639 {
640 self.data = None
641 }
642 }
643
644 pub async fn and_filter_sub_type_async(
645 mut self,
646 f: impl AsyncFnOnce(GroupIncreaseType) -> bool,
647 ) -> Self {
648 self.filter_sub_type_async(f).await;
649 self
650 }
651
652 pub fn filter_group_id(&mut self, f: impl FnOnce(i64) -> bool) {
653 if let Some(data) = self.data
654 && !f(data.group_id)
655 {
656 self.data = None
657 }
658 }
659
660 pub fn and_filter_group_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
661 self.filter_group_id(f);
662 self
663 }
664
665 pub async fn filter_group_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
666 if let Some(data) = self.data
667 && !f(data.group_id).await
668 {
669 self.data = None
670 }
671 }
672
673 pub async fn and_filter_group_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
674 self.filter_group_id_async(f).await;
675 self
676 }
677
678 pub fn filter_operator_id(&mut self, f: impl FnOnce(i64) -> bool) {
679 if let Some(data) = self.data
680 && !f(data.operator_id)
681 {
682 self.data = None
683 }
684 }
685
686 pub fn and_filter_operator_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
687 self.filter_operator_id(f);
688 self
689 }
690
691 pub async fn filter_operator_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
692 if let Some(data) = self.data
693 && !f(data.operator_id).await
694 {
695 self.data = None
696 }
697 }
698
699 pub async fn and_filter_operator_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
700 self.filter_operator_id_async(f).await;
701 self
702 }
703
704 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
705 if let Some(data) = self.data
706 && !f(data.user_id)
707 {
708 self.data = None
709 }
710 }
711
712 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
713 self.filter_user_id(f);
714 self
715 }
716
717 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
718 if let Some(data) = self.data
719 && !f(data.user_id).await
720 {
721 self.data = None
722 }
723 }
724
725 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
726 self.filter_user_id_async(f).await;
727 self
728 }
729
730 pub fn approve(&mut self) {
731 if let Some(data) = self.data
732 && !data.sub_type.is_approve()
733 {
734 self.data = None
735 }
736 }
737
738 pub fn and_approve(mut self) -> Self {
739 self.approve();
740 self
741 }
742
743 pub fn not_approve(&mut self) {
744 if let Some(data) = self.data
745 && data.sub_type.is_approve()
746 {
747 self.data = None
748 }
749 }
750
751 pub fn and_not_approve(mut self) -> Self {
752 self.not_approve();
753 self
754 }
755
756 pub fn invite(&mut self) {
757 if let Some(data) = self.data
758 && !data.sub_type.is_invite()
759 {
760 self.data = None
761 }
762 }
763
764 pub fn and_invite(mut self) -> Self {
765 self.invite();
766 self
767 }
768
769 pub fn not_invite(&mut self) {
770 if let Some(data) = self.data
771 && data.sub_type.is_invite()
772 {
773 self.data = None
774 }
775 }
776
777 pub fn and_not_invite(mut self) -> Self {
778 self.not_invite();
779 self
780 }
781}
782
783#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
784pub struct NoticeEventGroupBan {
785 sub_type: GroupBanType,
786 group_id: i64,
787 operator_id: i64,
788 user_id: i64,
789 duration: i64,
790}
791
792impl NoticeEventGroupBan {
793 #[cfg(feature = "selector")]
794 pub fn selector(&'_ self) -> Selector<'_, Self> {
795 Selector { data: Some(self) }
796 }
797}
798
799#[cfg(feature = "selector")]
800impl<'a> Selector<'a, NoticeEventGroupBan> {
801 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventGroupBan) -> bool) {
802 if let Some(data) = self.data
803 && !f(data)
804 {
805 self.data = None
806 }
807 }
808
809 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventGroupBan) -> bool) -> Self {
810 self.filter(f);
811 self
812 }
813
814 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventGroupBan) -> bool) {
815 if let Some(data) = self.data
816 && !f(data).await
817 {
818 self.data = None
819 }
820 }
821
822 pub async fn and_filter_async(
823 mut self,
824 f: impl AsyncFnOnce(&NoticeEventGroupBan) -> bool,
825 ) -> Self {
826 self.filter_async(f).await;
827 self
828 }
829
830 pub fn filter_sub_type(&mut self, f: impl FnOnce(GroupBanType) -> bool) {
831 if let Some(data) = self.data
832 && !f(data.sub_type)
833 {
834 self.data = None
835 }
836 }
837
838 pub fn and_filter_sub_type(mut self, f: impl FnOnce(GroupBanType) -> bool) -> Self {
839 self.filter_sub_type(f);
840 self
841 }
842
843 pub async fn filter_sub_type_async(&mut self, f: impl AsyncFnOnce(GroupBanType) -> bool) {
844 if let Some(data) = self.data
845 && !f(data.sub_type).await
846 {
847 self.data = None
848 }
849 }
850
851 pub async fn and_filter_sub_type_async(
852 mut self,
853 f: impl AsyncFnOnce(GroupBanType) -> bool,
854 ) -> Self {
855 self.filter_sub_type_async(f).await;
856 self
857 }
858
859 pub fn filter_group_id(&mut self, f: impl FnOnce(i64) -> bool) {
860 if let Some(data) = self.data
861 && !f(data.group_id)
862 {
863 self.data = None
864 }
865 }
866
867 pub fn and_filter_group_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
868 self.filter_group_id(f);
869 self
870 }
871
872 pub async fn filter_group_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
873 if let Some(data) = self.data
874 && !f(data.group_id).await
875 {
876 self.data = None
877 }
878 }
879
880 pub async fn and_filter_group_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
881 self.filter_group_id_async(f).await;
882 self
883 }
884
885 pub fn filter_operator_id(&mut self, f: impl FnOnce(i64) -> bool) {
886 if let Some(data) = self.data
887 && !f(data.operator_id)
888 {
889 self.data = None
890 }
891 }
892
893 pub fn and_filter_operator_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
894 self.filter_operator_id(f);
895 self
896 }
897
898 pub async fn filter_operator_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
899 if let Some(data) = self.data
900 && !f(data.operator_id).await
901 {
902 self.data = None
903 }
904 }
905
906 pub async fn and_filter_operator_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
907 self.filter_operator_id_async(f).await;
908 self
909 }
910
911 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
912 if let Some(data) = self.data
913 && !f(data.user_id)
914 {
915 self.data = None
916 }
917 }
918
919 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
920 self.filter_user_id(f);
921 self
922 }
923
924 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
925 if let Some(data) = self.data
926 && !f(data.user_id).await
927 {
928 self.data = None
929 }
930 }
931
932 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
933 self.filter_user_id_async(f).await;
934 self
935 }
936
937 pub fn filter_duration(&mut self, f: impl FnOnce(i64) -> bool) {
938 if let Some(data) = self.data
939 && !f(data.duration)
940 {
941 self.data = None
942 }
943 }
944
945 pub fn and_filter_duration(mut self, f: impl FnOnce(i64) -> bool) -> Self {
946 self.filter_duration(f);
947 self
948 }
949
950 pub async fn filter_duration_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
951 if let Some(data) = self.data
952 && !f(data.duration).await
953 {
954 self.data = None
955 }
956 }
957
958 pub async fn and_filter_duration_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
959 self.filter_duration_async(f).await;
960 self
961 }
962
963 pub fn ban(&mut self) {
964 if let Some(data) = self.data
965 && !data.sub_type.is_ban()
966 {
967 self.data = None
968 }
969 }
970
971 pub fn and_ban(mut self) -> Self {
972 self.ban();
973 self
974 }
975
976 pub fn not_ban(&mut self) {
977 if let Some(data) = self.data
978 && data.sub_type.is_ban()
979 {
980 self.data = None
981 }
982 }
983
984 pub fn and_not_ban(mut self) -> Self {
985 self.not_ban();
986 self
987 }
988
989 pub fn lift_ban(&mut self) {
990 if let Some(data) = self.data
991 && !data.sub_type.is_lift_ban()
992 {
993 self.data = None
994 }
995 }
996
997 pub fn and_lift_ban(mut self) -> Self {
998 self.lift_ban();
999 self
1000 }
1001
1002 pub fn not_lift_ban(&mut self) {
1003 if let Some(data) = self.data
1004 && data.sub_type.is_lift_ban()
1005 {
1006 self.data = None
1007 }
1008 }
1009
1010 pub fn and_not_lift_ban(mut self) -> Self {
1011 self.not_lift_ban();
1012 self
1013 }
1014}
1015
1016#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
1017pub struct NoticeEventFriendAdd {
1018 user_id: i64,
1019}
1020
1021impl NoticeEventFriendAdd {
1022 #[cfg(feature = "selector")]
1023 pub fn selector(&'_ self) -> Selector<'_, Self> {
1024 Selector { data: Some(self) }
1025 }
1026}
1027
1028#[cfg(feature = "selector")]
1029impl<'a> Selector<'a, NoticeEventFriendAdd> {
1030 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventFriendAdd) -> bool) {
1031 if let Some(data) = self.data
1032 && !f(data)
1033 {
1034 self.data = None
1035 }
1036 }
1037
1038 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventFriendAdd) -> bool) -> Self {
1039 self.filter(f);
1040 self
1041 }
1042
1043 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventFriendAdd) -> bool) {
1044 if let Some(data) = self.data
1045 && !f(data).await
1046 {
1047 self.data = None
1048 }
1049 }
1050
1051 pub async fn and_filter_async(
1052 mut self,
1053 f: impl AsyncFnOnce(&NoticeEventFriendAdd) -> bool,
1054 ) -> Self {
1055 self.filter_async(f).await;
1056 self
1057 }
1058
1059 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
1060 if let Some(data) = self.data
1061 && !f(data.user_id)
1062 {
1063 self.data = None
1064 }
1065 }
1066
1067 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1068 self.filter_user_id(f);
1069 self
1070 }
1071
1072 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1073 if let Some(data) = self.data
1074 && !f(data.user_id).await
1075 {
1076 self.data = None
1077 }
1078 }
1079
1080 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1081 self.filter_user_id_async(f).await;
1082 self
1083 }
1084}
1085
1086#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
1087pub struct NoticeEventGroupRecall {
1088 group_id: i64,
1089 user_id: i64,
1090 operator_id: i64,
1091 message_id: i64,
1092}
1093
1094impl NoticeEventGroupRecall {
1095 #[cfg(feature = "selector")]
1096 pub fn selector(&'_ self) -> Selector<'_, Self> {
1097 Selector { data: Some(self) }
1098 }
1099}
1100
1101#[cfg(feature = "selector")]
1102impl<'a> Selector<'a, NoticeEventGroupRecall> {
1103 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventGroupRecall) -> bool) {
1104 if let Some(data) = self.data
1105 && !f(data)
1106 {
1107 self.data = None
1108 }
1109 }
1110
1111 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventGroupRecall) -> bool) -> Self {
1112 self.filter(f);
1113 self
1114 }
1115
1116 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventGroupRecall) -> bool) {
1117 if let Some(data) = self.data
1118 && !f(data).await
1119 {
1120 self.data = None
1121 }
1122 }
1123
1124 pub async fn and_filter_async(
1125 mut self,
1126 f: impl AsyncFnOnce(&NoticeEventGroupRecall) -> bool,
1127 ) -> Self {
1128 self.filter_async(f).await;
1129 self
1130 }
1131
1132 pub fn filter_group_id(&mut self, f: impl FnOnce(i64) -> bool) {
1133 if let Some(data) = self.data
1134 && !f(data.group_id)
1135 {
1136 self.data = None
1137 }
1138 }
1139
1140 pub fn and_filter_group_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1141 self.filter_group_id(f);
1142 self
1143 }
1144
1145 pub async fn filter_group_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1146 if let Some(data) = self.data
1147 && !f(data.group_id).await
1148 {
1149 self.data = None
1150 }
1151 }
1152
1153 pub async fn and_filter_group_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1154 self.filter_group_id_async(f).await;
1155 self
1156 }
1157
1158 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
1159 if let Some(data) = self.data
1160 && !f(data.user_id)
1161 {
1162 self.data = None
1163 }
1164 }
1165
1166 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1167 self.filter_user_id(f);
1168 self
1169 }
1170
1171 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1172 if let Some(data) = self.data
1173 && !f(data.user_id).await
1174 {
1175 self.data = None
1176 }
1177 }
1178
1179 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1180 self.filter_user_id_async(f).await;
1181 self
1182 }
1183
1184 pub fn filter_operator_id(&mut self, f: impl FnOnce(i64) -> bool) {
1185 if let Some(data) = self.data
1186 && !f(data.operator_id)
1187 {
1188 self.data = None
1189 }
1190 }
1191
1192 pub fn and_filter_operator_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1193 self.filter_operator_id(f);
1194 self
1195 }
1196
1197 pub async fn filter_operator_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1198 if let Some(data) = self.data
1199 && !f(data.operator_id).await
1200 {
1201 self.data = None
1202 }
1203 }
1204
1205 pub async fn and_filter_operator_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1206 self.filter_operator_id_async(f).await;
1207 self
1208 }
1209
1210 pub fn filter_message_id(&mut self, f: impl FnOnce(i64) -> bool) {
1211 if let Some(data) = self.data
1212 && !f(data.message_id)
1213 {
1214 self.data = None
1215 }
1216 }
1217
1218 pub fn and_filter_message_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1219 self.filter_message_id(f);
1220 self
1221 }
1222
1223 pub async fn filter_message_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1224 if let Some(data) = self.data
1225 && !f(data.message_id).await
1226 {
1227 self.data = None
1228 }
1229 }
1230
1231 pub async fn and_filter_message_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1232 self.filter_message_id_async(f).await;
1233 self
1234 }
1235}
1236
1237#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
1238pub struct NoticeEventFriendRecall {
1239 user_id: i64,
1240 message_id: i64,
1241}
1242
1243impl NoticeEventFriendRecall {
1244 #[cfg(feature = "selector")]
1245 pub fn selector(&'_ self) -> Selector<'_, Self> {
1246 Selector { data: Some(self) }
1247 }
1248}
1249
1250#[cfg(feature = "selector")]
1251impl<'a> Selector<'a, NoticeEventFriendRecall> {
1252 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventFriendRecall) -> bool) {
1253 if let Some(data) = self.data
1254 && !f(data)
1255 {
1256 self.data = None
1257 }
1258 }
1259
1260 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventFriendRecall) -> bool) -> Self {
1261 self.filter(f);
1262 self
1263 }
1264
1265 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventFriendRecall) -> bool) {
1266 if let Some(data) = self.data
1267 && !f(data).await
1268 {
1269 self.data = None
1270 }
1271 }
1272
1273 pub async fn and_filter_async(
1274 mut self,
1275 f: impl AsyncFnOnce(&NoticeEventFriendRecall) -> bool,
1276 ) -> Self {
1277 self.filter_async(f).await;
1278 self
1279 }
1280
1281 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
1282 if let Some(data) = self.data
1283 && !f(data.user_id)
1284 {
1285 self.data = None
1286 }
1287 }
1288
1289 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1290 self.filter_user_id(f);
1291 self
1292 }
1293
1294 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1295 if let Some(data) = self.data
1296 && !f(data.user_id).await
1297 {
1298 self.data = None
1299 }
1300 }
1301
1302 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1303 self.filter_user_id_async(f).await;
1304 self
1305 }
1306
1307 pub fn filter_message_id(&mut self, f: impl FnOnce(i64) -> bool) {
1308 if let Some(data) = self.data
1309 && !f(data.message_id)
1310 {
1311 self.data = None
1312 }
1313 }
1314
1315 pub fn and_filter_message_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1316 self.filter_message_id(f);
1317 self
1318 }
1319
1320 pub async fn filter_message_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1321 if let Some(data) = self.data
1322 && !f(data.message_id).await
1323 {
1324 self.data = None
1325 }
1326 }
1327
1328 pub async fn and_filter_message_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1329 self.filter_message_id_async(f).await;
1330 self
1331 }
1332}
1333
1334#[derive(Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
1335pub struct NoticeEventNotify {
1336 group_id: i64,
1337 user_id: i64,
1338 #[serde(flatten)]
1339 data: NotifyType,
1340}
1341
1342impl NoticeEventNotify {
1343 #[cfg(feature = "selector")]
1344 pub fn selector(&'_ self) -> Selector<'_, Self> {
1345 Selector { data: Some(self) }
1346 }
1347}
1348
1349#[cfg(feature = "selector")]
1350impl<'a> Selector<'a, NoticeEventNotify> {
1351 pub fn filter(&mut self, f: impl FnOnce(&NoticeEventNotify) -> bool) {
1352 if let Some(data) = self.data
1353 && !f(data)
1354 {
1355 self.data = None
1356 }
1357 }
1358
1359 pub fn and_filter(mut self, f: impl FnOnce(&NoticeEventNotify) -> bool) -> Self {
1360 self.filter(f);
1361 self
1362 }
1363
1364 pub async fn filter_async(&mut self, f: impl AsyncFnOnce(&NoticeEventNotify) -> bool) {
1365 if let Some(data) = self.data
1366 && !f(data).await
1367 {
1368 self.data = None
1369 }
1370 }
1371
1372 pub async fn and_filter_async(mut self, f: impl AsyncFnOnce(&NoticeEventNotify) -> bool) -> Self {
1373 self.filter_async(f).await;
1374 self
1375 }
1376
1377 pub fn filter_group_id(&mut self, f: impl FnOnce(i64) -> bool) {
1378 if let Some(data) = self.data
1379 && !f(data.group_id)
1380 {
1381 self.data = None
1382 }
1383 }
1384
1385 pub fn and_filter_group_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1386 self.filter_group_id(f);
1387 self
1388 }
1389
1390 pub async fn filter_group_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1391 if let Some(data) = self.data
1392 && !f(data.group_id).await
1393 {
1394 self.data = None
1395 }
1396 }
1397
1398 pub async fn and_filter_group_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1399 self.filter_group_id_async(f).await;
1400 self
1401 }
1402
1403 pub fn filter_user_id(&mut self, f: impl FnOnce(i64) -> bool) {
1404 if let Some(data) = self.data
1405 && !f(data.user_id)
1406 {
1407 self.data = None
1408 }
1409 }
1410
1411 pub fn and_filter_user_id(mut self, f: impl FnOnce(i64) -> bool) -> Self {
1412 self.filter_user_id(f);
1413 self
1414 }
1415
1416 pub async fn filter_user_id_async(&mut self, f: impl AsyncFnOnce(i64) -> bool) {
1417 if let Some(data) = self.data
1418 && !f(data.user_id).await
1419 {
1420 self.data = None
1421 }
1422 }
1423
1424 pub async fn and_filter_user_id_async(mut self, f: impl AsyncFnOnce(i64) -> bool) -> Self {
1425 self.filter_user_id_async(f).await;
1426 self
1427 }
1428
1429 pub fn filter_data(&mut self, f: impl FnOnce(&NotifyType) -> bool) {
1430 if let Some(data) = self.data
1431 && !f(&data.data)
1432 {
1433 self.data = None
1434 }
1435 }
1436
1437 pub fn and_filter_data(mut self, f: impl FnOnce(&NotifyType) -> bool) -> Self {
1438 self.filter_data(f);
1439 self
1440 }
1441
1442 pub async fn filter_data_async(&mut self, f: impl AsyncFnOnce(&NotifyType) -> bool) {
1443 if let Some(data) = self.data
1444 && !f(&data.data).await
1445 {
1446 self.data = None
1447 }
1448 }
1449
1450 pub async fn and_filter_data_async(mut self, f: impl AsyncFnOnce(&NotifyType) -> bool) -> Self {
1451 self.filter_data_async(f).await;
1452 self
1453 }
1454}
1455
1456#[derive(Deserialize, Debug, Clone, Display, EnumIs, Ord, PartialOrd, Eq, PartialEq)]
1457#[serde(tag = "notice_type")]
1458pub enum NoticeEvent {
1459 #[serde(rename = "group_upload")]
1460 GroupUpload(NoticeEventGroupUpload),
1461
1462 #[serde(rename = "group_admin")]
1463 GroupAdmin(NoticeEventGroupAdmin),
1464
1465 #[serde(rename = "group_decrease")]
1466 GroupDecrease(NoticeEventGroupDecrease),
1467
1468 #[serde(rename = "group_increase")]
1469 GroupIncrease(NoticeEventGroupIncrease),
1470
1471 #[serde(rename = "group_ban")]
1472 GroupBan(NoticeEventGroupBan),
1473
1474 #[serde(rename = "friend_add")]
1475 FriendAdd(NoticeEventFriendAdd),
1476
1477 #[serde(rename = "group_recall")]
1478 GroupRecall(NoticeEventGroupRecall),
1479
1480 #[serde(rename = "friend_recall")]
1481 FriendRecall(NoticeEventFriendRecall),
1482
1483 #[serde(rename = "notify")]
1484 Notify(NoticeEventNotify),
1485}
1486
1487impl NoticeEvent {
1488 #[cfg(feature = "selector")]
1489 pub fn selector(&'_ self) -> Selector<'_, Self> {
1490 Selector { data: Some(self) }
1491 }
1492
1493 pub fn match_group_upload(&self) -> Option<&NoticeEventGroupUpload> {
1494 if let Self::GroupUpload(data) = self {
1495 Some(data)
1496 } else {
1497 None
1498 }
1499 }
1500
1501 pub fn on_group_upload<T>(
1502 &self,
1503 handler: impl FnOnce(&NoticeEventGroupUpload) -> T,
1504 ) -> Option<T> {
1505 if let Self::GroupUpload(data) = self {
1506 Some(handler(data))
1507 } else {
1508 None
1509 }
1510 }
1511
1512 pub async fn on_group_upload_async<T>(
1513 &self,
1514 handler: impl AsyncFnOnce(&NoticeEventGroupUpload) -> T,
1515 ) -> Option<T> {
1516 if let Self::GroupUpload(data) = self {
1517 Some(handler(data).await)
1518 } else {
1519 None
1520 }
1521 }
1522
1523 pub fn match_group_admin(&self) -> Option<&NoticeEventGroupAdmin> {
1524 if let Self::GroupAdmin(data) = self {
1525 Some(data)
1526 } else {
1527 None
1528 }
1529 }
1530
1531 pub fn on_group_admin<T>(&self, handler: impl FnOnce(&NoticeEventGroupAdmin) -> T) -> Option<T> {
1532 if let Self::GroupAdmin(data) = self {
1533 Some(handler(data))
1534 } else {
1535 None
1536 }
1537 }
1538
1539 pub async fn on_group_admin_async<T>(
1540 &self,
1541 handler: impl AsyncFnOnce(&NoticeEventGroupAdmin) -> T,
1542 ) -> Option<T> {
1543 if let Self::GroupAdmin(data) = self {
1544 Some(handler(data).await)
1545 } else {
1546 None
1547 }
1548 }
1549
1550 pub fn match_group_decrease(&self) -> Option<&NoticeEventGroupDecrease> {
1551 if let Self::GroupDecrease(data) = self {
1552 Some(data)
1553 } else {
1554 None
1555 }
1556 }
1557
1558 pub fn on_group_decrease<T>(
1559 &self,
1560 handler: impl FnOnce(&NoticeEventGroupDecrease) -> T,
1561 ) -> Option<T> {
1562 if let Self::GroupDecrease(data) = self {
1563 Some(handler(data))
1564 } else {
1565 None
1566 }
1567 }
1568
1569 pub async fn on_group_decrease_async<T>(
1570 &self,
1571 handler: impl AsyncFnOnce(&NoticeEventGroupDecrease) -> T,
1572 ) -> Option<T> {
1573 if let Self::GroupDecrease(data) = self {
1574 Some(handler(data).await)
1575 } else {
1576 None
1577 }
1578 }
1579
1580 pub fn match_group_increase(&self) -> Option<&NoticeEventGroupIncrease> {
1581 if let Self::GroupIncrease(data) = self {
1582 Some(data)
1583 } else {
1584 None
1585 }
1586 }
1587
1588 pub fn on_group_increase<T>(
1589 &self,
1590 handler: impl FnOnce(&NoticeEventGroupIncrease) -> T,
1591 ) -> Option<T> {
1592 if let Self::GroupIncrease(data) = self {
1593 Some(handler(data))
1594 } else {
1595 None
1596 }
1597 }
1598
1599 pub async fn on_group_increase_async<T>(
1600 &self,
1601 handler: impl AsyncFnOnce(&NoticeEventGroupIncrease) -> T,
1602 ) -> Option<T> {
1603 if let Self::GroupIncrease(data) = self {
1604 Some(handler(data).await)
1605 } else {
1606 None
1607 }
1608 }
1609
1610 pub fn match_group_ban(&self) -> Option<&NoticeEventGroupBan> {
1611 if let Self::GroupBan(data) = self {
1612 Some(data)
1613 } else {
1614 None
1615 }
1616 }
1617
1618 pub fn on_group_ban<T>(&self, handler: impl FnOnce(&NoticeEventGroupBan) -> T) -> Option<T> {
1619 if let Self::GroupBan(data) = self {
1620 Some(handler(data))
1621 } else {
1622 None
1623 }
1624 }
1625
1626 pub async fn on_group_ban_async<T>(
1627 &self,
1628 handler: impl AsyncFnOnce(&NoticeEventGroupBan) -> T,
1629 ) -> Option<T> {
1630 if let Self::GroupBan(data) = self {
1631 Some(handler(data).await)
1632 } else {
1633 None
1634 }
1635 }
1636
1637 pub fn match_friend_add(&self) -> Option<&NoticeEventFriendAdd> {
1638 if let Self::FriendAdd(data) = self {
1639 Some(data)
1640 } else {
1641 None
1642 }
1643 }
1644
1645 pub fn on_friend_add<T>(&self, handler: impl FnOnce(&NoticeEventFriendAdd) -> T) -> Option<T> {
1646 if let Self::FriendAdd(data) = self {
1647 Some(handler(data))
1648 } else {
1649 None
1650 }
1651 }
1652
1653 pub async fn on_friend_add_async<T>(
1654 &self,
1655 handler: impl AsyncFnOnce(&NoticeEventFriendAdd) -> T,
1656 ) -> Option<T> {
1657 if let Self::FriendAdd(data) = self {
1658 Some(handler(data).await)
1659 } else {
1660 None
1661 }
1662 }
1663
1664 pub fn match_group_recall(&self) -> Option<&NoticeEventGroupRecall> {
1665 if let Self::GroupRecall(data) = self {
1666 Some(data)
1667 } else {
1668 None
1669 }
1670 }
1671
1672 pub fn on_group_recall<T>(
1673 &self,
1674 handler: impl FnOnce(&NoticeEventGroupRecall) -> T,
1675 ) -> Option<T> {
1676 if let Self::GroupRecall(data) = self {
1677 Some(handler(data))
1678 } else {
1679 None
1680 }
1681 }
1682
1683 pub async fn on_group_recall_async<T>(
1684 &self,
1685 handler: impl AsyncFnOnce(&NoticeEventGroupRecall) -> T,
1686 ) -> Option<T> {
1687 if let Self::GroupRecall(data) = self {
1688 Some(handler(data).await)
1689 } else {
1690 None
1691 }
1692 }
1693
1694 pub fn match_friend_recall(&self) -> Option<&NoticeEventFriendRecall> {
1695 if let Self::FriendRecall(data) = self {
1696 Some(data)
1697 } else {
1698 None
1699 }
1700 }
1701
1702 pub fn on_friend_recall<T>(
1703 &self,
1704 handler: impl FnOnce(&NoticeEventFriendRecall) -> T,
1705 ) -> Option<T> {
1706 if let Self::FriendRecall(data) = self {
1707 Some(handler(data))
1708 } else {
1709 None
1710 }
1711 }
1712
1713 pub async fn on_friend_recall_async<T>(
1714 &self,
1715 handler: impl AsyncFnOnce(&NoticeEventFriendRecall) -> T,
1716 ) -> Option<T> {
1717 if let Self::FriendRecall(data) = self {
1718 Some(handler(data).await)
1719 } else {
1720 None
1721 }
1722 }
1723
1724 pub fn match_notify(&self) -> Option<&NoticeEventNotify> {
1725 if let Self::Notify(data) = self {
1726 Some(data)
1727 } else {
1728 None
1729 }
1730 }
1731
1732 pub fn on_notify<T>(&self, handler: impl FnOnce(&NoticeEventNotify) -> T) -> Option<T> {
1733 if let Self::Notify(data) = self {
1734 Some(handler(data))
1735 } else {
1736 None
1737 }
1738 }
1739
1740 pub async fn on_notify_async<T>(
1741 &self,
1742 handler: impl AsyncFnOnce(&NoticeEventNotify) -> T,
1743 ) -> Option<T> {
1744 if let Self::Notify(data) = self {
1745 Some(handler(data).await)
1746 } else {
1747 None
1748 }
1749 }
1750}
1751
1752#[cfg(feature = "selector")]
1753impl<'a> Selector<'a, NoticeEvent> {
1754 pub fn group_upload(&self) -> Selector<'a, NoticeEventGroupUpload> {
1755 Selector {
1756 data: self.data.and_then(|d| d.match_group_upload()),
1757 }
1758 }
1759
1760 pub fn group_admin(&self) -> Selector<'a, NoticeEventGroupAdmin> {
1761 Selector {
1762 data: self.data.and_then(|d| d.match_group_admin()),
1763 }
1764 }
1765
1766 pub fn group_decrease(&self) -> Selector<'a, NoticeEventGroupDecrease> {
1767 Selector {
1768 data: self.data.and_then(|d| d.match_group_decrease()),
1769 }
1770 }
1771
1772 pub fn group_increase(&self) -> Selector<'a, NoticeEventGroupIncrease> {
1773 Selector {
1774 data: self.data.and_then(|d| d.match_group_increase()),
1775 }
1776 }
1777
1778 pub fn group_ban(&self) -> Selector<'a, NoticeEventGroupBan> {
1779 Selector {
1780 data: self.data.and_then(|d| d.match_group_ban()),
1781 }
1782 }
1783
1784 pub fn friend_add(&self) -> Selector<'a, NoticeEventFriendAdd> {
1785 Selector {
1786 data: self.data.and_then(|d| d.match_friend_add()),
1787 }
1788 }
1789
1790 pub fn group_recall(&self) -> Selector<'a, NoticeEventGroupRecall> {
1791 Selector {
1792 data: self.data.and_then(|d| d.match_group_recall()),
1793 }
1794 }
1795
1796 pub fn friend_recall(&self) -> Selector<'a, NoticeEventFriendRecall> {
1797 Selector {
1798 data: self.data.and_then(|d| d.match_friend_recall()),
1799 }
1800 }
1801
1802 pub fn notify(&self) -> Selector<'a, NoticeEventNotify> {
1803 Selector {
1804 data: self.data.and_then(|d| d.match_notify()),
1805 }
1806 }
1807}