1
+ package love.forte.simboot.annotation
2
+
3
+ import love.forte.simbot.Api4J
4
+ import love.forte.simbot.MutableAttributeMap
5
+ import love.forte.simbot.event.*
6
+
7
+ /* *
8
+ * 应用于 [@Filter][love.forte.simboot.annotation.Filter] 注解上的
9
+ * [Filter.by][love.forte.simboot.annotation.Filter.by] 参数,用于
10
+ * 通过参数构建一个当前 `Filter` 对应的过滤器实例。
11
+ *
12
+ * ```kotlin
13
+ * @Filter(by = FooAnnotationEventFilterFactory::class)
14
+ * suspend fun Event.onEvent() { ... }
15
+ * ```
16
+ *
17
+ * @author ForteScarlet
18
+ */
19
+ public interface AnnotationEventFilterFactory {
20
+
21
+
22
+ /* *
23
+ * 通过提供的监听函数和过滤器注解参数来解析并得到一个 [EventFilter] 实例。
24
+ *
25
+ * 如果需要跳过本次解析,可以直接返回一个 null。
26
+ *
27
+ * @see Filter.by
28
+ *
29
+ */
30
+ public fun resolveFilter (
31
+ listener : EventListener ,
32
+ listenerAttributes : MutableAttributeMap ,
33
+ filter : Filter ,
34
+ filters : Filters ,
35
+ ): EventFilter ?
36
+
37
+ }
38
+
39
+
40
+ /* *
41
+ * 应用于 [love.forte.simboot.annotation.Filter] 注解上用来直接处理对应注解的函数。
42
+ *
43
+ * 非挂起的阻塞实现参考 [BlockingAnnotationEventFilter].
44
+ *
45
+ * @see BlockingAnnotationEventFilter
46
+ * @author ForteScarlet
47
+ */
48
+ @Deprecated(" Unused" )
49
+ @Suppress(" KDocUnresolvedReference" )
50
+ public interface AnnotationEventFilter : EventFilter {
51
+
52
+ public fun init (listener : EventListener , filter : Filter , filters : Filters )
53
+
54
+
55
+ @Deprecated(" Unused" )
56
+ public enum class InitType {
57
+ INDEPENDENT ,
58
+ UNITED
59
+ }
60
+
61
+
62
+ override suspend fun test (context : EventListenerProcessingContext ): Boolean
63
+
64
+ }
65
+
66
+
67
+ /* *
68
+ * 应用于 [love.forte.simboot.annotation.Filter] 注解上用来直接处理对应注解的函数。
69
+ *
70
+ * 是阻塞的 [AnnotationEventFilter] 类型实现,主要用于为不支持挂起函数的实现方使用。
71
+ *
72
+ * @see AnnotationEventFilter
73
+ *
74
+ */
75
+ @Suppress(" DEPRECATION" )
76
+ @Deprecated(" Unused" )
77
+ @Api4J
78
+ public interface BlockingAnnotationEventFilter : AnnotationEventFilter , BlockingEventFilter {
79
+
80
+ /* *
81
+ * 过滤器的检测函数。通过 [EventProcessingContext] 来验证是否需要处理当前事件。
82
+ */
83
+ @Api4J
84
+ override fun testBlocking (): Boolean
85
+
86
+
87
+ /* *
88
+ * 过滤器的检测函数。通过 [EventProcessingContext] 来验证是否需要处理当前事件。
89
+ */
90
+ @JvmSynthetic
91
+ override suspend fun test (context : EventListenerProcessingContext ): Boolean = testBlocking()
92
+
93
+
94
+ }
0 commit comments