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
2501cbb5
Commit
2501cbb5
authored
Apr 29, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure binary compatibility
parent
50934f9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
28 deletions
+24
-28
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
...in/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
+6
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/RichMessage.kt
...onMain/kotlin/net.mamoe.mirai/message/data/RichMessage.kt
+18
-25
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
View file @
2501cbb5
...
...
@@ -236,6 +236,7 @@ private fun MessageChain.cleanupRubbishMessageElements(): MessageChain {
var
last
:
SingleMessage
?
=
null
return
buildMessageChain
(
initialSize
=
this
.
count
())
{
this
@
cleanupRubbishMessageElements
.
forEach
{
element
->
@Suppress
(
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
)
if
(
last
is
LongMessage
&&
element
is
PlainText
)
{
if
(
element
==
UNSUPPORTED_MERGED_MESSAGE_PLAIN
)
{
last
=
element
...
...
@@ -347,16 +348,18 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
val
resId
=
this
.
firstIsInstanceOrNull
<
ImMsgBody
.
GeneralFlags
>()
?.
longTextResid
if
(
resId
!=
null
)
{
list
.
add
(
LongMessage
(
content
,
resId
))
// TODO: 2020/4/29 解析长消息
list
.
add
(
ServiceMessage
(
35
,
content
))
// resId
}
else
{
list
.
add
(
ForwardMessageInternal
(
content
))
// TODO: 2020/4/29 解析合并转发
list
.
add
(
ServiceMessage
(
35
,
content
))
}
}
// 104 新群员入群的消息
else
->
{
if
(
element
.
richMsg
.
serviceId
==
60
||
content
.
startsWith
(
"<?"
))
{
@Suppress
(
"DEPRECATION_ERROR"
)
@Suppress
(
"DEPRECATION_ERROR"
)
// bin comp
list
.
add
(
XmlMessage
(
element
.
richMsg
.
serviceId
,
content
))
}
else
list
.
add
(
ServiceMessage
(
element
.
richMsg
.
serviceId
,
content
))
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/RichMessage.kt
View file @
2501cbb5
...
...
@@ -13,7 +13,6 @@
package
net.mamoe.mirai.message.data
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.PlannedRemoval
import
net.mamoe.mirai.utils.SinceMirai
...
...
@@ -105,10 +104,8 @@ data class LightApp(override val content: String) : RichMessage {
/**
* 服务消息, 如 [XmlMessage].
*/
@MiraiExperimentalAPI
@SinceMirai
(
"0.37.3"
)
open
class
ServiceMessage
(
@MiraiExperimentalAPI
val
serviceId
:
Int
,
final
override
val
content
:
String
)
:
RichMessage
{
@Suppress
(
"DEPRECATION"
)
open
class
ServiceMessage
(
val
serviceId
:
Int
,
final
override
val
content
:
String
)
:
RichMessage
{
companion
object
Key
:
Message
.
Key
<
ServiceMessage
>
{
override
val
typeName
:
String
get
()
=
"ServiceMessage"
}
...
...
@@ -133,6 +130,8 @@ open class ServiceMessage(@MiraiExperimentalAPI val serviceId: Int, final overri
/**
* Json 消息.
*
* 由于 [serviceId] 不准确, 请使用 [ServiceMessage] 并手动指定 `serviceId`
*
* @see LightApp 一些 json 消息实际上是 [LightApp]
*/
@PlannedRemoval
(
"1.0.0"
)
...
...
@@ -156,6 +155,8 @@ constructor(content: String) : ServiceMessage(1, content) {
/**
* XML 消息, 如分享, 卡片等.
*
* 由于 [serviceId] 不准确, 请使用 [ServiceMessage] 并手动指定 `serviceId`
*
* @param serviceId 目前未知, 一般为 60
*
* @see buildXmlMessage 使用 DSL 构造一个 XML 消息
...
...
@@ -179,27 +180,6 @@ constructor(serviceId: Int = 60, content: String) : ServiceMessage(serviceId, co
}
}
/**
* 长消息.
*
* 不需要手动区分长消息和普通消息, 在 [Contact.sendMessage] 时会自动判断.
*/
@SinceMirai
(
"0.31.0"
)
@MiraiExperimentalAPI
class
LongMessage
internal
constructor
(
content
:
String
,
val
resId
:
String
)
:
ServiceMessage
(
35
,
content
)
{
companion
object
Key
:
Message
.
Key
<
LongMessage
>
{
override
val
typeName
:
String
get
()
=
"LongMessage"
}
}
/**
* 合并转发消息
* @suppress 此 API 非常不稳定
*/
@OptIn
(
MiraiExperimentalAPI
::
class
)
@SinceMirai
(
"0.39.0"
)
internal
class
ForwardMessageInternal
(
content
:
String
)
:
ServiceMessage
(
35
,
content
)
/*
commonElem=CommonElem#750141174 {
businessType=0x00000001(1)
...
...
@@ -293,3 +273,16 @@ class XmlMessageBuilder(
@Deprecated
(
"specify serviceId explicitly"
,
ReplaceWith
(
"buildXmlMessage(60, block)"
))
inline
fun
buildXmlMessage
(
block
:
@XmlMessageDsl
XmlMessageBuilder
.()
->
Unit
):
ServiceMessage
=
buildXmlMessage
(
60
,
block
)
@SinceMirai
(
"0.31.0"
)
@MiraiExperimentalAPI
internal
class
LongMessage
internal
constructor
(
content
:
String
,
val
resId
:
String
)
:
ServiceMessage
(
35
,
content
)
{
companion
object
Key
:
Message
.
Key
<
LongMessage
>
{
override
val
typeName
:
String
get
()
=
"LongMessage"
}
}
@OptIn
(
MiraiExperimentalAPI
::
class
)
@SinceMirai
(
"0.39.0"
)
internal
class
ForwardMessageInternal
(
content
:
String
)
:
ServiceMessage
(
35
,
content
)
\ No newline at end of file
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