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
1d0b42df
Commit
1d0b42df
authored
Jul 31, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
01e887ff
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
54 additions
and
69 deletions
+54
-69
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/util.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/contact/util.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/conversions.kt
...n/kotlin/net/mamoe/mirai/qqandroid/message/conversions.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/offlineSourceImpl.kt
...in/net/mamoe/mirai/qqandroid/message/offlineSourceImpl.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/outgoingSourceImpl.kt
...n/net/mamoe/mirai/qqandroid/message/outgoingSourceImpl.kt
+1
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
...core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
+18
-5
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/CustomMessage.kt
...Main/kotlin/net.mamoe.mirai/message/data/CustomMessage.kt
+7
-10
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/ChunkedFlowSession.kt
...tlin/net.mamoe.mirai/utils/internal/ChunkedFlowSession.kt
+9
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/md5.common.kt
...nMain/kotlin/net.mamoe.mirai/utils/internal/md5.common.kt
+1
-9
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/BotConfiguration.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/BotConfiguration.kt
+2
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/FileCacheStrategy.jvm.kt
...ain/kotlin/net/mamoe/mirai/utils/FileCacheStrategy.jvm.kt
+1
-5
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.jvm.kt
...c/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.jvm.kt
+0
-3
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
+2
-2
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/DeferredReusableInput.jvm.kt
...t/mamoe/mirai/utils/internal/DeferredReusableInput.jvm.kt
+2
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/asReusableInput.jvm.kt
...lin/net/mamoe/mirai/utils/internal/asReusableInput.jvm.kt
+7
-6
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/md5.jvm.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/internal/md5.jvm.kt
+1
-4
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/retryCatching.jvm.kt
...otlin/net/mamoe/mirai/utils/internal/retryCatching.jvm.kt
+0
-17
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/util.kt
View file @
1d0b42df
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
)
@
file
:
Suppress
(
"INVISIBLE_MEMBER"
,
"INVISIBLE_REFERENCE"
)
package
net.mamoe.mirai.qqandroid.contact
package
net.mamoe.mirai.qqandroid.contact
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/conversions.kt
View file @
1d0b42df
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
OptIn
(
LowLevelAPI
::
class
)
@
file
:
OptIn
(
LowLevelAPI
::
class
)
@
file
:
Suppress
(
"EXPERIMENTAL_API_USAGE"
,
"DEPRECATION_ERROR"
)
@
file
:
Suppress
(
"EXPERIMENTAL_API_USAGE"
,
"DEPRECATION_ERROR"
)
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/offlineSourceImpl.kt
View file @
1d0b42df
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
"EXPERIMENTAL_API_USAGE"
,
"EXPERIMENTAL_OVERRIDE"
,
"INVISIBLE_REFERENCE"
,
"INVISIBLE_MEMBER"
)
@
file
:
Suppress
(
"EXPERIMENTAL_API_USAGE"
,
"EXPERIMENTAL_OVERRIDE"
,
"INVISIBLE_REFERENCE"
,
"INVISIBLE_MEMBER"
)
package
net.mamoe.mirai.qqandroid.message
package
net.mamoe.mirai.qqandroid.message
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/outgoingSourceImpl.kt
View file @
1d0b42df
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
"EXPERIMENTAL_API_USAGE"
,
"EXPERIMENTAL_OVERRIDE"
,
"INVISIBLE_REFERENCE"
,
"INVISIBLE_MEMBER"
)
@
file
:
Suppress
(
"EXPERIMENTAL_API_USAGE"
,
"EXPERIMENTAL_OVERRIDE"
,
"INVISIBLE_REFERENCE"
,
"INVISIBLE_MEMBER"
)
package
net.mamoe.mirai.qqandroid.message
package
net.mamoe.mirai.qqandroid.message
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
View file @
1d0b42df
...
@@ -14,6 +14,7 @@ import net.mamoe.mirai.contact.Friend
...
@@ -14,6 +14,7 @@ import net.mamoe.mirai.contact.Friend
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.data.*
import
net.mamoe.mirai.data.*
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.SinceMirai
import
net.mamoe.mirai.utils.WeakRef
import
net.mamoe.mirai.utils.WeakRef
/**
/**
...
@@ -125,7 +126,6 @@ public interface LowLevelBotAPIAccessor {
...
@@ -125,7 +126,6 @@ public interface LowLevelBotAPIAccessor {
* 处理一个账号请求添加机器人为好友的事件
* 处理一个账号请求添加机器人为好友的事件
*/
*/
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
public
suspend
fun
_lowLevelSolveNewFriendRequestEvent
(
public
suspend
fun
_lowLevelSolveNewFriendRequestEvent
(
eventId
:
Long
,
eventId
:
Long
,
fromId
:
Long
,
fromId
:
Long
,
...
@@ -138,7 +138,6 @@ public interface LowLevelBotAPIAccessor {
...
@@ -138,7 +138,6 @@ public interface LowLevelBotAPIAccessor {
* 处理被邀请加入一个群请求事件
* 处理被邀请加入一个群请求事件
*/
*/
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
public
suspend
fun
_lowLevelSolveBotInvitedJoinGroupRequestEvent
(
public
suspend
fun
_lowLevelSolveBotInvitedJoinGroupRequestEvent
(
eventId
:
Long
,
eventId
:
Long
,
invitorId
:
Long
,
invitorId
:
Long
,
...
@@ -150,7 +149,7 @@ public interface LowLevelBotAPIAccessor {
...
@@ -150,7 +149,7 @@ public interface LowLevelBotAPIAccessor {
* 处理账号请求加入群事件
* 处理账号请求加入群事件
*/
*/
@LowLevelAPI
@LowLevelAPI
@
MiraiExperimentalAPI
@
SinceMirai
(
"1.2.0"
)
public
suspend
fun
_lowLevelSolveMemberJoinRequestEvent
(
public
suspend
fun
_lowLevelSolveMemberJoinRequestEvent
(
eventId
:
Long
,
eventId
:
Long
,
fromId
:
Long
,
fromId
:
Long
,
...
@@ -165,6 +164,20 @@ public interface LowLevelBotAPIAccessor {
...
@@ -165,6 +164,20 @@ public interface LowLevelBotAPIAccessor {
* 查询语音的下载连接
* 查询语音的下载连接
*/
*/
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
@SinceMirai
(
"1.2.0"
)
public
suspend
fun
_lowLevelQueryGroupVoiceDownloadUrl
(
md5
:
ByteArray
,
groupId
:
Long
,
dstUin
:
Long
):
String
public
suspend
fun
_lowLevelQueryGroupVoiceDownloadUrl
(
md5
:
ByteArray
,
groupId
:
Long
,
dstUin
:
Long
):
String
/**
* 查询语音的上传连接
*/
@LowLevelAPI
@SinceMirai
(
"1.2.0"
)
public
suspend
fun
_lowLevelUploadVoice
(
md5
:
ByteArray
,
groupId
:
Long
,
)
}
}
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/CustomMessage.kt
View file @
1d0b42df
...
@@ -14,9 +14,7 @@ package net.mamoe.mirai.message.data
...
@@ -14,9 +14,7 @@ package net.mamoe.mirai.message.data
import
kotlinx.io.core.*
import
kotlinx.io.core.*
import
kotlinx.serialization.KSerializer
import
kotlinx.serialization.KSerializer
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.UnstableDefault
import
kotlinx.serialization.json.Json
import
kotlinx.serialization.json.Json
import
kotlinx.serialization.json.JsonConfiguration
import
kotlinx.serialization.protobuf.ProtoBuf
import
kotlinx.serialization.protobuf.ProtoBuf
import
kotlinx.serialization.protobuf.ProtoId
import
kotlinx.serialization.protobuf.ProtoId
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
...
@@ -90,8 +88,8 @@ public sealed class CustomMessage : SingleMessage {
...
@@ -90,8 +88,8 @@ public sealed class CustomMessage : SingleMessage {
*/
*/
public
abstract
fun
serializer
():
KSerializer
<
M
>
public
abstract
fun
serializer
():
KSerializer
<
M
>
public
override
fun
dump
(
message
:
M
):
ByteArray
=
ProtoBuf
.
dump
(
serializer
(),
message
)
public
override
fun
dump
(
message
:
M
):
ByteArray
=
ProtoBuf
.
encodeToByteArray
(
serializer
(),
message
)
public
override
fun
load
(
input
:
ByteArray
):
M
=
ProtoBuf
.
load
(
serializer
(),
input
)
public
override
fun
load
(
input
:
ByteArray
):
M
=
ProtoBuf
.
decodeFromByteArray
(
serializer
(),
input
)
}
}
/**
/**
...
@@ -106,11 +104,10 @@ public sealed class CustomMessage : SingleMessage {
...
@@ -106,11 +104,10 @@ public sealed class CustomMessage : SingleMessage {
*/
*/
public
abstract
fun
serializer
():
KSerializer
<
M
>
public
abstract
fun
serializer
():
KSerializer
<
M
>
@OptIn
(
UnstableDefault
::
class
)
public
open
val
json
:
Json
=
Json
.
Default
public
open
val
json
:
Json
=
Json
(
JsonConfiguration
.
Default
)
public
override
fun
dump
(
message
:
M
):
ByteArray
=
json
.
stringify
(
serializer
(),
message
).
toByteArray
()
public
override
fun
dump
(
message
:
M
):
ByteArray
=
json
.
encodeToString
(
serializer
(),
message
).
toByteArray
()
public
override
fun
load
(
input
:
ByteArray
):
M
=
json
.
parse
(
serializer
(),
String
(
input
))
public
override
fun
load
(
input
:
ByteArray
):
M
=
json
.
decodeFromString
(
serializer
(),
String
(
input
))
}
}
public
companion
object
Key
:
Message
.
Key
<
CustomMessage
>
{
public
companion
object
Key
:
Message
.
Key
<
CustomMessage
>
{
...
@@ -143,7 +140,7 @@ public sealed class CustomMessage : SingleMessage {
...
@@ -143,7 +140,7 @@ public sealed class CustomMessage : SingleMessage {
if
(
fullData
.
remaining
!=
length
.
toLong
())
{
if
(
fullData
.
remaining
!=
length
.
toLong
())
{
return
null
return
null
}
}
ProtoBuf
.
load
(
CustomMessageFullData
.
serializer
(),
fullData
.
readBytes
(
length
))
ProtoBuf
.
decodeFromByteArray
(
CustomMessageFullData
.
serializer
(),
fullData
.
readBytes
(
length
))
}.
getOrElse
{
}.
getOrElse
{
throw
CustomMessageFullDataDeserializeInternalException
(
it
)
throw
CustomMessageFullDataDeserializeInternalException
(
it
)
}
}
...
@@ -158,7 +155,7 @@ public sealed class CustomMessage : SingleMessage {
...
@@ -158,7 +155,7 @@ public sealed class CustomMessage : SingleMessage {
}
}
internal
fun
<
M
:
CustomMessage
>
dump
(
factory
:
Factory
<
M
>,
message
:
M
):
ByteArray
=
buildPacket
{
internal
fun
<
M
:
CustomMessage
>
dump
(
factory
:
Factory
<
M
>,
message
:
M
):
ByteArray
=
buildPacket
{
ProtoBuf
.
dump
(
ProtoBuf
.
encodeToByteArray
(
CustomMessageFullData
.
serializer
(),
CustomMessageFullData
(
CustomMessageFullData
.
serializer
(),
CustomMessageFullData
(
miraiVersionFlag
=
1
,
miraiVersionFlag
=
1
,
typeName
=
factory
.
typeName
,
typeName
=
factory
.
typeName
,
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/ChunkedFlowSession.kt
View file @
1d0b42df
...
@@ -15,16 +15,18 @@ import kotlinx.coroutines.flow.flow
...
@@ -15,16 +15,18 @@ import kotlinx.coroutines.flow.flow
import
kotlinx.coroutines.flow.flowOf
import
kotlinx.coroutines.flow.flowOf
import
kotlinx.coroutines.flow.map
import
kotlinx.coroutines.flow.map
import
kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.coroutines.io.ByteReadChannel
import
kotlinx.io.InputStream
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.Closeable
import
kotlinx.io.core.Closeable
import
kotlinx.io.core.Input
import
kotlinx.io.core.Input
import
kotlinx.serialization.InternalSerializationApi
import
kotlinx.serialization.InternalSerializationApi
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
java.io.InputStream
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmField
internal
interface
ChunkedFlowSession
<
T
>
:
Closeable
{
@MiraiExperimentalAPI
val
flow
:
Flow
<
T
>
public
interface
ChunkedFlowSession
<
T
>
:
Closeable
{
public
val
flow
:
Flow
<
T
>
override
fun
close
()
override
fun
close
()
}
}
...
@@ -39,7 +41,8 @@ internal inline fun <T, R> ChunkedFlowSession<T>.map(crossinline mapper: suspend
...
@@ -39,7 +41,8 @@ internal inline fun <T, R> ChunkedFlowSession<T>.map(crossinline mapper: suspend
/**
/**
* 由 [chunkedFlow] 分割得到的区块
* 由 [chunkedFlow] 分割得到的区块
*/
*/
internal
class
ChunkedInput
(
@MiraiExperimentalAPI
public
class
ChunkedInput
(
/**
/**
* 区块的数据.
* 区块的数据.
* 由 [ByteArrayPool] 缓存并管理, 只可在 [Flow.collect] 中访问.
* 由 [ByteArrayPool] 缓存并管理, 只可在 [Flow.collect] 中访问.
...
@@ -47,13 +50,13 @@ internal class ChunkedInput(
...
@@ -47,13 +50,13 @@ internal class ChunkedInput(
*
*
* **注意**: 不要将他带出 [Flow.collect] 作用域, 否则将造成内存泄露
* **注意**: 不要将他带出 [Flow.collect] 作用域, 否则将造成内存泄露
*/
*/
@JvmField
val
buffer
:
ByteArray
,
@JvmField
public
val
buffer
:
ByteArray
,
@JvmField
internal
var
size
:
Int
@JvmField
internal
var
size
:
Int
)
{
)
{
/**
/**
* [buffer] 的有效大小
* [buffer] 的有效大小
*/
*/
inline
val
bufferSize
:
Int
get
()
=
size
public
val
bufferSize
:
Int
get
()
=
size
}
}
/**
/**
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/md5.common.kt
View file @
1d0b42df
...
@@ -4,15 +4,7 @@ package net.mamoe.mirai.utils.internal
...
@@ -4,15 +4,7 @@ package net.mamoe.mirai.utils.internal
import
kotlinx.io.pool.DefaultPool
import
kotlinx.io.pool.DefaultPool
import
kotlinx.io.pool.ObjectPool
import
kotlinx.io.pool.ObjectPool
import
java.io.InputStream
internal
expect
abstract
class
InputStream
{
open
fun
available
():
Int
open
fun
close
()
abstract
fun
read
():
Int
open
fun
read
(
b
:
ByteArray
):
Int
open
fun
read
(
b
:
ByteArray
,
offset
:
Int
,
len
:
Int
):
Int
open
fun
skip
(
n
:
Long
):
Long
}
internal
expect
fun
InputStream
.
md5
():
ByteArray
internal
expect
fun
InputStream
.
md5
():
ByteArray
internal
expect
fun
ByteArray
.
md5
(
offset
:
Int
=
0
,
length
:
Int
=
this
.
size
-
offset
):
ByteArray
internal
expect
fun
ByteArray
.
md5
(
offset
:
Int
=
0
,
length
:
Int
=
this
.
size
-
offset
):
ByteArray
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/BotConfiguration.kt
View file @
1d0b42df
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
@
file
:
Suppress
(
"unused"
,
"DEPRECATION_ERROR"
,
"EXPOSED_SUPER_CLASS"
)
@
file
:
Suppress
(
"unused"
,
"DEPRECATION_ERROR"
,
"EXPOSED_SUPER_CLASS"
)
package
net.mamoe.mirai.utils
package
net.mamoe.mirai.utils
...
@@ -63,7 +64,7 @@ public actual open class BotConfiguration : BotConfigurationBase() { // open for
...
@@ -63,7 +64,7 @@ public actual open class BotConfiguration : BotConfigurationBase() { // open for
@SinceMirai
(
"1.2.0"
)
@SinceMirai
(
"1.2.0"
)
public
actual
fun
loadDeviceInfoJson
(
json
:
String
)
{
public
actual
fun
loadDeviceInfoJson
(
json
:
String
)
{
deviceInfo
=
{
context
->
deviceInfo
=
{
context
->
this
.
json
.
parse
(
DeviceInfoData
.
serializer
(),
json
).
also
{
it
.
context
=
context
}
this
.
json
.
decodeFromString
(
DeviceInfoData
.
serializer
(),
json
).
also
{
it
.
context
=
context
}
}
}
}
}
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/FileCacheStrategy.jvm.kt
View file @
1d0b42df
...
@@ -6,13 +6,9 @@ import kotlinx.io.core.*
...
@@ -6,13 +6,9 @@ import kotlinx.io.core.*
import
kotlinx.io.streams.asInput
import
kotlinx.io.streams.asInput
import
kotlinx.io.streams.asOutput
import
kotlinx.io.streams.asOutput
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.utils.internal.InputStream
import
net.mamoe.mirai.utils.internal.asReusableInput
import
net.mamoe.mirai.utils.internal.asReusableInput
import
java.awt.image.BufferedImage
import
java.awt.image.BufferedImage
import
java.io.ByteArrayOutputStream
import
java.io.*
import
java.io.File
import
java.io.IOException
import
java.io.OutputStream
import
java.net.URL
import
java.net.URL
import
java.security.MessageDigest
import
java.security.MessageDigest
import
java.util.*
import
java.util.*
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/LoginSolver.jvm.kt
View file @
1d0b42df
...
@@ -30,9 +30,6 @@ import java.io.RandomAccessFile
...
@@ -30,9 +30,6 @@ import java.io.RandomAccessFile
import
javax.imageio.ImageIO
import
javax.imageio.ImageIO
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
internal
actual
typealias
Throws
=
kotlin
.
jvm
.
Throws
/**
/**
* 自动选择 [SwingSolver] 或 [StandardCharImageLoginSolver]
* 自动选择 [SwingSolver] 或 [StandardCharImageLoginSolver]
*/
*/
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
View file @
1d0b42df
...
@@ -24,10 +24,10 @@ import kotlin.random.nextInt
...
@@ -24,10 +24,10 @@ import kotlin.random.nextInt
public
fun
File
.
loadAsDeviceInfo
(
json
:
Json
,
context
:
Context
=
ContextImpl
()):
DeviceInfo
{
public
fun
File
.
loadAsDeviceInfo
(
json
:
Json
,
context
:
Context
=
ContextImpl
()):
DeviceInfo
{
if
(!
this
.
exists
()
||
this
.
length
()
==
0L
)
{
if
(!
this
.
exists
()
||
this
.
length
()
==
0L
)
{
return
SystemDeviceInfo
(
context
).
also
{
return
SystemDeviceInfo
(
context
).
also
{
this
.
writeText
(
json
.
stringify
(
SystemDeviceInfo
.
serializer
(),
it
))
this
.
writeText
(
json
.
encodeToString
(
SystemDeviceInfo
.
serializer
(),
it
))
}
}
}
}
return
json
.
parse
(
DeviceInfoData
.
serializer
(),
this
.
readText
()).
also
{
return
json
.
decodeFromString
(
DeviceInfoData
.
serializer
(),
this
.
readText
()).
also
{
it
.
context
=
context
it
.
context
=
context
}
}
}
}
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/DeferredReusableInput.jvm.kt
View file @
1d0b42df
...
@@ -6,6 +6,7 @@ import kotlinx.coroutines.withContext
...
@@ -6,6 +6,7 @@ import kotlinx.coroutines.withContext
import
kotlinx.io.core.Input
import
kotlinx.io.core.Input
import
net.mamoe.mirai.utils.FileCacheStrategy
import
net.mamoe.mirai.utils.FileCacheStrategy
import
java.awt.image.BufferedImage
import
java.awt.image.BufferedImage
import
java.io.InputStream
import
java.net.URL
import
java.net.URL
internal
actual
class
DeferredReusableInput
actual
constructor
(
internal
actual
class
DeferredReusableInput
actual
constructor
(
...
@@ -44,7 +45,7 @@ internal actual class DeferredReusableInput actual constructor(
...
@@ -44,7 +45,7 @@ internal actual class DeferredReusableInput actual constructor(
return
delegate
?.
writeTo
(
out
)
?:
error
(
"DeferredReusableInput not yet initialized"
)
return
delegate
?.
writeTo
(
out
)
?:
error
(
"DeferredReusableInput not yet initialized"
)
}
}
override
fun
asInput
():
Input
{
override
fun
asInput
():
Input
Stream
{
return
delegate
?.
asInput
()
?:
error
(
"DeferredReusableInput not yet initialized"
)
return
delegate
?.
asInput
()
?:
error
(
"DeferredReusableInput not yet initialized"
)
}
}
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/asReusableInput.jvm.kt
View file @
1d0b42df
...
@@ -8,6 +8,7 @@ import kotlinx.io.core.ByteReadPacket
...
@@ -8,6 +8,7 @@ import kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.Input
import
kotlinx.io.core.Input
import
kotlinx.io.streams.asInput
import
kotlinx.io.streams.asInput
import
net.mamoe.mirai.message.data.toLongUnsigned
import
net.mamoe.mirai.message.data.toLongUnsigned
import
java.io.ByteArrayInputStream
import
java.io.File
import
java.io.File
import
java.io.InputStream
import
java.io.InputStream
...
@@ -36,8 +37,8 @@ internal actual fun ByteArray.asReusableInput(): ReusableInput {
...
@@ -36,8 +37,8 @@ internal actual fun ByteArray.asReusableInput(): ReusableInput {
return
this
@
asReusableInput
.
size
.
toLongUnsigned
()
return
this
@
asReusableInput
.
size
.
toLongUnsigned
()
}
}
override
fun
asInput
():
Input
{
override
fun
asInput
():
Input
Stream
{
return
Byte
ReadPacket
(
this
@
asReusableInput
)
return
Byte
ArrayInputStream
(
this
@
asReusableInput
)
}
}
}
}
}
}
...
@@ -62,8 +63,8 @@ internal fun File.asReusableInput(deleteOnClose: Boolean): ReusableInput {
...
@@ -62,8 +63,8 @@ internal fun File.asReusableInput(deleteOnClose: Boolean): ReusableInput {
return
inputStream
().
use
{
it
.
copyTo
(
out
)
}
return
inputStream
().
use
{
it
.
copyTo
(
out
)
}
}
}
override
fun
asInput
():
Input
{
override
fun
asInput
():
Input
Stream
{
return
inputStream
()
.
asInput
()
return
inputStream
()
}
}
}
}
}
}
...
@@ -88,8 +89,8 @@ internal fun File.asReusableInput(deleteOnClose: Boolean, md5: ByteArray): Reusa
...
@@ -88,8 +89,8 @@ internal fun File.asReusableInput(deleteOnClose: Boolean, md5: ByteArray): Reusa
return
inputStream
().
use
{
it
.
copyTo
(
out
)
}
return
inputStream
().
use
{
it
.
copyTo
(
out
)
}
}
}
override
fun
asInput
():
Input
{
override
fun
asInput
():
Input
Stream
{
return
inputStream
()
.
asInput
()
return
inputStream
()
}
}
}
}
}
}
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/md5.jvm.kt
View file @
1d0b42df
...
@@ -17,7 +17,4 @@ internal actual fun InputStream.md5(): ByteArray {
...
@@ -17,7 +17,4 @@ internal actual fun InputStream.md5(): ByteArray {
digest
.
update
(
buf
,
0
,
len
)
digest
.
update
(
buf
,
0
,
len
)
}
}
return
digest
.
digest
()
return
digest
.
digest
()
}
}
\ No newline at end of file
@Suppress
(
"ACTUAL_WITHOUT_EXPECT"
)
internal
actual
typealias
InputStream
=
java
.
io
.
InputStream
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/retryCatching.jvm.kt
deleted
100644 → 0
View file @
01e887ff
package
net.mamoe.mirai.utils.internal
private
var
isAddSuppressedSupported
:
Boolean
=
true
internal
actual
fun
Throwable
.
addSuppressedMirai
(
e
:
Throwable
)
{
if
(
this
==
e
)
{
return
}
if
(!
isAddSuppressedSupported
)
{
return
}
try
{
this
.
addSuppressed
(
e
)
}
catch
(
e
:
Exception
)
{
isAddSuppressedSupported
=
false
}
}
\ 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