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
80a6d1bc
Commit
80a6d1bc
authored
Jan 10, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace all deprecated api usages
parent
d1419824
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
59 additions
and
59 deletions
+59
-59
UpdateLog.md
UpdateLog.md
+5
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt
...qandroid/network/protocol/packet/OutgoingPacketAndroid.kt
+7
-7
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
.../mirai/qqandroid/network/protocol/packet/PacketFactory.kt
+2
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
...ai/qqandroid/network/protocol/packet/login/LoginPacket.kt
+4
-2
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/TIMPCBot.kt
...c/src/commonMain/kotlin/net.mamoe.mirai.timpc/TIMPCBot.kt
+8
-9
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/ContactImpl.kt
...nMain/kotlin/net.mamoe.mirai.timpc/network/ContactImpl.kt
+14
-15
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
...n/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
+12
-13
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/event/EventPacketFactory.kt
...oe.mirai.timpc/network/packet/event/EventPacketFactory.kt
+1
-2
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/event/MemberKickEvent.kt
...mamoe.mirai.timpc/network/packet/event/MemberKickEvent.kt
+1
-2
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/event/MemberMute.kt
.../net.mamoe.mirai.timpc/network/packet/event/MemberMute.kt
+2
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
+2
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
...commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
+1
-2
No files found.
UpdateLog.md
View file @
80a6d1bc
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
开发版本. 频繁更新, 不保证高稳定性
开发版本. 频繁更新, 不保证高稳定性
## `0.11.0` *UNRELEASED*
### mirai-core
-
弃用
`BotAccount.id`
. 将来它可能会被改名成为邮箱等账号. QQ 号码需通过
`bot.uin`
获取.
-
`Gender`
由
`inline class`
改为 enum
## `0.10.6` *2020/1/8*
## `0.10.6` *2020/1/8*
TIMPC
TIMPC
-
Fix #27, 群成员找不到的问题
-
Fix #27, 群成员找不到的问题
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt
View file @
80a6d1bc
...
@@ -190,10 +190,10 @@ internal inline fun PacketFactory<*, *>.buildSessionOutgoingPacket(
...
@@ -190,10 +190,10 @@ internal inline fun PacketFactory<*, *>.buildSessionOutgoingPacket(
* Encryption method to be used for packet body.
* Encryption method to be used for packet body.
*/
*/
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
interface
EncryptMethod
{
inter
nal
inter
face
EncryptMethod
{
val
id
:
Int
val
id
:
Int
fun
makeBody
(
body
:
BytePacketBuilder
.()
->
Unit
):
ByteReadPacket
fun
makeBody
(
client
:
QQAndroidClient
,
body
:
BytePacketBuilder
.()
->
Unit
):
ByteReadPacket
}
}
internal
interface
EncryptMethodSessionKey
:
EncryptMethod
{
internal
interface
EncryptMethodSessionKey
:
EncryptMethod
{
...
@@ -211,7 +211,7 @@ internal interface EncryptMethodSessionKey : EncryptMethod {
...
@@ -211,7 +211,7 @@ internal interface EncryptMethodSessionKey : EncryptMethod {
* fully encrypted
* fully encrypted
* }
* }
*/
*/
override
fun
makeBody
(
body
:
BytePacketBuilder
.()
->
Unit
):
ByteReadPacket
=
buildPacket
{
override
fun
makeBody
(
client
:
QQAndroidClient
,
body
:
BytePacketBuilder
.()
->
Unit
):
ByteReadPacket
=
buildPacket
{
require
(
currentLoginState
==
2
||
currentLoginState
==
3
)
{
"currentLoginState must be either 2 or 3"
}
require
(
currentLoginState
==
2
||
currentLoginState
==
3
)
{
"currentLoginState must be either 2 or 3"
}
writeByte
(
1
)
// const
writeByte
(
1
)
// const
writeByte
(
if
(
currentLoginState
==
2
)
3
else
2
)
writeByte
(
if
(
currentLoginState
==
2
)
3
else
2
)
...
@@ -251,16 +251,16 @@ internal interface EncryptMethodECDH : EncryptMethod {
...
@@ -251,16 +251,16 @@ internal interface EncryptMethodECDH : EncryptMethod {
* byte[] [ECDH.publicKey]
* byte[] [ECDH.publicKey]
* byte[] encrypted `body()` by [ECDH.shareKey]
* byte[] encrypted `body()` by [ECDH.shareKey]
*/
*/
override
fun
makeBody
(
body
:
BytePacketBuilder
.()
->
Unit
):
ByteReadPacket
=
buildPacket
{
override
fun
makeBody
(
client
:
QQAndroidClient
,
body
:
BytePacketBuilder
.()
->
Unit
):
ByteReadPacket
=
buildPacket
{
writeByte
(
1
)
// const
writeByte
(
1
)
// const
writeByte
(
1
)
// const
writeByte
(
1
)
// const
writeFully
(
ByteArray
(
16
)
)
writeFully
(
client
.
randomKey
)
writeShort
(
258
)
// const
writeShort
(
258
)
// const
// writeShortLVByteArray("04 CB 36 66 98 56 1E 93 6E 80 C1 57 E0 74 CA B1 3B 0B B6 8D DE B2 82 45 48 A1 B1 8D D4 FB 61 22 AF E1 2F E4 8C 52 66 D8 D7 26 9D 76 51 A8 EB 6F E7".hexToBytes())
// writeShortLVByteArray("04 CB 36 66 98 56 1E 93 6E 80 C1 57 E0 74 CA B1 3B 0B B6 8D DE B2 82 45 48 A1 B1 8D D4 FB 61 22 AF E1 2F E4 8C 52 66 D8 D7 26 9D 76 51 A8 EB 6F E7".hexToBytes())
writeShortLVByteArray
(
ecdh
.
keyPair
.
publicKey
.
getEncoded
().
drop
(
23
).
take
(
49
).
toByteArray
().
also
{
writeShortLVByteArray
(
ecdh
.
keyPair
.
publicKey
.
getEncoded
().
drop
(
23
).
take
(
49
).
toByteArray
().
also
{
it
.
toUHexString
().
debugPrint
(
"PUBLIC KEY"
)
//
it.toUHexString().debugPrint("PUBLIC KEY")
check
(
it
[
0
].
toInt
()
==
0
x04
)
{
"Bad publicKey generated. Expected first element=0x04, got${it[0]}"
}
check
(
it
[
0
].
toInt
()
==
0
x04
)
{
"Bad publicKey generated. Expected first element=0x04, got${it[0]}"
}
//check(ecdh.calculateShareKeyByPeerPublicKey(it.adjustToPublicKey()).contentEquals(ecdh.keyPair.shareKey)) { "PublicKey Validation failed" }
//check(ecdh.calculateShareKeyByPeerPublicKey(it.adjustToPublicKey()).contentEquals(ecdh.keyPair.shareKey)) { "PublicKey Validation failed" }
})
})
...
@@ -296,7 +296,7 @@ internal fun BytePacketBuilder.writeOicqRequestPacket(
...
@@ -296,7 +296,7 @@ internal fun BytePacketBuilder.writeOicqRequestPacket(
packetId
:
PacketId
,
packetId
:
PacketId
,
bodyBlock
:
BytePacketBuilder
.()
->
Unit
bodyBlock
:
BytePacketBuilder
.()
->
Unit
)
{
)
{
val
body
=
encryptMethod
.
makeBody
(
bodyBlock
)
val
body
=
encryptMethod
.
makeBody
(
client
,
bodyBlock
)
// writeIntLVPacket(lengthOffset = { it + 4 }) {
// writeIntLVPacket(lengthOffset = { it + 4 }) {
// Head
// Head
writeByte
(
0
x02
)
// head
writeByte
(
0
x02
)
// head
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt
View file @
80a6d1bc
...
@@ -134,11 +134,11 @@ internal object KnownPacketFactories : List<PacketFactory<*, *>> by mutableListO
...
@@ -134,11 +134,11 @@ internal object KnownPacketFactories : List<PacketFactory<*, *>> by mutableListO
runCatching
{
runCatching
{
byteArrayBuffer
.
decryptBy
(
bot
.
client
.
ecdh
.
keyPair
.
shareKey
,
size
)
byteArrayBuffer
.
decryptBy
(
bot
.
client
.
ecdh
.
keyPair
.
shareKey
,
size
)
}.
getOrElse
{
}.
getOrElse
{
byteArrayBuffer
.
decryptBy
(
bot
.
client
.
tgtgt
Key
,
size
)
byteArrayBuffer
.
decryptBy
(
bot
.
client
.
random
Key
,
size
)
}
// 这里实际上应该用 privateKey(另一个random出来的key)
}
// 这里实际上应该用 privateKey(另一个random出来的key)
}
}
}
else
{
}
else
{
this
.
decryptBy
(
bot
.
client
.
tgtgt
Key
,
0
,
this
.
readRemaining
-
1
)
this
.
decryptBy
(
bot
.
client
.
random
Key
,
0
,
this
.
readRemaining
-
1
)
}
}
packetFactory
.
decode
(
bot
,
data
.
toReadPacket
())
packetFactory
.
decode
(
bot
,
data
.
toReadPacket
())
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/LoginPacket.kt
View file @
80a6d1bc
...
@@ -187,9 +187,11 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
...
@@ -187,9 +187,11 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse, Log
val
client
=
bot
.
client
val
client
=
bot
.
client
val
subCommand
=
readShort
().
toInt
()
val
subCommand
=
readShort
().
toInt
()
println
(
"subCommand=$subCommand"
)
val
type
=
readByte
()
val
type
=
readByte
()
discardExact
(
3
)
println
(
"type=$subCommand"
)
val
tlvMap
=
this
.
readTLVMap
()
debugDiscardExact
(
3
)
val
tlvMap
:
Map
<
Int
,
ByteArray
>
=
this
.
readTLVMap
()
tlvMap
[
0
x150
]
?.
let
{
client
.
analysisTlv150
(
it
)
}
tlvMap
[
0
x150
]
?.
let
{
client
.
analysisTlv150
(
it
)
}
tlvMap
[
0
x161
]
?.
let
{
client
.
analysisTlv161
(
it
)
}
tlvMap
[
0
x161
]
?.
let
{
client
.
analysisTlv161
(
it
)
}
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/TIMPCBot.kt
View file @
80a6d1bc
...
@@ -11,7 +11,6 @@ import net.mamoe.mirai.data.Packet
...
@@ -11,7 +11,6 @@ import net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.ImageId0x03
import
net.mamoe.mirai.message.data.ImageId0x03
import
net.mamoe.mirai.message.data.ImageId0x06
import
net.mamoe.mirai.message.data.ImageId0x06
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.timpc.internal.RawGroupInfo
import
net.mamoe.mirai.timpc.internal.RawGroupInfo
import
net.mamoe.mirai.timpc.network.GroupImpl
import
net.mamoe.mirai.timpc.network.GroupImpl
import
net.mamoe.mirai.timpc.network.MemberImpl
import
net.mamoe.mirai.timpc.network.MemberImpl
...
@@ -89,14 +88,14 @@ internal abstract class TIMPCBotBase constructor(
...
@@ -89,14 +88,14 @@ internal abstract class TIMPCBotBase constructor(
}
}
final
override
suspend
fun
addFriend
(
id
:
Long
,
message
:
String
?,
remark
:
String
?):
AddFriendResult
{
final
override
suspend
fun
addFriend
(
id
:
Long
,
message
:
String
?,
remark
:
String
?):
AddFriendResult
{
return
when
(
CanAddFriendPacket
(
qqAccount
,
id
,
sessionKey
).
sendAndExpect
<
CanAddFriendResponse
>())
{
return
when
(
CanAddFriendPacket
(
uin
,
id
,
sessionKey
).
sendAndExpect
<
CanAddFriendResponse
>())
{
is
CanAddFriendResponse
.
AlreadyAdded
->
AddFriendResult
.
ALREADY_ADDED
is
CanAddFriendResponse
.
AlreadyAdded
->
AddFriendResult
.
ALREADY_ADDED
is
CanAddFriendResponse
.
Rejected
->
AddFriendResult
.
REJECTED
is
CanAddFriendResponse
.
Rejected
->
AddFriendResult
.
REJECTED
is
CanAddFriendResponse
.
ReadyToAdd
,
is
CanAddFriendResponse
.
ReadyToAdd
,
is
CanAddFriendResponse
.
RequireVerification
->
{
is
CanAddFriendResponse
.
RequireVerification
->
{
val
key
=
RequestFriendAdditionKeyPacket
(
qqAccount
,
id
,
sessionKey
).
sendAndExpect
<
RequestFriendAdditionKeyPacket
.
Response
>().
key
val
key
=
RequestFriendAdditionKeyPacket
(
uin
,
id
,
sessionKey
).
sendAndExpect
<
RequestFriendAdditionKeyPacket
.
Response
>().
key
AddFriendPacket
.
RequestAdd
(
qqAccount
,
id
,
sessionKey
,
message
,
remark
,
key
).
sendAndExpect
<
AddFriendPacket
.
Response
>()
AddFriendPacket
.
RequestAdd
(
uin
,
id
,
sessionKey
,
message
,
remark
,
key
).
sendAndExpect
<
AddFriendPacket
.
Response
>()
AddFriendResult
.
WAITING_FOR_APPROVAL
AddFriendResult
.
WAITING_FOR_APPROVAL
}
//这个做的是需要验证消息的情况, 不确定 ReadyToAdd 的是啥
}
//这个做的是需要验证消息的情况, 不确定 ReadyToAdd 的是啥
...
@@ -114,7 +113,7 @@ internal abstract class TIMPCBotBase constructor(
...
@@ -114,7 +113,7 @@ internal abstract class TIMPCBotBase constructor(
}
}
final
override
suspend
fun
approveFriendAddRequest
(
id
:
Long
,
remark
:
String
?)
{
final
override
suspend
fun
approveFriendAddRequest
(
id
:
Long
,
remark
:
String
?)
{
AddFriendPacket
.
Approve
(
qqAccount
,
sessionKey
,
0
,
id
,
remark
).
sendAndExpect
<
AddFriendPacket
.
Response
>()
AddFriendPacket
.
Approve
(
uin
,
sessionKey
,
0
,
id
,
remark
).
sendAndExpect
<
AddFriendPacket
.
Response
>()
}
}
...
@@ -134,7 +133,7 @@ internal abstract class TIMPCBotBase constructor(
...
@@ -134,7 +133,7 @@ internal abstract class TIMPCBotBase constructor(
final
override
suspend
fun
getGroup
(
id
:
GroupId
):
Group
=
groups
.
delegate
.
getOrNull
(
id
.
value
)
?:
inline
{
final
override
suspend
fun
getGroup
(
id
:
GroupId
):
Group
=
groups
.
delegate
.
getOrNull
(
id
.
value
)
?:
inline
{
val
info
:
RawGroupInfo
=
try
{
val
info
:
RawGroupInfo
=
try
{
when
(
val
response
=
when
(
val
response
=
GroupPacket
.
QueryGroupInfo
(
qqAccount
,
id
.
toInternalId
(),
sessionKey
).
sendAndExpect
<
GroupPacket
.
InfoResponse
>())
{
GroupPacket
.
QueryGroupInfo
(
uin
,
id
.
toInternalId
(),
sessionKey
).
sendAndExpect
<
GroupPacket
.
InfoResponse
>())
{
is
RawGroupInfo
->
response
is
RawGroupInfo
->
response
is
GroupNotFound
->
throw
GroupNotFoundException
(
"id=${id.value}"
)
is
GroupNotFound
->
throw
GroupNotFoundException
(
"id=${id.value}"
)
else
->
assertUnreachable
()
else
->
assertUnreachable
()
...
@@ -152,7 +151,7 @@ internal abstract class TIMPCBotBase constructor(
...
@@ -152,7 +151,7 @@ internal abstract class TIMPCBotBase constructor(
private
suspend
inline
fun
getGroup0
(
id
:
Long
):
Group
=
private
suspend
inline
fun
getGroup0
(
id
:
Long
):
Group
=
groups
.
delegate
.
getOrNull
(
id
)
?:
inline
{
groups
.
delegate
.
getOrNull
(
id
)
?:
inline
{
val
info
:
RawGroupInfo
=
try
{
val
info
:
RawGroupInfo
=
try
{
GroupPacket
.
QueryGroupInfo
(
qqAccount
,
GroupId
(
id
).
toInternalId
(),
sessionKey
).
sendAndExpect
()
GroupPacket
.
QueryGroupInfo
(
uin
,
GroupId
(
id
).
toInternalId
(),
sessionKey
).
sendAndExpect
()
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
logStacktrace
()
e
.
logStacktrace
()
error
(
"Cannot obtain group info for id $id"
)
error
(
"Cannot obtain group info for id $id"
)
...
@@ -201,8 +200,8 @@ internal abstract class TIMPCBotBase constructor(
...
@@ -201,8 +200,8 @@ internal abstract class TIMPCBotBase constructor(
final
override
suspend
fun
Image
.
getLink
():
ImageLink
=
when
(
val
id
=
this
.
id
)
{
final
override
suspend
fun
Image
.
getLink
():
ImageLink
=
when
(
val
id
=
this
.
id
)
{
is
ImageId0x03
->
GroupImagePacket
.
RequestImageLink
(
qqAccount
,
sessionKey
,
id
).
sendAndExpect
<
GroupImageLink
>().
requireSuccess
()
is
ImageId0x03
->
GroupImagePacket
.
RequestImageLink
(
uin
,
sessionKey
,
id
).
sendAndExpect
<
GroupImageLink
>().
requireSuccess
()
is
ImageId0x06
->
FriendImagePacket
.
RequestImageLink
(
qqAccount
,
sessionKey
,
id
).
sendAndExpect
<
FriendImageLink
>()
is
ImageId0x06
->
FriendImagePacket
.
RequestImageLink
(
uin
,
sessionKey
,
id
).
sendAndExpect
<
FriendImageLink
>()
else
->
assertUnreachable
()
else
->
assertUnreachable
()
}
}
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/ContactImpl.kt
View file @
80a6d1bc
...
@@ -13,7 +13,6 @@ import net.mamoe.mirai.data.Profile
...
@@ -13,7 +13,6 @@ import net.mamoe.mirai.data.Profile
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.message.data.ImageId
import
net.mamoe.mirai.message.data.ImageId
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.timpc.TIMPCBot
import
net.mamoe.mirai.timpc.TIMPCBot
import
net.mamoe.mirai.timpc.internal.RawGroupInfo
import
net.mamoe.mirai.timpc.internal.RawGroupInfo
import
net.mamoe.mirai.timpc.network.packet.action.*
import
net.mamoe.mirai.timpc.network.packet.action.*
...
@@ -56,19 +55,19 @@ internal class GroupImpl internal constructor(bot: TIMPCBot, val groupId: GroupI
...
@@ -56,19 +55,19 @@ internal class GroupImpl internal constructor(bot: TIMPCBot, val groupId: GroupI
members
.
delegate
.
filteringGetOrAdd
({
it
.
id
==
id
})
{
MemberImpl
(
QQImpl
(
bot
,
id
,
coroutineContext
),
this
,
MemberPermission
.
MEMBER
,
coroutineContext
)
}
members
.
delegate
.
filteringGetOrAdd
({
it
.
id
==
id
})
{
MemberImpl
(
QQImpl
(
bot
,
id
,
coroutineContext
),
this
,
MemberPermission
.
MEMBER
,
coroutineContext
)
}
override
suspend
fun
sendMessage
(
message
:
MessageChain
)
{
override
suspend
fun
sendMessage
(
message
:
MessageChain
)
{
bot
.
sendPacket
(
GroupPacket
.
Message
(
bot
.
qqAccount
,
internalId
,
bot
.
sessionKey
,
message
))
bot
.
sendPacket
(
GroupPacket
.
Message
(
bot
.
uin
,
internalId
,
bot
.
sessionKey
,
message
))
}
}
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
ImageId
=
withTIMPCBot
{
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
ImageId
=
withTIMPCBot
{
val
userContext
=
coroutineContext
val
userContext
=
coroutineContext
val
response
=
GroupImagePacket
.
RequestImageId
(
bot
.
qqAccount
,
internalId
,
image
,
sessionKey
).
sendAndExpect
<
GroupImageResponse
>()
val
response
=
GroupImagePacket
.
RequestImageId
(
bot
.
uin
,
internalId
,
image
,
sessionKey
).
sendAndExpect
<
GroupImageResponse
>()
withContext
(
userContext
)
{
withContext
(
userContext
)
{
when
(
response
)
{
when
(
response
)
{
is
ImageUploadInfo
->
response
.
uKey
?.
let
{
uKey
->
is
ImageUploadInfo
->
response
.
uKey
?.
let
{
uKey
->
check
(
Http
.
postImage
(
check
(
Http
.
postImage
(
htcmd
=
"0x6ff0071"
,
htcmd
=
"0x6ff0071"
,
uin
=
bot
.
qqAccount
,
uin
=
bot
.
uin
,
groupId
=
GroupId
(
id
),
groupId
=
GroupId
(
id
),
imageInput
=
image
.
input
,
imageInput
=
image
.
input
,
inputSize
=
image
.
inputSize
,
inputSize
=
image
.
inputSize
,
...
@@ -87,11 +86,11 @@ internal class GroupImpl internal constructor(bot: TIMPCBot, val groupId: GroupI
...
@@ -87,11 +86,11 @@ internal class GroupImpl internal constructor(bot: TIMPCBot, val groupId: GroupI
}
}
override
suspend
fun
updateGroupInfo
():
GroupInfo
=
withTIMPCBot
{
override
suspend
fun
updateGroupInfo
():
GroupInfo
=
withTIMPCBot
{
GroupPacket
.
QueryGroupInfo
(
qqAccount
,
internalId
,
sessionKey
).
sendAndExpect
<
RawGroupInfo
>().
parseBy
(
this
@GroupImpl
).
also
{
info
=
it
}
GroupPacket
.
QueryGroupInfo
(
uin
,
internalId
,
sessionKey
).
sendAndExpect
<
RawGroupInfo
>().
parseBy
(
this
@GroupImpl
).
also
{
info
=
it
}
}
}
override
suspend
fun
quit
():
Boolean
=
withTIMPCBot
{
override
suspend
fun
quit
():
Boolean
=
withTIMPCBot
{
GroupPacket
.
QuitGroup
(
qqAccount
,
sessionKey
,
internalId
).
sendAndExpect
<
GroupPacket
.
QuitGroupResponse
>().
isSuccess
GroupPacket
.
QuitGroup
(
uin
,
sessionKey
,
internalId
).
sendAndExpect
<
GroupPacket
.
QuitGroupResponse
>().
isSuccess
}
}
@UseExperimental
(
MiraiInternalAPI
::
class
)
@UseExperimental
(
MiraiInternalAPI
::
class
)
...
@@ -114,16 +113,16 @@ internal class QQImpl @PublishedApi internal constructor(bot: TIMPCBot, override
...
@@ -114,16 +113,16 @@ internal class QQImpl @PublishedApi internal constructor(bot: TIMPCBot, override
override
val
bot
:
TIMPCBot
by
bot
.
unsafeWeakRef
()
override
val
bot
:
TIMPCBot
by
bot
.
unsafeWeakRef
()
override
suspend
fun
sendMessage
(
message
:
MessageChain
)
=
override
suspend
fun
sendMessage
(
message
:
MessageChain
)
=
bot
.
sendPacket
(
SendFriendMessagePacket
(
bot
.
qqAccount
,
id
,
bot
.
sessionKey
,
message
))
bot
.
sendPacket
(
SendFriendMessagePacket
(
bot
.
uin
,
id
,
bot
.
sessionKey
,
message
))
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
ImageId
=
withTIMPCBot
{
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
ImageId
=
withTIMPCBot
{
FriendImagePacket
.
RequestImageId
(
qqAccount
,
sessionKey
,
id
,
image
).
sendAndExpect
<
FriendImageResponse
>().
let
{
FriendImagePacket
.
RequestImageId
(
uin
,
sessionKey
,
id
,
image
).
sendAndExpect
<
FriendImageResponse
>().
let
{
when
(
it
)
{
when
(
it
)
{
is
FriendImageUKey
->
{
is
FriendImageUKey
->
{
check
(
check
(
Http
.
postImage
(
Http
.
postImage
(
htcmd
=
"0x6ff0070"
,
htcmd
=
"0x6ff0070"
,
uin
=
bot
.
qqAccount
,
uin
=
bot
.
uin
,
groupId
=
null
,
groupId
=
null
,
uKeyHex
=
it
.
uKey
.
toUHexString
(
""
),
uKeyHex
=
it
.
uKey
.
toUHexString
(
""
),
imageInput
=
image
.
input
,
imageInput
=
image
.
input
,
...
@@ -141,15 +140,15 @@ internal class QQImpl @PublishedApi internal constructor(bot: TIMPCBot, override
...
@@ -141,15 +140,15 @@ internal class QQImpl @PublishedApi internal constructor(bot: TIMPCBot, override
}
}
override
suspend
fun
queryProfile
():
Profile
=
withTIMPCBot
{
override
suspend
fun
queryProfile
():
Profile
=
withTIMPCBot
{
RequestProfileDetailsPacket
(
bot
.
qqAccount
,
id
,
sessionKey
).
sendAndExpect
<
RequestProfileDetailsResponse
>().
profile
RequestProfileDetailsPacket
(
bot
.
uin
,
id
,
sessionKey
).
sendAndExpect
<
RequestProfileDetailsResponse
>().
profile
}
}
override
suspend
fun
queryPreviousNameList
():
PreviousNameList
=
withTIMPCBot
{
override
suspend
fun
queryPreviousNameList
():
PreviousNameList
=
withTIMPCBot
{
QueryPreviousNamePacket
(
bot
.
qqAccount
,
sessionKey
,
id
).
sendAndExpect
()
QueryPreviousNamePacket
(
bot
.
uin
,
sessionKey
,
id
).
sendAndExpect
()
}
}
override
suspend
fun
queryRemark
():
FriendNameRemark
=
withTIMPCBot
{
override
suspend
fun
queryRemark
():
FriendNameRemark
=
withTIMPCBot
{
QueryFriendRemarkPacket
(
bot
.
qqAccount
,
sessionKey
,
id
).
sendAndExpect
()
QueryFriendRemarkPacket
(
bot
.
uin
,
sessionKey
,
id
).
sendAndExpect
()
}
}
@PublishedApi
@PublishedApi
...
@@ -177,7 +176,7 @@ internal data class MemberImpl(
...
@@ -177,7 +176,7 @@ internal data class MemberImpl(
require
(
durationSeconds
<=
30
*
24
*
3600
)
{
"duration must be no more than 30 days"
}
require
(
durationSeconds
<=
30
*
24
*
3600
)
{
"duration must be no more than 30 days"
}
if
(
permission
==
MemberPermission
.
OWNER
)
return
false
if
(
permission
==
MemberPermission
.
OWNER
)
return
false
val
operator
=
group
.
getMember
(
bot
.
qqAccount
)
val
operator
=
group
.
getMember
(
bot
.
uin
)
check
(
operator
.
id
!=
id
)
{
"The bot is the owner of group ${group.id}, it cannot mute itself!"
}
check
(
operator
.
id
!=
id
)
{
"The bot is the owner of group ${group.id}, it cannot mute itself!"
}
when
(
operator
.
permission
)
{
when
(
operator
.
permission
)
{
MemberPermission
.
MEMBER
->
return
false
MemberPermission
.
MEMBER
->
return
false
...
@@ -186,7 +185,7 @@ internal data class MemberImpl(
...
@@ -186,7 +185,7 @@ internal data class MemberImpl(
}
}
}
}
GroupPacket
.
Mute
(
qqAccount
,
group
.
internalId
,
sessionKey
,
id
,
durationSeconds
.
toUInt
()).
sendAndExpect
<
GroupPacket
.
MuteResponse
>()
GroupPacket
.
Mute
(
uin
,
group
.
internalId
,
sessionKey
,
id
,
durationSeconds
.
toUInt
()).
sendAndExpect
<
GroupPacket
.
MuteResponse
>()
return
true
return
true
}
}
...
@@ -196,6 +195,6 @@ internal data class MemberImpl(
...
@@ -196,6 +195,6 @@ internal data class MemberImpl(
}
}
override
suspend
fun
unmute
():
Unit
=
withTIMPCBot
{
override
suspend
fun
unmute
():
Unit
=
withTIMPCBot
{
GroupPacket
.
Mute
(
qqAccount
,
group
.
internalId
,
sessionKey
,
id
,
0
u
).
sendAndExpect
<
GroupPacket
.
MuteResponse
>()
GroupPacket
.
Mute
(
uin
,
group
.
internalId
,
sessionKey
,
id
,
0
u
).
sendAndExpect
<
GroupPacket
.
MuteResponse
>()
}
}
}
}
\ No newline at end of file
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
View file @
80a6d1bc
...
@@ -14,7 +14,6 @@ import net.mamoe.mirai.event.Subscribable
...
@@ -14,7 +14,6 @@ import net.mamoe.mirai.event.Subscribable
import
net.mamoe.mirai.event.broadcast
import
net.mamoe.mirai.event.broadcast
import
net.mamoe.mirai.event.events.BotLoginSucceedEvent
import
net.mamoe.mirai.event.events.BotLoginSucceedEvent
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.timpc.TIMPCBot
import
net.mamoe.mirai.timpc.TIMPCBot
import
net.mamoe.mirai.timpc.network.handler.DataPacketSocketAdapter
import
net.mamoe.mirai.timpc.network.handler.DataPacketSocketAdapter
import
net.mamoe.mirai.timpc.network.handler.TemporaryPacketHandler
import
net.mamoe.mirai.timpc.network.handler.TemporaryPacketHandler
...
@@ -178,7 +177,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -178,7 +177,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
loginResult
.
complete
(
LoginResult
.
TIMEOUT
)
loginResult
.
complete
(
LoginResult
.
TIMEOUT
)
}
}
}
}
sendPacket
(
TouchPacket
(
bot
.
qqAccount
,
serverIp
,
false
))
sendPacket
(
TouchPacket
(
bot
.
uin
,
serverIp
,
false
))
return
loginResult
.
await
()
return
loginResult
.
await
()
}
finally
{
}
finally
{
...
@@ -319,7 +318,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -319,7 +318,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
socket
.
sendPacket
(
socket
.
sendPacket
(
SubmitPasswordPacket
(
SubmitPasswordPacket
(
bot
=
bot
.
qqAccount
,
bot
=
bot
.
uin
,
passwordMd5
=
bot
.
account
.
passwordMd5
,
passwordMd5
=
bot
.
account
.
passwordMd5
,
loginTime
=
loginTime
,
loginTime
=
loginTime
,
loginIP
=
loginIP
,
loginIP
=
loginIP
,
...
@@ -349,7 +348,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -349,7 +348,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
socket
.
sendPacket
(
socket
.
sendPacket
(
SubmitPasswordPacket
(
SubmitPasswordPacket
(
bot
=
bot
.
qqAccount
,
bot
=
bot
.
uin
,
passwordMd5
=
bot
.
account
.
passwordMd5
,
passwordMd5
=
bot
.
account
.
passwordMd5
,
loginTime
=
loginTime
,
loginTime
=
loginTime
,
loginIP
=
loginIP
,
loginIP
=
loginIP
,
...
@@ -367,7 +366,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -367,7 +366,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
this
.
captchaCache
=
packet
.
captchaPart1
this
.
captchaCache
=
packet
.
captchaPart1
this
.
captchaSectionId
=
1
this
.
captchaSectionId
=
1
socket
.
sendPacket
(
CaptchaPacket
.
RequestTransmission
(
bot
.
qqAccount
,
this
.
token0825
,
this
.
captchaSectionId
++,
packet
.
token00BA
))
socket
.
sendPacket
(
CaptchaPacket
.
RequestTransmission
(
bot
.
uin
,
this
.
token0825
,
this
.
captchaSectionId
++,
packet
.
token00BA
))
}
}
is
CaptchaPacket
.
CaptchaResponse
.
Transmission
->
{
is
CaptchaPacket
.
CaptchaResponse
.
Transmission
->
{
...
@@ -393,19 +392,19 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -393,19 +392,19 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
this
.
captchaCache
=
null
this
.
captchaCache
=
null
if
(
code
==
null
||
code
.
length
!=
4
)
{
if
(
code
==
null
||
code
.
length
!=
4
)
{
this
.
captchaSectionId
=
1
//意味着正在刷新验证码
this
.
captchaSectionId
=
1
//意味着正在刷新验证码
socket
.
sendPacket
(
CaptchaPacket
.
Refresh
(
bot
.
qqAccount
,
token0825
))
socket
.
sendPacket
(
CaptchaPacket
.
Refresh
(
bot
.
uin
,
token0825
))
}
else
{
}
else
{
this
.
captchaSectionId
=
0
//意味着已经提交验证码
this
.
captchaSectionId
=
0
//意味着已经提交验证码
socket
.
sendPacket
(
CaptchaPacket
.
Submit
(
bot
.
qqAccount
,
token0825
,
code
,
packet
.
captchaToken
))
socket
.
sendPacket
(
CaptchaPacket
.
Submit
(
bot
.
uin
,
token0825
,
code
,
packet
.
captchaToken
))
}
}
}
else
{
}
else
{
socket
.
sendPacket
(
CaptchaPacket
.
RequestTransmission
(
bot
.
qqAccount
,
token0825
,
captchaSectionId
++,
packet
.
token00BA
))
socket
.
sendPacket
(
CaptchaPacket
.
RequestTransmission
(
bot
.
uin
,
token0825
,
captchaSectionId
++,
packet
.
token00BA
))
}
}
}
}
is
SubmitPasswordPacket
.
LoginResponse
.
Success
->
{
is
SubmitPasswordPacket
.
LoginResponse
.
Success
->
{
this
.
sessionResponseDecryptionKey
=
packet
.
sessionResponseDecryptionKey
this
.
sessionResponseDecryptionKey
=
packet
.
sessionResponseDecryptionKey
socket
.
sendPacket
(
RequestSessionPacket
(
bot
.
qqAccount
,
socket
.
serverIp
,
packet
.
token38
,
packet
.
token88
,
packet
.
encryptionKey
))
socket
.
sendPacket
(
RequestSessionPacket
(
bot
.
uin
,
socket
.
serverIp
,
packet
.
token38
,
packet
.
token88
,
packet
.
encryptionKey
))
}
}
//是ClientPasswordSubmissionPacket之后服务器回复的可能之一
//是ClientPasswordSubmissionPacket之后服务器回复的可能之一
...
@@ -414,7 +413,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -414,7 +413,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
socket
.
sendPacket
(
socket
.
sendPacket
(
SubmitPasswordPacket
(
SubmitPasswordPacket
(
bot
=
bot
.
qqAccount
,
bot
=
bot
.
uin
,
passwordMd5
=
bot
.
account
.
passwordMd5
,
passwordMd5
=
bot
.
account
.
passwordMd5
,
loginTime
=
loginTime
,
loginTime
=
loginTime
,
loginIP
=
loginIP
,
loginIP
=
loginIP
,
...
@@ -447,12 +446,12 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -447,12 +446,12 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
if
(
withTimeoutOrNull
(
configuration
.
heartbeatTimeoutMillis
)
{
if
(
withTimeoutOrNull
(
configuration
.
heartbeatTimeoutMillis
)
{
// FIXME: 2019/11/26 启动被挤掉线检测
// FIXME: 2019/11/26 启动被挤掉线检测
HeartbeatPacket
(
bot
.
qqAccount
,
sessionKey
).
sendAndExpect
<
HeartbeatPacketResponse
>()
HeartbeatPacket
(
bot
.
uin
,
sessionKey
).
sendAndExpect
<
HeartbeatPacketResponse
>()
}
==
null
)
{
}
==
null
)
{
// retry one time
// retry one time
if
(
withTimeoutOrNull
(
configuration
.
heartbeatTimeoutMillis
)
{
if
(
withTimeoutOrNull
(
configuration
.
heartbeatTimeoutMillis
)
{
HeartbeatPacket
(
bot
.
qqAccount
,
sessionKey
).
sendAndExpect
<
HeartbeatPacketResponse
>()
HeartbeatPacket
(
bot
.
uin
,
sessionKey
).
sendAndExpect
<
HeartbeatPacketResponse
>()
}
==
null
)
{
}
==
null
)
{
bot
.
logger
.
warning
(
"Heartbeat timed out"
)
bot
.
logger
.
warning
(
"Heartbeat timed out"
)
...
@@ -474,7 +473,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -474,7 +473,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
@Suppress
(
"MemberVisibilityCanBePrivate"
)
@Suppress
(
"MemberVisibilityCanBePrivate"
)
suspend
fun
setOnlineStatus
(
status
:
OnlineStatus
)
{
suspend
fun
setOnlineStatus
(
status
:
OnlineStatus
)
{
socket
.
sendPacket
(
ChangeOnlineStatusPacket
(
bot
.
qqAccount
,
sessionKey
,
status
))
socket
.
sendPacket
(
ChangeOnlineStatusPacket
(
bot
.
uin
,
sessionKey
,
status
))
}
}
fun
close
()
{
fun
close
()
{
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/event/EventPacketFactory.kt
View file @
80a6d1bc
...
@@ -8,7 +8,6 @@ import net.mamoe.mirai.network.BotNetworkHandler
...
@@ -8,7 +8,6 @@ import net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.data.Packet
import
net.mamoe.mirai.utils.NoLog
import
net.mamoe.mirai.utils.NoLog
import
net.mamoe.mirai.timpc.network.TIMPCBotNetworkHandler
import
net.mamoe.mirai.timpc.network.TIMPCBotNetworkHandler
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.timpc.network.packet.*
import
net.mamoe.mirai.timpc.network.packet.*
import
net.mamoe.mirai.utils.io.readIoBuffer
import
net.mamoe.mirai.utils.io.readIoBuffer
...
@@ -46,7 +45,7 @@ internal object EventPacketFactory : PacketFactory<Packet, SessionKey>(SessionKe
...
@@ -46,7 +45,7 @@ internal object EventPacketFactory : PacketFactory<Packet, SessionKey>(SessionKe
to
=
readUInt
().
toLong
(),
// clear semantic
to
=
readUInt
().
toLong
(),
// clear semantic
uniqueId
=
readIoBuffer
(
8
)
uniqueId
=
readIoBuffer
(
8
)
)
)
(
handler
as
TIMPCBotNetworkHandler
).
socket
.
sendPacket
(
EventPacketFactory
(
id
,
sequenceId
,
handler
.
bot
.
qqAccount
,
handler
.
sessionKey
,
eventIdentity
))
(
handler
as
TIMPCBotNetworkHandler
).
socket
.
sendPacket
(
EventPacketFactory
(
id
,
sequenceId
,
handler
.
bot
.
uin
,
handler
.
sessionKey
,
eventIdentity
))
discardExact
(
2
)
// 1F 40
discardExact
(
2
)
// 1F 40
return
with
(
matchEventPacketFactory
(
readUShort
()))
{
parse
(
handler
.
bot
,
eventIdentity
)
}.
also
{
return
with
(
matchEventPacketFactory
(
readUShort
()))
{
parse
(
handler
.
bot
,
eventIdentity
)
}.
also
{
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/event/MemberKickEvent.kt
View file @
80a6d1bc
...
@@ -8,7 +8,6 @@ import net.mamoe.mirai.Bot
...
@@ -8,7 +8,6 @@ import net.mamoe.mirai.Bot
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.data.EventPacket
import
net.mamoe.mirai.data.EventPacket
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.utils.io.*
import
net.mamoe.mirai.utils.io.*
/**
/**
...
@@ -54,7 +53,7 @@ internal object MemberGoneEventPacketHandler : KnownEventParserAndHandler<Member
...
@@ -54,7 +53,7 @@ internal object MemberGoneEventPacketHandler : KnownEventParserAndHandler<Member
discardExact
(
1
)
discardExact
(
1
)
val
id
=
readQQ
()
val
id
=
readQQ
()
if
(
id
==
bot
.
qqAccount
)
{
if
(
id
==
bot
.
uin
)
{
discardExact
(
1
)
discardExact
(
1
)
return
BeingKickEvent
(
group
,
group
.
getMember
(
readQQ
()))
return
BeingKickEvent
(
group
,
group
.
getMember
(
readQQ
()))
}
}
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/packet/event/MemberMute.kt
View file @
80a6d1bc
...
@@ -10,7 +10,6 @@ import net.mamoe.mirai.Bot
...
@@ -10,7 +10,6 @@ import net.mamoe.mirai.Bot
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.contact.Member
import
net.mamoe.mirai.data.*
import
net.mamoe.mirai.data.*
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.utils.io.debugPrintIfFail
import
net.mamoe.mirai.utils.io.debugPrintIfFail
import
net.mamoe.mirai.utils.io.readQQ
import
net.mamoe.mirai.utils.io.readQQ
import
net.mamoe.mirai.utils.io.readRemainingBytes
import
net.mamoe.mirai.utils.io.readRemainingBytes
...
@@ -78,13 +77,13 @@ internal object MemberMuteEventPacketParserAndHandler : KnownEventParserAndHandl
...
@@ -78,13 +77,13 @@ internal object MemberMuteEventPacketParserAndHandler : KnownEventParserAndHandl
val
durationSeconds
=
readUInt
().
toInt
()
val
durationSeconds
=
readUInt
().
toInt
()
if
(
durationSeconds
==
0
)
{
if
(
durationSeconds
==
0
)
{
if
(
memberQQ
==
bot
.
qqAccount
)
{
if
(
memberQQ
==
bot
.
uin
)
{
BeingUnmutedEvent
(
operator
)
BeingUnmutedEvent
(
operator
)
}
else
{
}
else
{
MemberUnmuteEvent
(
group
.
getMember
(
memberQQ
),
operator
)
MemberUnmuteEvent
(
group
.
getMember
(
memberQQ
),
operator
)
}
}
}
else
{
}
else
{
if
(
memberQQ
==
bot
.
qqAccount
)
{
if
(
memberQQ
==
bot
.
uin
)
{
BeingMutedEvent
(
durationSeconds
,
operator
)
BeingMutedEvent
(
durationSeconds
,
operator
)
}
else
{
}
else
{
MemberMuteEvent
(
group
.
getMember
(
memberQQ
),
durationSeconds
,
operator
)
MemberMuteEvent
(
group
.
getMember
(
memberQQ
),
durationSeconds
,
operator
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
View file @
80a6d1bc
...
@@ -41,7 +41,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
...
@@ -41,7 +41,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
fun
instanceWhose
(
qq
:
Long
):
Bot
{
fun
instanceWhose
(
qq
:
Long
):
Bot
{
instances
.
forEach
{
instances
.
forEach
{
if
(
it
.
qqAccount
==
qq
)
{
if
(
it
.
uin
==
qq
)
{
return
it
return
it
}
}
}
}
...
@@ -82,7 +82,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
...
@@ -82,7 +82,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
private
suspend
fun
reinitializeNetworkHandler
(
private
suspend
fun
reinitializeNetworkHandler
(
cause
:
Throwable
?
cause
:
Throwable
?
)
{
)
{
logger
.
info
(
"BotAccount: $
qqAccount
"
)
logger
.
info
(
"BotAccount: $
uin
"
)
logger
.
info
(
"Initializing BotNetworkHandler"
)
logger
.
info
(
"Initializing BotNetworkHandler"
)
try
{
try
{
if
(
::
_network
.
isInitialized
)
{
if
(
::
_network
.
isInitialized
)
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt
View file @
80a6d1bc
...
@@ -7,7 +7,6 @@ import net.mamoe.mirai.contact.MemberPermission
...
@@ -7,7 +7,6 @@ import net.mamoe.mirai.contact.MemberPermission
import
net.mamoe.mirai.event.BroadcastControllable
import
net.mamoe.mirai.event.BroadcastControllable
import
net.mamoe.mirai.message.data.At
import
net.mamoe.mirai.message.data.At
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.message.data.MessageChain
import
net.mamoe.mirai.qqAccount
import
net.mamoe.mirai.utils.unsafeWeakRef
import
net.mamoe.mirai.utils.unsafeWeakRef
@Suppress
(
"unused"
,
"NOTHING_TO_INLINE"
)
@Suppress
(
"unused"
,
"NOTHING_TO_INLINE"
)
...
@@ -37,5 +36,5 @@ class GroupMessage(
...
@@ -37,5 +36,5 @@ class GroupMessage(
override
val
shouldBroadcast
:
Boolean
override
val
shouldBroadcast
:
Boolean
get
()
=
bot
.
qqAccount
!=
sender
.
id
// 自己会收到自己发的消息
get
()
=
bot
.
uin
!=
sender
.
id
// 自己会收到自己发的消息
}
}
\ 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