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
1ff84a4c
Commit
1ff84a4c
authored
Apr 10, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #212
parent
94557a2a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
23 deletions
+58
-23
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
...ain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
+2
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt
...in/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/util.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/contact/util.kt
+25
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/OnlinePush.kt
...mirai/qqandroid/network/protocol/data/proto/OnlinePush.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
...ndroid/network/protocol/packet/chat/receive/OnlinePush.kt
+29
-21
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/GroupImpl.kt
View file @
1ff84a4c
...
...
@@ -65,7 +65,8 @@ internal class GroupImpl(
)
:
Group
()
{
companion
object
val
lastRecalledMessageRandoms
:
LockFreeLinkedList
<
Int
>
=
LockFreeLinkedList
()
val
lastRecalledMessageRandoms
:
LockFreeCacheList
<
Int
>
=
LockFreeCacheList
(
16
)
// events per 3 second
val
lastMemberPermissionChangeSequences
:
LockFreeCacheList
<
Int
>
=
LockFreeCacheList
(
16
)
// events per 3 second
override
val
bot
:
QQAndroidBot
by
bot
.
unsafeWeakRef
()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/MemberImpl.kt
View file @
1ff84a4c
...
...
@@ -49,6 +49,7 @@ internal class MemberImpl constructor(
)
:
Member
()
{
override
val
group
:
GroupImpl
by
group
.
unsafeWeakRef
()
@Suppress
(
"unused"
)
// false positive
val
lastMessageSequence
:
AtomicInt
=
atomic
(-
1
)
// region QQ delegate
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/util.kt
View file @
1ff84a4c
...
...
@@ -25,6 +25,7 @@ import net.mamoe.mirai.qqandroid.message.ensureSequenceIdAvailable
import
net.mamoe.mirai.qqandroid.message.firstIsInstanceOrNull
import
net.mamoe.mirai.qqandroid.network.QQAndroidBotNetworkHandler
import
net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
import
net.mamoe.mirai.utils.LockFreeLinkedList
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.MiraiInternalAPI
...
...
@@ -61,3 +62,27 @@ internal fun Contact.logMessageSent(message: Message) {
internal
fun
String
.
singleLine
():
String
{
return
this
.
replace
(
"\n"
,
"""\n"""
).
replace
(
"\r"
,
""
)
}
/**
* Size management isn't atomic.
*/
internal
class
LockFreeCacheList
<
E
>(
private
val
maxSize
:
Int
)
:
LockFreeLinkedList
<
E
>()
{
override
fun
addLast
(
element
:
E
)
{
if
(
size
>=
maxSize
)
{
this
.
removeFirst
()
}
super
.
addLast
(
element
)
}
@Deprecated
(
"prohibited"
,
level
=
DeprecationLevel
.
HIDDEN
)
override
fun
addAll
(
iterable
:
Iterable
<
E
>)
{
super
.
addAll
(
iterable
)
}
@Deprecated
(
"prohibited"
,
level
=
DeprecationLevel
.
HIDDEN
)
override
fun
addAll
(
iterable
:
Sequence
<
E
>)
{
super
.
addAll
(
iterable
)
}
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/OnlinePush.kt
View file @
1ff84a4c
...
...
@@ -47,7 +47,7 @@ internal class OnlinePushTrans : ProtoBuf {
@ProtoId
(
9
)
val
nickName
:
String
=
""
,
@ProtoId
(
10
)
val
msgData
:
ByteArray
=
EMPTY_BYTE_ARRAY
,
@ProtoId
(
11
)
val
svrIp
:
Int
=
0
,
@ProtoId
(
12
)
val
extGroupKeyInfo
:
OnlinePushTrans
.
ExtGroupKeyInfo
?
=
null
,
@ProtoId
(
12
)
val
extGroupKeyInfo
:
ExtGroupKeyInfo
?
=
null
,
@ProtoId
(
17
)
val
generalFlag
:
Int
=
0
)
:
ProtoBuf
}
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt
View file @
1ff84a4c
...
...
@@ -113,9 +113,9 @@ internal class OnlinePush {
IncomingPacketFactory
<
Packet
?
>(
"OnlinePush.PbPushTransMsg"
,
"OnlinePush.RespPush"
)
{
@OptIn
(
MiraiInternalAPI
::
class
)
@ExperimentalUnsignedTypes
override
suspend
fun
ByteReadPacket
.
decode
(
bot
:
QQAndroidBot
,
sequenceId
:
Int
):
Packet
?
{
val
content
=
this
.
readProtoBuf
(
OnlinePushTrans
.
PbMsgInfo
.
serializer
())
content
.
msgData
.
read
<
Unit
>
{
when
(
content
.
msgType
)
{
44
->
{
...
...
@@ -128,21 +128,33 @@ internal class OnlinePush {
}
val
group
=
bot
.
getGroupByUin
(
content
.
fromUin
)
as
GroupImpl
if
(
group
.
lastMemberPermissionChangeSequences
.
remove
(
content
.
msgSeq
))
{
return
null
}
if
(
var5
==
0L
&&
this
.
remaining
==
1L
)
{
//管理员变更
group
.
lastMemberPermissionChangeSequences
.
addLast
(
content
.
msgSeq
)
val
newPermission
=
if
(
this
.
readByte
()
.
toInt
()
==
1
)
MemberPermission
.
ADMINISTRATOR
else
MemberPermission
.
MEMBER
if
(
this
.
readByte
().
toInt
()
==
1
)
MemberPermission
.
ADMINISTRATOR
else
MemberPermission
.
MEMBER
if
(
target
==
bot
.
id
)
{
if
(
group
.
botPermission
==
newPermission
)
{
return
null
}
return
if
(
target
==
bot
.
id
)
{
BotGroupPermissionChangeEvent
(
return
BotGroupPermissionChangeEvent
(
group
,
group
.
botPermission
.
also
{
group
.
botPermission
=
newPermission
},
newPermission
)
}
else
{
val
member
=
group
[
target
]
as
MemberImpl
MemberPermissionChangeEvent
(
if
(
member
.
permission
==
newPermission
)
{
return
null
}
return
MemberPermissionChangeEvent
(
member
,
member
.
permission
.
also
{
member
.
permission
=
newPermission
},
newPermission
...
...
@@ -173,21 +185,17 @@ internal class OnlinePush {
val
groupUin
=
content
.
fromUin
when
(
type
)
{
0
x82
->
{
// 2020/4/8: 在这里拿到了一个 Group xxx not found
bot
.
getGroupByUinOrNull
(
groupUin
)
?.
let
{
group
->
val
member
=
group
.
getOrNull
(
target
)
as
?
MemberImpl
?:
return
null
return
MemberLeaveEvent
.
Quit
(
member
.
also
{
group
.
members
.
delegate
.
remove
(
member
)
})
}
0
x82
->
bot
.
getGroupByUinOrNull
(
groupUin
)
?.
let
{
group
->
val
member
=
group
.
getOrNull
(
target
)
as
?
MemberImpl
?:
return
null
return
MemberLeaveEvent
.
Quit
(
member
.
also
{
group
.
members
.
delegate
.
remove
(
member
)
})
}
0
x83
->
{
bot
.
getGroupByUin
(
groupUin
).
let
{
group
->
val
member
=
group
.
getOrNull
(
target
)
as
?
MemberImpl
?:
return
null
return
MemberLeaveEvent
.
Kick
(
member
.
also
{
group
.
members
.
delegate
.
remove
(
member
)
},
group
.
members
[
operator
])
}
0
x83
->
bot
.
getGroupByUin
(
groupUin
).
let
{
group
->
val
member
=
group
.
getOrNull
(
target
)
as
?
MemberImpl
?:
return
null
return
MemberLeaveEvent
.
Kick
(
member
.
also
{
group
.
members
.
delegate
.
remove
(
member
)
},
group
.
members
[
operator
])
}
}
}
...
...
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