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
6cbc69cd
Commit
6cbc69cd
authored
Feb 24, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sequenceId for FriendMessage
parent
4d79a699
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
20 deletions
+72
-20
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+7
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/PbMessageSvc.kt
...ai/qqandroid/network/protocol/packet/chat/PbMessageSvc.kt
+29
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
...ndroid/network/protocol/packet/chat/receive/MessageSvc.kt
+32
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
...mmonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
+3
-7
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
6cbc69cd
...
@@ -542,7 +542,7 @@ internal class GroupImpl(
...
@@ -542,7 +542,7 @@ internal class GroupImpl(
if
(
event
.
isCancelled
)
{
if
(
event
.
isCancelled
)
{
throw
EventCancelledException
(
"cancelled by FriendMessageSendEvent"
)
throw
EventCancelledException
(
"cancelled by FriendMessageSendEvent"
)
}
}
lateinit
var
source
:
MessageSvc
.
PbSendMsg
.
MessageSourceFromSend
lateinit
var
source
:
MessageSvc
.
PbSendMsg
.
MessageSourceFromSend
Group
bot
.
network
.
run
{
bot
.
network
.
run
{
val
response
:
MessageSvc
.
PbSendMsg
.
Response
=
MessageSvc
.
PbSendMsg
.
ToGroup
(
val
response
:
MessageSvc
.
PbSendMsg
.
Response
=
MessageSvc
.
PbSendMsg
.
ToGroup
(
bot
.
client
,
bot
.
client
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
6cbc69cd
...
@@ -129,9 +129,15 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -129,9 +129,15 @@ internal abstract class QQAndroidBotBase constructor(
source
.
ensureSequenceIdAvailable
()
source
.
ensureSequenceIdAvailable
()
network
.
run
{
network
.
run
{
val
response
:
PbMessageSvc
.
PbMsgWithDraw
.
Response
=
val
response
:
PbMessageSvc
.
PbMsgWithDraw
.
Response
=
if
(
source
.
groupId
==
0L
)
{
PbMessageSvc
.
PbMsgWithDraw
.
Friend
(
bot
.
client
,
source
.
senderId
,
source
.
sequenceId
,
source
.
messageRandom
,
source
.
time
)
.
sendAndExpect
()
}
else
{
PbMessageSvc
.
PbMsgWithDraw
.
Group
(
bot
.
client
,
source
.
groupId
,
source
.
sequenceId
,
source
.
messageRandom
)
PbMessageSvc
.
PbMsgWithDraw
.
Group
(
bot
.
client
,
source
.
groupId
,
source
.
sequenceId
,
source
.
messageRandom
)
.
sendAndExpect
()
.
sendAndExpect
()
}
check
(
response
is
PbMessageSvc
.
PbMsgWithDraw
.
Response
.
Success
)
{
"Failed to recall message #${source.sequenceId}: $response"
}
check
(
response
is
PbMessageSvc
.
PbMsgWithDraw
.
Response
.
Success
)
{
"Failed to recall message #${source.sequenceId}: $response"
}
}
}
}
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/PbMessageSvc.kt
View file @
6cbc69cd
...
@@ -71,6 +71,35 @@ internal class PbMessageSvc {
...
@@ -71,6 +71,35 @@ internal class PbMessageSvc {
)
)
}
}
fun
Friend
(
client
:
QQAndroidClient
,
toUin
:
Long
,
messageSequenceId
:
Int
,
// 56639
messageRandom
:
Int
,
// 921878719
time
:
Long
,
messageType
:
Int
=
0
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
)
{
writeProtoBuf
(
MsgSvc
.
PbMsgWithDrawReq
.
serializer
(),
MsgSvc
.
PbMsgWithDrawReq
(
c2cWithDraw
=
listOf
(
MsgSvc
.
PbC2CMsgWithDrawReq
(
subCmd
=
1
,
msgInfo
=
listOf
(
MsgSvc
.
PbC2CMsgWithDrawReq
.
MsgInfo
(
fromUin
=
client
.
bot
.
uin
,
toUin
=
toUin
,
msgSeq
=
messageSequenceId
,
msgUid
=
messageRandom
.
toLong
()
and
0
xffffffff
,
msgTime
=
time
and
0
xffffffff
)
)
)
)
)
)
}
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
Response
{
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
):
Response
{
val
resp
=
readProtoBuf
(
MsgSvc
.
PbMsgWithDrawResp
.
serializer
())
val
resp
=
readProtoBuf
(
MsgSvc
.
PbMsgWithDrawResp
.
serializer
())
resp
.
groupWithDraw
?.
firstOrNull
()
?.
let
{
resp
.
groupWithDraw
?.
firstOrNull
()
?.
let
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
View file @
6cbc69cd
...
@@ -269,7 +269,28 @@ internal class MessageSvc {
...
@@ -269,7 +269,28 @@ internal class MessageSvc {
}
}
}
}
internal
class
MessageSourceFromSend
(
internal
class
MessageSourceFromSendFriend
(
val
messageRandom
:
Int
,
override
val
time
:
Long
,
override
val
senderId
:
Long
,
override
val
groupId
:
Long
,
val
sequenceId
:
Int
)
:
MessageSource
{
@UseExperimental
(
ExperimentalCoroutinesApi
::
class
)
override
val
id
:
Long
get
()
=
sequenceId
.
toLong
().
shl
(
32
)
or
messageRandom
.
toLong
().
and
(
0
xFFFFFFFF
)
override
suspend
fun
ensureSequenceIdAvailable
()
{
// nothing to do
}
override
fun
toString
():
String
{
return
""
}
}
internal
class
MessageSourceFromSendGroup
(
val
messageRandom
:
Int
,
val
messageRandom
:
Int
,
override
val
time
:
Long
,
override
val
time
:
Long
,
override
val
senderId
:
Long
,
override
val
senderId
:
Long
,
...
@@ -286,7 +307,7 @@ internal class MessageSvc {
...
@@ -286,7 +307,7 @@ internal class MessageSvc {
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
fun
startWaitingSequenceId
(
contact
:
Contact
)
{
fun
startWaitingSequenceId
(
contact
:
Contact
)
{
sequenceIdDeferred
=
contact
.
subscribingGetAsync
<
OnlinePush
.
PbPushGroupMsg
.
SendGroupMessageReceipt
,
Int
>(
timeoutMillis
=
3000
)
{
sequenceIdDeferred
=
contact
.
subscribingGetAsync
<
OnlinePush
.
PbPushGroupMsg
.
SendGroupMessageReceipt
,
Int
>(
timeoutMillis
=
3000
)
{
if
(
it
.
messageRandom
==
this
@MessageSourceFromSend
.
messageRandom
)
{
if
(
it
.
messageRandom
==
this
@MessageSourceFromSend
Group
.
messageRandom
)
{
it
.
sequenceId
it
.
sequenceId
}
else
null
}
else
null
}
}
...
@@ -305,14 +326,14 @@ internal class MessageSvc {
...
@@ -305,14 +326,14 @@ internal class MessageSvc {
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
toUin
:
Long
,
toUin
:
Long
,
message
:
MessageChain
,
message
:
MessageChain
,
crossinline
sourceCallback
:
(
MessageSource
)
->
Unit
crossinline
sourceCallback
:
(
MessageSource
FromSendFriend
)
->
Unit
):
OutgoingPacket
{
):
OutgoingPacket
{
val
source
=
MessageSourceFromSend
(
val
source
=
MessageSourceFromSend
Friend
(
messageRandom
=
Random
.
nextInt
().
absoluteValue
,
messageRandom
=
Random
.
nextInt
().
absoluteValue
,
senderId
=
client
.
uin
,
senderId
=
client
.
uin
,
time
=
currentTimeSeconds
+
client
.
timeDifference
,
time
=
currentTimeSeconds
+
client
.
timeDifference
,
groupId
=
0
//
groupId
=
0
,
// sourceMessage = message
sequenceId
=
client
.
atomicNextMessageSequenceId
()
)
)
sourceCallback
(
source
)
sourceCallback
(
source
)
return
ToFriend
(
client
,
toUin
,
message
,
source
)
return
ToFriend
(
client
,
toUin
,
message
,
source
)
...
@@ -326,7 +347,7 @@ internal class MessageSvc {
...
@@ -326,7 +347,7 @@ internal class MessageSvc {
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
toUin
:
Long
,
toUin
:
Long
,
message
:
MessageChain
,
message
:
MessageChain
,
source
:
MessageSourceFromSend
source
:
MessageSourceFromSend
Friend
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
)
{
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
)
{
///writeFully("0A 08 0A 06 08 89 FC A6 8C 0B 12 06 08 01 10 00 18 00 1A 1F 0A 1D 12 08 0A 06 0A 04 F0 9F 92 A9 12 11 AA 02 0E 88 01 00 9A 01 08 78 00 F8 01 00 C8 02 00 20 9B 7A 28 F4 CA 9B B8 03 32 34 08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00 40 01".hexToBytes())
///writeFully("0A 08 0A 06 08 89 FC A6 8C 0B 12 06 08 01 10 00 18 00 1A 1F 0A 1D 12 08 0A 06 0A 04 F0 9F 92 A9 12 11 AA 02 0E 88 01 00 9A 01 08 78 00 F8 01 00 C8 02 00 20 9B 7A 28 F4 CA 9B B8 03 32 34 08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00 40 01".hexToBytes())
...
@@ -340,7 +361,7 @@ internal class MessageSvc {
...
@@ -340,7 +361,7 @@ internal class MessageSvc {
elems
=
message
.
toRichTextElems
(
false
)
elems
=
message
.
toRichTextElems
(
false
)
)
)
),
),
msgSeq
=
client
.
atomicNextMessageSequenceId
()
,
msgSeq
=
source
.
sequenceId
,
msgRand
=
source
.
messageRandom
,
msgRand
=
source
.
messageRandom
,
syncCookie
=
SyncCookie
(
time
=
source
.
time
).
toByteArray
(
SyncCookie
.
serializer
())
syncCookie
=
SyncCookie
(
time
=
source
.
time
).
toByteArray
(
SyncCookie
.
serializer
())
// msgVia = 1
// msgVia = 1
...
@@ -353,10 +374,10 @@ internal class MessageSvc {
...
@@ -353,10 +374,10 @@ internal class MessageSvc {
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
groupCode
:
Long
,
groupCode
:
Long
,
message
:
MessageChain
,
message
:
MessageChain
,
sourceCallback
:
(
MessageSourceFromSend
)
->
Unit
sourceCallback
:
(
MessageSourceFromSend
Group
)
->
Unit
):
OutgoingPacket
{
):
OutgoingPacket
{
val
source
=
MessageSourceFromSend
(
val
source
=
MessageSourceFromSend
Group
(
messageRandom
=
Random
.
nextInt
().
absoluteValue
,
messageRandom
=
Random
.
nextInt
().
absoluteValue
,
senderId
=
client
.
uin
,
senderId
=
client
.
uin
,
time
=
currentTimeSeconds
+
client
.
timeDifference
,
time
=
currentTimeSeconds
+
client
.
timeDifference
,
...
@@ -375,7 +396,7 @@ internal class MessageSvc {
...
@@ -375,7 +396,7 @@ internal class MessageSvc {
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
groupCode
:
Long
,
groupCode
:
Long
,
message
:
MessageChain
,
message
:
MessageChain
,
source
:
MessageSourceFromSend
source
:
MessageSourceFromSend
Group
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
)
{
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
)
{
///writeFully("0A 08 0A 06 08 89 FC A6 8C 0B 12 06 08 01 10 00 18 00 1A 1F 0A 1D 12 08 0A 06 0A 04 F0 9F 92 A9 12 11 AA 02 0E 88 01 00 9A 01 08 78 00 F8 01 00 C8 02 00 20 9B 7A 28 F4 CA 9B B8 03 32 34 08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00 40 01".hexToBytes())
///writeFully("0A 08 0A 06 08 89 FC A6 8C 0B 12 06 08 01 10 00 18 00 1A 1F 0A 1D 12 08 0A 06 0A 04 F0 9F 92 A9 12 11 AA 02 0E 88 01 00 9A 01 08 78 00 F8 01 00 C8 02 00 20 9B 7A 28 F4 CA 9B B8 03 32 34 08 92 C2 C4 F1 05 10 92 C2 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 89 84 F9 A2 06 48 DE 8C EA E5 0E 58 D9 BD BB A0 09 60 1D 68 92 C2 C4 F1 05 70 00 40 01".hexToBytes())
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageReceipt.kt
View file @
6cbc69cd
...
@@ -78,13 +78,9 @@ open class MessageReceipt<C : Contact>(
...
@@ -78,13 +78,9 @@ open class MessageReceipt<C : Contact>(
fun
recallIn
(
millis
:
Long
):
Job
{
fun
recallIn
(
millis
:
Long
):
Job
{
@Suppress
(
"BooleanLiteralArgument"
)
@Suppress
(
"BooleanLiteralArgument"
)
if
(
_isRecalled
.
compareAndSet
(
false
,
true
))
{
if
(
_isRecalled
.
compareAndSet
(
false
,
true
))
{
when
(
val
contact
=
target
)
{
return
when
(
val
contact
=
target
)
{
is
Group
->
{
is
QQ
,
return
contact
.
bot
.
recallIn
(
source
,
millis
)
is
Group
->
contact
.
bot
.
recallIn
(
source
,
millis
)
}
is
QQ
->
{
TODO
()
}
else
->
error
(
"Unknown contact type"
)
else
->
error
(
"Unknown contact type"
)
}
}
}
else
error
(
"message is already or planned to be recalled"
)
}
else
error
(
"message is already or planned to be recalled"
)
...
...
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