Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
d2602cb9
Commit
d2602cb9
authored
Jun 12, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce interface CodableMessage
parent
5941605a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
12 deletions
+49
-12
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/code/CodableMessage.kt
...ain/kotlin/net.mamoe.mirai/message/code/CodableMessage.kt
+33
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt
.../src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt
+4
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/AtAll.kt
...c/commonMain/kotlin/net.mamoe.mirai/message/data/AtAll.kt
+4
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Face.kt
...rc/commonMain/kotlin/net.mamoe.mirai/message/data/Face.kt
+2
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/HummerMessage.kt
...Main/kotlin/net.mamoe.mirai/message/data/HummerMessage.kt
+4
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
...c/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
+2
-1
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/code/CodableMessage.kt
0 → 100644
View file @
d2602cb9
/*
* Copyright 2020 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/master/LICENSE
*/
package
net.mamoe.mirai.message.code
import
net.mamoe.mirai.message.data.Message
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.SinceMirai
/**
* 可以使用 mirai 码表示的 [Message] 类型.
*
* 使用 `mirai-serialization` 中 `String.parseMiraiCode()` 转回 [Message].
*
* @suppress 警告: 此 API 可能在任何时刻被改变
*/
@MiraiExperimentalAPI
@SinceMirai
(
"1.1.0"
)
interface
CodableMessage
:
Message
{
/**
* 转换为 mirai 码.
*
* @suppress 警告: 此 API 可能在任何时刻被改变
*/
@MiraiExperimentalAPI
fun
toMiraiCode
():
String
=
this
.
toString
()
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt
View file @
d2602cb9
...
...
@@ -17,6 +17,7 @@ package net.mamoe.mirai.message.data
import
net.mamoe.mirai.LowLevelAPI
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.contact.nameCardOrNick
import
net.mamoe.mirai.message.code.CodableMessage
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmStatic
...
...
@@ -36,8 +37,7 @@ private constructor(
* "@群员名片"
*/
val
display
:
String
)
:
// don't change
MessageContent
{
)
:
MessageContent
,
CodableMessage
{
/**
* 构造一个 [At] 实例. 这是唯一的公开的构造方式.
...
...
@@ -67,9 +67,9 @@ private constructor(
// 自动为消息补充 " "
override
fun
followedBy
(
tail
:
Message
):
MessageChain
{
if
(
tail
is
PlainText
&&
tail
.
content
.
startsWith
(
' '
))
{
return
super
.
followedBy
(
tail
)
return
super
<
MessageContent
>
.
followedBy
(
tail
)
}
return
super
.
followedBy
(
PlainText
(
" "
))
+
tail
return
super
<
MessageContent
>
.
followedBy
(
PlainText
(
" "
))
+
tail
}
override
fun
hashCode
():
Int
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/AtAll.kt
View file @
d2602cb9
...
...
@@ -12,6 +12,7 @@
package
net.mamoe.mirai.message.data
import
net.mamoe.mirai.message.code.CodableMessage
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
...
...
@@ -26,7 +27,7 @@ private const val displayA = "@全体成员"
*/
object
AtAll
:
Message
.
Key
<
AtAll
>,
MessageContent
{
MessageContent
,
CodableMessage
{
const
val
display
=
displayA
override
val
typeName
:
String
get
()
=
"AtAll"
...
...
@@ -45,8 +46,8 @@ object AtAll :
// 自动为消息补充 " "
override
fun
followedBy
(
tail
:
Message
):
MessageChain
{
if
(
tail
is
PlainText
&&
tail
.
content
.
startsWith
(
' '
))
{
return
super
.
followedBy
(
tail
)
return
super
<
MessageContent
>
.
followedBy
(
tail
)
}
return
super
.
followedBy
(
PlainText
(
" "
))
+
tail
return
super
<
MessageContent
>
.
followedBy
(
PlainText
(
" "
))
+
tail
}
}
\ No newline at end of file
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Face.kt
View file @
d2602cb9
...
...
@@ -12,6 +12,7 @@
package
net.mamoe.mirai.message.data
import
net.mamoe.mirai.message.code.CodableMessage
import
net.mamoe.mirai.utils.PlannedRemoval
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
...
...
@@ -21,7 +22,7 @@ import kotlin.jvm.JvmSynthetic
* QQ 自带表情
*/
data class
Face
(
val
id
:
Int
)
:
// used in delegation
MessageContent
{
MessageContent
,
CodableMessage
{
override
fun
toString
():
String
=
"[mirai:face:$id]"
override
fun
contentToString
():
String
=
"[表情]"
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/HummerMessage.kt
View file @
d2602cb9
...
...
@@ -13,6 +13,7 @@
package
net.mamoe.mirai.message.data
import
net.mamoe.mirai.message.code.CodableMessage
import
net.mamoe.mirai.message.data.PokeMessage.Types
import
net.mamoe.mirai.message.data.VipFace.Companion
import
net.mamoe.mirai.utils.PlannedRemoval
...
...
@@ -49,7 +50,7 @@ data class PokeMessage internal constructor(
val
type
:
Int
,
val
id
:
Int
)
:
HummerMessage
()
{
)
:
HummerMessage
()
,
CodableMessage
{
@Suppress
(
"DEPRECATION_ERROR"
,
"DEPRECATION"
,
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
)
companion
object
Types
:
Message
.
Key
<
PokeMessage
>
{
override
val
typeName
:
String
...
...
@@ -159,7 +160,7 @@ data class VipFace internal constructor(
*/
val
kind
:
Kind
,
val
count
:
Int
)
:
HummerMessage
()
{
)
:
HummerMessage
()
,
CodableMessage
{
data class
Kind
(
val
id
:
Int
,
val
name
:
String
...
...
@@ -238,7 +239,7 @@ data class VipFace internal constructor(
*
* @see Image 查看图片相关信息
*/
sealed
class
FlashImage
:
MessageContent
,
HummerMessage
()
{
sealed
class
FlashImage
:
MessageContent
,
HummerMessage
()
,
CodableMessage
{
companion
object
Key
:
Message
.
Key
<
FlashImage
>
{
/**
* 将普通图片转换为闪照.
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
View file @
d2602cb9
...
...
@@ -25,6 +25,7 @@ import kotlinx.serialization.Serializable
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.message.code.CodableMessage
import
net.mamoe.mirai.utils.*
import
kotlin.js.JsName
import
kotlin.jvm.JvmMultifileClass
...
...
@@ -57,7 +58,7 @@ import kotlin.jvm.JvmSynthetic
* @see FlashImage 闪照
* @see Image.flash 转换普通图片为闪照
*/
expect
interface
Image
:
Message
,
MessageContent
{
expect
interface
Image
:
Message
,
MessageContent
,
CodableMessage
{
companion
object
Key
:
Message
.
Key
<
Image
>
{
override
val
typeName
:
String
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment