-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathVipFace.kt
116 lines (93 loc) · 3.27 KB
/
VipFace.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
package net.mamoe.mirai.message.data
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import net.mamoe.mirai.message.code.CodableMessage
import net.mamoe.mirai.message.data.VipFace.Kind
import net.mamoe.mirai.message.data.visitor.MessageVisitor
import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.safeCast
import kotlin.jvm.JvmField
/**
* VIP 表情.
*
* 不支持发送, 在发送时会变为纯文本.
*
* ## mirai 码支持
* 格式: [mirai:vipface:*[Kind.id]*,*[Kind.name]*,*[count]*]
*
* @see VipFace.Key 使用伴生对象中的常量
*/
@OptIn(MiraiExperimentalApi::class)
@Serializable
@SerialName(VipFace.SERIAL_NAME)
public data class VipFace @MiraiInternalApi constructor(
/**
* 使用 [Companion] 中常量.
*/
public val kind: Kind,
public val count: Int
) : HummerMessage, CodableMessage {
override val key: MessageKey<VipFace> get() = Key
@MiraiExperimentalApi
override fun appendMiraiCodeTo(builder: StringBuilder) {
builder.append("[mirai:vipface:").append(kind).append(',').append(count).append(']')
}
override fun toString(): String = "[mirai:vipface:$kind,$count]"
override fun contentToString(): String = "[${kind.name}]x$count"
@MiraiInternalApi
override fun <D, R> accept(visitor: MessageVisitor<D, R>, data: D): R {
return visitor.visitVipFace(this, data)
}
@Serializable
public data class Kind(
val id: Int,
val name: String
) {
public override fun toString(): String {
return "$id,$name"
}
}
public companion object Key :
AbstractPolymorphicMessageKey<HummerMessage, VipFace>(HummerMessage, { it.safeCast() }) {
public const val SERIAL_NAME: String = "VipFace"
@JvmField
public val LiuLian: Kind = 9 to "榴莲"
@JvmField
public val PingDiGuo: Kind = 1 to "平底锅"
@JvmField
public val ChaoPiao: Kind = 12 to "钞票"
@JvmField
public val LueLueLue: Kind = 10 to "略略略"
@JvmField
public val ZhuTou: Kind = 4 to "猪头"
@JvmField
public val BianBian: Kind = 6 to "便便"
@JvmField
public val ZhaDan: Kind = 5 to "炸弹"
@JvmField
public val AiXin: Kind = 2 to "爱心"
@JvmField
public val HaHa: Kind = 3 to "哈哈"
@JvmField
public val DianZan: Kind = 1 to "点赞"
@JvmField
public val QinQin: Kind = 7 to "亲亲"
@JvmField
public val YaoWan: Kind = 8 to "药丸"
@JvmField
public val values: Array<Kind> = arrayOf(
LiuLian, PingDiGuo, ChaoPiao, LueLueLue, ZhuTou,
BianBian, ZhaDan, AiXin, HaHa, DianZan, QinQin, YaoWan
)
private infix fun Int.to(name: String): Kind = Kind(this, name)
}
}