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
4261e201
Commit
4261e201
authored
Dec 24, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use BotConfiguration
parent
308988fa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
18 deletions
+19
-18
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
...n/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
+3
-4
mirai-core-timpc/src/jvmTest/kotlin/PacketDebugger.kt
mirai-core-timpc/src/jvmTest/kotlin/PacketDebugger.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt
....mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/OutputUtils.kt
...commonMain/kotlin/net.mamoe.mirai/utils/io/OutputUtils.kt
+4
-2
mirai-demos/mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo/MiraiService.kt
...roid/src/main/kotlin/net/mamoe/mirai/demo/MiraiService.kt
+10
-10
No files found.
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
View file @
4261e201
...
...
@@ -255,9 +255,8 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
if
(
e
.
cause
!
is
CancellationException
)
{
bot
.
logger
.
error
(
"Caught SendPacketInternalException: ${e.cause?.message}"
)
}
val
configuration
=
bot
.
configuration
delay
(
configuration
.
firstReconnectDelayMillis
)
bot
.
tryReinitializeNetworkHandler
(
configuration
,
e
)
delay
(
bot
.
configuration
.
firstReconnectDelayMillis
)
bot
.
tryReinitializeNetworkHandler
(
e
)
return
@
withContext
}
finally
{
buffer
.
release
(
IoBuffer
.
Pool
)
...
...
@@ -468,7 +467,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
}
==
null
)
{
bot
.
logger
.
warning
(
"Heartbeat timed out"
)
delay
(
configuration
.
firstReconnectDelayMillis
)
bot
.
tryReinitializeNetworkHandler
(
configuration
,
HeartbeatTimeoutException
())
bot
.
tryReinitializeNetworkHandler
(
HeartbeatTimeoutException
())
return
@
launch
}
}
...
...
mirai-core-timpc/src/jvmTest/kotlin/PacketDebugger.kt
View file @
4261e201
...
...
@@ -379,7 +379,7 @@ when (idHex.substring(0, 5)) {
internal
object
DebugNetworkHandler
:
BotNetworkHandler
(),
CoroutineScope
{
override
val
supervisor
:
CompletableJob
=
SupervisorJob
()
override
val
bot
:
Bot
=
TIMPC
.
run
{
this
@DebugNetworkHandler
.
Bot
(
qq
?:
0L
,
""
,
null
)
}
override
val
bot
:
Bot
=
TIMPC
.
Bot
(
qq
?:
0L
,
""
,
null
)
override
suspend
fun
login
()
{}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt
View file @
4261e201
...
...
@@ -22,6 +22,6 @@ class ReceiveFriendAddRequestEvent(
*
* @param remark 备注名, 不设置则需为 `null`
*/
@JvmOverloads
// TODO: 2019/12/17 协议抽象
@JvmOverloads
suspend
fun
approve
(
remark
:
String
?
=
null
):
Unit
=
qq
.
bot
.
approveFriendAddRequest
(
qq
.
id
,
remark
)
}
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/OutputUtils.kt
View file @
4261e201
...
...
@@ -33,11 +33,13 @@ fun BytePacketBuilder.writeShortLVByteArray(byteArray: ByteArray) {
this
.
writeFully
(
byteArray
)
}
fun
BytePacketBuilder
.
writeShortLVPacket
(
tag
:
UByte
?
=
null
,
lengthOffset
:
((
Long
)
->
Long
)?
=
null
,
builder
:
BytePacketBuilder
.()
->
Unit
)
=
fun
BytePacketBuilder
.
writeShortLVPacket
(
tag
:
UByte
?
=
null
,
lengthOffset
:
((
Long
)
->
Long
)?
=
null
,
builder
:
BytePacketBuilder
.()
->
Unit
)
:
Int
=
BytePacketBuilder
().
apply
(
builder
).
build
().
use
{
if
(
tag
!=
null
)
writeUByte
(
tag
)
writeUShort
((
lengthOffset
?.
invoke
(
it
.
remaining
)
?:
it
.
remaining
).
coerceAtMostOrFail
(
0
xFFFFL
).
toUShort
())
val
length
=
(
lengthOffset
?.
invoke
(
it
.
remaining
)
?:
it
.
remaining
).
coerceAtMostOrFail
(
0
xFFFFL
)
writeUShort
(
length
.
toUShort
())
writePacket
(
it
)
return
length
.
toInt
()
}
fun
BytePacketBuilder
.
writeUVarIntLVPacket
(
tag
:
UByte
?
=
null
,
lengthOffset
:
((
Long
)
->
Long
)?
=
null
,
builder
:
BytePacketBuilder
.()
->
Unit
)
=
...
...
mirai-demos/mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo/MiraiService.kt
View file @
4261e201
...
...
@@ -41,17 +41,17 @@ class MiraiService : Service() {
private
fun
login
(
qq
:
Long
,
pwd
:
String
)
{
GlobalScope
.
launch
{
mBot
=
TIMPC
.
Bot
(
qq
,
pwd
).
apply
{
mBot
=
TIMPC
.
Bot
(
qq
,
pwd
)
{
captchaSolver
=
{
val
bytes
=
it
.
readBytes
()
val
bitmap
=
BitmapFactory
.
decodeByteArray
(
bytes
,
0
,
bytes
.
size
)
mCaptchaDeferred
=
CompletableDeferred
()
mCallback
?.
get
()
?.
onCaptcha
(
bitmap
)
mCaptchaDeferred
.
await
()
}
}.
apply
{
try
{
login
{
captchaSolver
=
{
val
bytes
=
it
.
readBytes
()
val
bitmap
=
BitmapFactory
.
decodeByteArray
(
bytes
,
0
,
bytes
.
size
)
mCaptchaDeferred
=
CompletableDeferred
()
mCallback
?.
get
()
?.
onCaptcha
(
bitmap
)
mCaptchaDeferred
.
await
()
}
}
login
()
mCallback
?.
get
()
?.
onSuccess
()
}
catch
(
e
:
LoginFailedException
)
{
mCallback
?.
get
()
?.
onFailed
()
...
...
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