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
50934f9b
Commit
50934f9b
authored
Apr 29, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure binary compatibility until 1.1.0
parent
0de76149
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
28 deletions
+28
-28
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
...in/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
+2
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/type.kt
...commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/type.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt
.../src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt
+2
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/AtAll.kt
...c/commonMain/kotlin/net.mamoe.mirai/message/data/AtAll.kt
+2
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Face.kt
...rc/commonMain/kotlin/net.mamoe.mirai/message/data/Face.kt
+1
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
...commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
+20
-1
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/message.data/ConstrainSingleTest.kt
...otlin/net/mamoe/mirai/message.data/ConstrainSingleTest.kt
+0
-14
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/convension.kt
View file @
50934f9b
...
...
@@ -98,7 +98,7 @@ internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: B
}
when
(
it
)
{
is
PlainText
->
elements
.
add
(
ImMsgBody
.
Elem
(
text
=
ImMsgBody
.
Text
(
str
=
it
.
stringValue
)))
is
PlainText
->
elements
.
add
(
ImMsgBody
.
Elem
(
text
=
ImMsgBody
.
Text
(
str
=
it
.
content
)))
is
CustomMessage
->
{
@Suppress
(
"UNCHECKED_CAST"
)
elements
.
add
(
...
...
@@ -250,7 +250,7 @@ private fun MessageChain.cleanupRubbishMessageElements(): MessageChain {
}
if
(
last
is
VipFace
&&
element
is
PlainText
)
{
val
l
=
last
as
VipFace
if
(
element
.
length
==
4
+
(
l
.
count
/
10
)
+
l
.
kind
.
name
.
length
)
{
if
(
element
.
content
.
length
==
4
+
(
l
.
count
/
10
)
+
l
.
kind
.
name
.
length
)
{
last
=
element
return
@
forEach
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/type.kt
View file @
50934f9b
...
...
@@ -52,7 +52,7 @@ internal fun SingleMessage.estimateLength(upTo: Int): Int {
return
when
(
this
)
{
is
QuoteReply
->
444
+
this
.
source
.
originalMessage
.
estimateLength
(
upTo
)
// Magic number
is
Image
->
260
// Magic number
is
PlainText
->
stringValue
.
chineseLength
(
upTo
)
is
PlainText
->
content
.
chineseLength
(
upTo
)
is
At
->
display
.
chineseLength
(
upTo
)
is
AtAll
->
display
.
chineseLength
(
upTo
)
else
->
this
.
toString
().
chineseLength
(
upTo
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt
View file @
50934f9b
...
...
@@ -32,9 +32,7 @@ import kotlin.jvm.JvmSynthetic
data class
At
@Suppress
(
"DataClassPrivateConstructor"
)
private
constructor
(
val
target
:
Long
,
val
display
:
String
)
:
MessageContent
,
CharSequence
by
display
,
Comparable
<
String
>
by
display
{
MessageContent
{
/**
* 构造一个 [At] 实例. 这是唯一的公开的构造方式.
...
...
@@ -63,7 +61,7 @@ private constructor(val target: Long, val display: String) :
// 自动为消息补充 " "
override
fun
followedBy
(
tail
:
Message
):
MessageChain
{
if
(
tail
is
PlainText
&&
tail
.
stringValue
.
startsWith
(
' '
))
{
if
(
tail
is
PlainText
&&
tail
.
content
.
startsWith
(
' '
))
{
return
super
.
followedBy
(
tail
)
}
return
super
.
followedBy
(
PlainText
(
" "
))
+
tail
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/AtAll.kt
View file @
50934f9b
...
...
@@ -27,9 +27,7 @@ private const val displayA = "@全体成员"
*/
object
AtAll
:
Message
.
Key
<
AtAll
>,
MessageContent
,
CharSequence
by
displayA
,
Comparable
<
String
>
by
displayA
{
MessageContent
{
@SinceMirai
(
"0.31.2"
)
const
val
display
=
displayA
...
...
@@ -49,7 +47,7 @@ object AtAll :
// 自动为消息补充 " "
override
fun
followedBy
(
tail
:
Message
):
MessageChain
{
if
(
tail
is
PlainText
&&
tail
.
stringValue
.
startsWith
(
' '
))
{
if
(
tail
is
PlainText
&&
tail
.
content
.
startsWith
(
' '
))
{
return
super
.
followedBy
(
tail
)
}
return
super
.
followedBy
(
PlainText
(
" "
))
+
tail
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Face.kt
View file @
50934f9b
...
...
@@ -21,8 +21,7 @@ import kotlin.jvm.JvmName
data class
Face
@Suppress
(
"DataClassPrivateConstructor"
)
private
constructor
(
val
id
:
Int
,
private
val
stringValue
:
String
)
:
// used in delegation
MessageContent
,
CharSequence
by
stringValue
,
Comparable
<
String
>
by
stringValue
{
MessageContent
{
constructor
(
id
:
Int
)
:
this
(
id
,
"[mirai:face:$id]"
)
override
fun
toString
():
String
=
stringValue
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Message.kt
View file @
50934f9b
...
...
@@ -279,7 +279,7 @@ interface Message { // must be interface. Don't consider any changes.
@SinceMirai
(
"0.39.3"
)
fun
Message
.
isContentEmpty
():
Boolean
=
when
(
this
)
{
is
MessageMetadata
->
true
is
PlainText
->
this
.
stringValue
.
isEmpty
()
is
PlainText
->
this
.
content
.
isEmpty
()
is
MessageChain
->
this
.
all
{
it
.
isContentEmpty
()
}
else
->
false
}
...
...
@@ -339,6 +339,25 @@ interface SingleMessage : Message {
DeprecationLevel
.
ERROR
)
/* final */
override
infix
fun
eq
(
other
:
String
):
Boolean
=
this
.
contentToString
()
==
other
@PlannedRemoval
(
"1.1.0"
)
@JvmSynthetic
@SinceMirai
(
"1.0.0"
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
fun
length
():
Int
=
this
.
toString
().
length
@PlannedRemoval
(
"1.1.0"
)
@JvmSynthetic
@SinceMirai
(
"1.0.0"
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
fun
charAt
(
index
:
Int
):
Char
=
this
.
toString
()[
index
]
@PlannedRemoval
(
"1.1.0"
)
@JvmSynthetic
@SinceMirai
(
"1.0.0"
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
fun
subSequence
(
start
:
Int
,
end
:
Int
):
CharSequence
=
this
.
toString
().
subSequence
(
start
,
end
)
}
/**
...
...
mirai-core/src/commonTest/kotlin/net/mamoe/mirai/message.data/ConstrainSingleTest.kt
View file @
50934f9b
...
...
@@ -32,20 +32,6 @@ internal class TestConstrainSingleMessage : ConstrainSingle<TestConstrainSingleM
override
val
key
:
Message
.
Key
<
TestConstrainSingleMessage
>
get
()
=
Key
override
val
length
:
Int
get
()
=
TODO
(
"Not yet implemented"
)
override
fun
get
(
index
:
Int
):
Char
{
TODO
(
"Not yet implemented"
)
}
override
fun
subSequence
(
startIndex
:
Int
,
endIndex
:
Int
):
CharSequence
{
TODO
(
"Not yet implemented"
)
}
override
fun
compareTo
(
other
:
String
):
Int
{
TODO
(
"Not yet implemented"
)
}
}
@OptIn
(
MiraiExperimentalAPI
::
class
)
...
...
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