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
2de767d4
Commit
2de767d4
authored
May 21, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unexpected exception thrown when no bot available on `Image.queryUrl()`
parent
12c38b94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
...c/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
+25
-13
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
...onMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
+1
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
View file @
2de767d4
...
...
@@ -71,6 +71,7 @@ expect interface Image : Message, MessageContent {
* - [FRIEND_IMAGE_ID_REGEX_2], 示例: `/000000000-3814297509-BFB7027B9354B8F899A062061D74E206`
*
* @see Image 使用 id 构造图片
* @see md5 得到图片文件 MD5
*/
val
imageId
:
String
...
...
@@ -80,9 +81,11 @@ expect interface Image : Message, MessageContent {
final override fun contentToString(): String = "[图片]"
*/
@Deprecated
(
"""
@Deprecated
(
"""
不要自行实现 Image, 它必须由协议模块实现, 否则会无法发送也无法解析.
"""
,
level
=
DeprecationLevel
.
HIDDEN
)
"""
,
level
=
DeprecationLevel
.
HIDDEN
)
@Suppress
(
"PropertyName"
)
@
get
:
JvmSynthetic
internal
val
DoNotImplementThisClass
:
Nothing
?
...
...
@@ -187,7 +190,7 @@ suspend fun Image.queryUrl(): String {
@Suppress
(
"DEPRECATION"
)
return
when
(
this
)
{
is
OnlineImage
->
this
.
originUrl
else
->
Bot
.
_instances
.
peekFirst
().
get
()
?.
queryImageUrl
(
this
)
else
->
Bot
.
_instances
.
peekFirst
()
?
.
get
()
?.
queryImageUrl
(
this
)
?:
error
(
"No Bot available to query image url"
)
}
}
...
...
@@ -207,7 +210,8 @@ internal const val ONLINE_OFFLINE_DEPRECATION_MESSAGE = """
@PlannedRemoval
(
"1.2.0"
)
// 改为 internal
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
WARNING
,
replaceWith
=
ReplaceWith
(
"Image"
,
"net.mamoe.mirai.message.data.Image"
)
)
...
...
@@ -226,7 +230,8 @@ interface OnlineImage : Image {
* 一般由 [Contact.uploadImage] 得到
*/
@PlannedRemoval
(
"1.2.0"
)
// 改为 internal
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
WARNING
,
replaceWith
=
ReplaceWith
(
"Image"
,
"net.mamoe.mirai.message.data.Image"
)
)
...
...
@@ -237,12 +242,13 @@ interface OfflineImage : Image {
}
@PlannedRemoval
(
"1.2.0"
)
// 删除
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
HIDDEN
)
@JvmSynthetic
suspend
fun
OfflineImage
.
queryUrl
():
String
{
return
Bot
.
_instances
.
peekFirst
().
get
()
?.
queryImageUrl
(
this
)
?:
error
(
"No Bot available to query image url"
)
return
Bot
.
_instances
.
peekFirst
()
?
.
get
()
?.
queryImageUrl
(
this
)
?:
error
(
"No Bot available to query image url"
)
}
/**
...
...
@@ -251,7 +257,8 @@ suspend fun OfflineImage.queryUrl(): String {
* @param imageId 参考 [Image.imageId]
*/
@PlannedRemoval
(
"1.2.0"
)
// 改为 internal
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
WARNING
,
replaceWith
=
ReplaceWith
(
"Image"
,
"net.mamoe.mirai.message.data.Image"
)
)
...
...
@@ -271,7 +278,8 @@ data class OfflineGroupImage(
* 接收消息时获取到的 [GroupImage]. 它可以直接获取下载链接 [originUrl]
*/
@PlannedRemoval
(
"1.2.0"
)
// 改为 internal
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
WARNING
,
replaceWith
=
ReplaceWith
(
"Image"
,
"net.mamoe.mirai.message.data.Image"
)
)
...
...
@@ -283,7 +291,8 @@ abstract class OnlineGroupImage : GroupImage(), OnlineImage
* @param imageId 参考 [Image.imageId]
*/
@PlannedRemoval
(
"1.2.0"
)
// 改为 internal
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
WARNING
,
replaceWith
=
ReplaceWith
(
"Image"
,
"net.mamoe.mirai.message.data.Image"
)
)
...
...
@@ -302,7 +311,8 @@ data class OfflineFriendImage(
* 接收消息时获取到的 [FriendImage]. 它可以直接获取下载链接 [originUrl]
*/
@PlannedRemoval
(
"1.2.0"
)
// 改为 internal
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
@Deprecated
(
ONLINE_OFFLINE_DEPRECATION_MESSAGE
,
level
=
DeprecationLevel
.
WARNING
,
replaceWith
=
ReplaceWith
(
"Image"
,
"net.mamoe.mirai.message.data.Image"
)
)
...
...
@@ -322,9 +332,11 @@ abstract class OnlineFriendImage : FriendImage(), OnlineImage
)
@MiraiInternalAPI
(
"Use Image instead"
)
sealed
class
AbstractImage
:
Image
{
@Deprecated
(
"""
@Deprecated
(
"""
不要自行实现 Image, 它必须由协议模块实现, 否则会无法发送也无法解析.
"""
,
level
=
DeprecationLevel
.
HIDDEN
)
"""
,
level
=
DeprecationLevel
.
HIDDEN
)
@Suppress
(
"PropertyName"
,
"DeprecatedCallableAddReplaceWith"
)
@
get
:
JvmSynthetic
final
override
val
DoNotImplementThisClass
:
Nothing
?
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
View file @
2de767d4
...
...
@@ -110,13 +110,12 @@ internal open class LockFreeLinkedList<E> {
}
}
open
fun
peekFirst
():
E
{
open
fun
peekFirst
():
E
?
{
return
head
.
iterateBeforeFirst
{
it
.
isValidElementNode
()
}
.
takeUnless
{
it
.
isTail
()
}
?.
nextNode
?.
nodeValue
?:
throw
NoSuchElementException
()
}
open
fun
removeLast
():
E
{
...
...
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