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
e3084c5f
Commit
e3084c5f
authored
Apr 29, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate `XmlMessage` and `JsonMessage` in favour of `ServiceMessage`
parent
4840a57b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
6 deletions
+45
-6
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
...in/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
+3
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/RichMessage.kt
...onMain/kotlin/net.mamoe.mirai/message/data/RichMessage.kt
+40
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/impl.kt
...rc/commonMain/kotlin/net.mamoe.mirai/message/data/impl.kt
+2
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
View file @
e3084c5f
...
@@ -338,7 +338,8 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
...
@@ -338,7 +338,8 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
/**
/**
* [JsonMessage]
* [JsonMessage]
*/
*/
1
->
list
.
add
(
JsonMessage
(
content
))
1
->
@Suppress
(
"DEPRECATION_ERROR"
)
list
.
add
(
JsonMessage
(
content
))
/**
/**
* [LongMessage], [ForwardMessage]
* [LongMessage], [ForwardMessage]
*/
*/
...
@@ -355,6 +356,7 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
...
@@ -355,6 +356,7 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
// 104 新群员入群的消息
// 104 新群员入群的消息
else
->
{
else
->
{
if
(
element
.
richMsg
.
serviceId
==
60
||
content
.
startsWith
(
"<?"
))
{
if
(
element
.
richMsg
.
serviceId
==
60
||
content
.
startsWith
(
"<?"
))
{
@Suppress
(
"DEPRECATION_ERROR"
)
list
.
add
(
XmlMessage
(
element
.
richMsg
.
serviceId
,
content
))
list
.
add
(
XmlMessage
(
element
.
richMsg
.
serviceId
,
content
))
}
else
list
.
add
(
ServiceMessage
(
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 @
e3084c5f
...
@@ -15,6 +15,7 @@ package net.mamoe.mirai.message.data
...
@@ -15,6 +15,7 @@ package net.mamoe.mirai.message.data
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.PlannedRemoval
import
net.mamoe.mirai.utils.SinceMirai
import
net.mamoe.mirai.utils.SinceMirai
import
kotlin.annotation.AnnotationTarget.*
import
kotlin.annotation.AnnotationTarget.*
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmMultifileClass
...
@@ -40,7 +41,12 @@ interface RichMessage : MessageContent {
...
@@ -40,7 +41,12 @@ interface RichMessage : MessageContent {
@MiraiExperimentalAPI
@MiraiExperimentalAPI
@SinceMirai
(
"0.30.0"
)
@SinceMirai
(
"0.30.0"
)
fun
share
(
url
:
String
,
title
:
String
?
=
null
,
content
:
String
?
=
null
,
coverUrl
:
String
?
=
null
):
XmlMessage
=
fun
share
(
url
:
String
,
title
:
String
?
=
null
,
content
:
String
?
=
null
,
coverUrl
:
String
?
=
null
):
ServiceMessage
=
buildXmlMessage
(
60
)
{
buildXmlMessage
(
60
)
{
templateId
=
12345
templateId
=
12345
serviceId
=
1
serviceId
=
1
...
@@ -61,6 +67,20 @@ interface RichMessage : MessageContent {
...
@@ -61,6 +67,20 @@ interface RichMessage : MessageContent {
}
}
}
}
@PlannedRemoval
(
"1.0.0"
)
@JvmName
(
"share"
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
@Suppress
(
"DEPRECATION_ERROR"
)
@MiraiExperimentalAPI
fun
shareDeprecated
(
url
:
String
,
title
:
String
?
=
null
,
content
:
String
?
=
null
,
coverUrl
:
String
?
=
null
):
XmlMessage
=
share
(
url
,
title
,
content
,
coverUrl
)
as
XmlMessage
override
val
typeName
:
String
override
val
typeName
:
String
get
()
=
"RichMessage"
get
()
=
"RichMessage"
}
}
...
@@ -120,8 +140,17 @@ open class ServiceMessage(@MiraiExperimentalAPI val serviceId: Int, final overri
...
@@ -120,8 +140,17 @@ open class ServiceMessage(@MiraiExperimentalAPI val serviceId: Int, final overri
*
*
* @see LightApp 一些 json 消息实际上是 [LightApp]
* @see LightApp 一些 json 消息实际上是 [LightApp]
*/
*/
@PlannedRemoval
(
"1.0.0"
)
@Deprecated
(
"use ServiceMessage with serviceId 1"
,
level
=
DeprecationLevel
.
ERROR
,
replaceWith
=
ReplaceWith
(
"ServiceMessage"
))
@Suppress
(
"DEPRECATION_ERROR"
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
class
JsonMessage
(
content
:
String
)
:
ServiceMessage
(
1
,
content
)
{
class
JsonMessage
@Deprecated
(
"use ServiceMessage with serviceId 1"
,
level
=
DeprecationLevel
.
ERROR
,
replaceWith
=
ReplaceWith
(
"ServiceMessage(1, content)"
))
constructor
(
content
:
String
)
:
ServiceMessage
(
1
,
content
)
{
@Suppress
(
"DEPRECATION"
)
@Suppress
(
"DEPRECATION"
)
companion
object
Key
:
Message
.
Key
<
JsonMessage
>
{
companion
object
Key
:
Message
.
Key
<
JsonMessage
>
{
override
val
typeName
:
String
get
()
=
"JsonMessage"
override
val
typeName
:
String
get
()
=
"JsonMessage"
...
@@ -136,7 +165,12 @@ class JsonMessage(content: String) : ServiceMessage(1, content) {
...
@@ -136,7 +165,12 @@ class JsonMessage(content: String) : ServiceMessage(1, content) {
*
*
* @see buildXmlMessage 使用 DSL 构造一个 XML 消息
* @see buildXmlMessage 使用 DSL 构造一个 XML 消息
*/
*/
@PlannedRemoval
(
"1.0.0"
)
@Deprecated
(
"use ServiceMessage with serviceId 1"
,
level
=
DeprecationLevel
.
ERROR
,
replaceWith
=
ReplaceWith
(
"ServiceMessage"
))
@MiraiExperimentalAPI
@MiraiExperimentalAPI
@Suppress
(
"DEPRECATION_ERROR"
)
@SinceMirai
(
"0.27.0"
)
@SinceMirai
(
"0.27.0"
)
class
XmlMessage
@MiraiExperimentalAPI
(
"Maybe replaced with an enum"
)
class
XmlMessage
@MiraiExperimentalAPI
(
"Maybe replaced with an enum"
)
constructor
(
serviceId
:
Int
=
60
,
content
:
String
)
:
ServiceMessage
(
serviceId
,
content
)
{
constructor
(
serviceId
:
Int
=
60
,
content
:
String
)
:
ServiceMessage
(
serviceId
,
content
)
{
...
@@ -182,10 +216,11 @@ commonElem=CommonElem#750141174 {
...
@@ -182,10 +216,11 @@ commonElem=CommonElem#750141174 {
/**
/**
* 构造一条 XML 消息
* 构造一条 XML 消息
*/
*/
@Suppress
(
"DEPRECATION_ERROR"
)
@JvmSynthetic
@JvmSynthetic
@SinceMirai
(
"0.27.0"
)
@SinceMirai
(
"0.27.0"
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
inline
fun
buildXmlMessage
(
serviceId
:
Int
,
block
:
@XmlMessageDsl
XmlMessageBuilder
.()
->
Unit
):
Xml
Message
=
inline
fun
buildXmlMessage
(
serviceId
:
Int
,
block
:
@XmlMessageDsl
XmlMessageBuilder
.()
->
Unit
):
Service
Message
=
XmlMessage
(
serviceId
,
XmlMessageBuilder
().
apply
(
block
).
text
)
XmlMessage
(
serviceId
,
XmlMessageBuilder
().
apply
(
block
).
text
)
@Target
(
CLASS
,
FUNCTION
,
TYPE
)
@Target
(
CLASS
,
FUNCTION
,
TYPE
)
...
@@ -261,4 +296,5 @@ class XmlMessageBuilder(
...
@@ -261,4 +296,5 @@ class XmlMessageBuilder(
@SinceMirai
(
"0.27.0"
)
@SinceMirai
(
"0.27.0"
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
@Deprecated
(
"specify serviceId explicitly"
,
ReplaceWith
(
"buildXmlMessage(60, block)"
))
@Deprecated
(
"specify serviceId explicitly"
,
ReplaceWith
(
"buildXmlMessage(60, block)"
))
inline
fun
buildXmlMessage
(
block
:
@XmlMessageDsl
XmlMessageBuilder
.()
->
Unit
):
XmlMessage
=
buildXmlMessage
(
60
,
block
)
inline
fun
buildXmlMessage
(
block
:
@XmlMessageDsl
XmlMessageBuilder
.()
->
Unit
):
ServiceMessage
=
buildXmlMessage
(
60
,
block
)
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/impl.kt
View file @
e3084c5f
...
@@ -198,7 +198,7 @@ internal inline fun <T> List<T>.indexOfFirst(offset: Int, predicate: (T) -> Bool
...
@@ -198,7 +198,7 @@ internal inline fun <T> List<T>.indexOfFirst(offset: Int, predicate: (T) -> Bool
@OptIn
(
MiraiExperimentalAPI
::
class
)
@OptIn
(
MiraiExperimentalAPI
::
class
)
@JvmSynthetic
@JvmSynthetic
@Suppress
(
"UNCHECKED_CAST"
)
@Suppress
(
"UNCHECKED_CAST"
,
"DEPRECATION_ERROR"
)
internal
fun
<
M
:
Message
>
MessageChain
.
firstOrNullImpl
(
key
:
Message
.
Key
<
M
>):
M
?
=
when
(
key
)
{
internal
fun
<
M
:
Message
>
MessageChain
.
firstOrNullImpl
(
key
:
Message
.
Key
<
M
>):
M
?
=
when
(
key
)
{
At
->
firstIsInstanceOrNull
<
At
>()
At
->
firstIsInstanceOrNull
<
At
>()
AtAll
->
firstIsInstanceOrNull
<
AtAll
>()
AtAll
->
firstIsInstanceOrNull
<
AtAll
>()
...
@@ -221,6 +221,7 @@ internal fun <M : Message> MessageChain.firstOrNullImpl(key: Message.Key<M>): M?
...
@@ -221,6 +221,7 @@ internal fun <M : Message> MessageChain.firstOrNullImpl(key: Message.Key<M>): M?
OnlineMessageSource
.
Incoming
.
FromFriend
->
firstIsInstanceOrNull
<
OnlineMessageSource
.
Incoming
.
FromFriend
>()
OnlineMessageSource
.
Incoming
.
FromFriend
->
firstIsInstanceOrNull
<
OnlineMessageSource
.
Incoming
.
FromFriend
>()
OnlineMessageSource
->
firstIsInstanceOrNull
<
OnlineMessageSource
>()
OnlineMessageSource
->
firstIsInstanceOrNull
<
OnlineMessageSource
>()
XmlMessage
->
firstIsInstanceOrNull
<
XmlMessage
>()
XmlMessage
->
firstIsInstanceOrNull
<
XmlMessage
>()
LongMessage
->
firstIsInstanceOrNull
()
JsonMessage
->
firstIsInstanceOrNull
<
JsonMessage
>()
JsonMessage
->
firstIsInstanceOrNull
<
JsonMessage
>()
RichMessage
->
firstIsInstanceOrNull
<
RichMessage
>()
RichMessage
->
firstIsInstanceOrNull
<
RichMessage
>()
LightApp
->
firstIsInstanceOrNull
<
LightApp
>()
LightApp
->
firstIsInstanceOrNull
<
LightApp
>()
...
...
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