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
96c3e775
Commit
96c3e775
authored
Feb 08, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
9d9089dd
13d6bd29
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
181 deletions
+164
-181
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+119
-96
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
.../kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
+34
-74
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+9
-9
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/PushNotifyPack.kt
...rai/qqandroid/network/protocol/data/jce/PushNotifyPack.kt
+1
-1
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
...o-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
+1
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
96c3e775
...
@@ -20,7 +20,6 @@ import net.mamoe.mirai.qqandroid.utils.toIpV4AddressString
...
@@ -20,7 +20,6 @@ import net.mamoe.mirai.qqandroid.utils.toIpV4AddressString
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.io.toUHexString
import
net.mamoe.mirai.utils.io.toUHexString
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
import
kotlin.properties.Delegates
internal
abstract
class
ContactImpl
:
Contact
{
internal
abstract
class
ContactImpl
:
Contact
{
override
fun
hashCode
():
Int
{
override
fun
hashCode
():
Int
{
...
@@ -51,6 +50,7 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
...
@@ -51,6 +50,7 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
)
{
"send message failed"
}
)
{
"send message failed"
}
}
}
}
}
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
Image
=
try
{
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
Image
=
try
{
bot
.
network
.
run
{
bot
.
network
.
run
{
val
response
=
LongConn
.
OffPicUp
(
val
response
=
LongConn
.
OffPicUp
(
...
@@ -129,8 +129,8 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
...
@@ -129,8 +129,8 @@ internal class QQImpl(bot: QQAndroidBot, override val coroutineContext: Coroutin
internal
class
MemberImpl
(
internal
class
MemberImpl
(
qq
:
QQImpl
,
qq
:
QQImpl
,
initG
roupCard
:
String
,
var
_g
roupCard
:
String
,
initS
pecialTitle
:
String
,
var
_s
pecialTitle
:
String
,
group
:
GroupImpl
,
group
:
GroupImpl
,
override
val
coroutineContext
:
CoroutineContext
,
override
val
coroutineContext
:
CoroutineContext
,
override
val
permission
:
MemberPermission
override
val
permission
:
MemberPermission
...
@@ -138,37 +138,41 @@ internal class MemberImpl(
...
@@ -138,37 +138,41 @@ internal class MemberImpl(
override
val
group
:
GroupImpl
by
group
.
unsafeWeakRef
()
override
val
group
:
GroupImpl
by
group
.
unsafeWeakRef
()
val
qq
:
QQImpl
by
qq
.
unsafeWeakRef
()
val
qq
:
QQImpl
by
qq
.
unsafeWeakRef
()
override
var
groupCard
:
String
override
var
groupCard
:
String
by
Delegates
.
observable
(
initGroupCard
)
{
_
,
old
,
new
->
get
()
=
_groupCard
group
.
checkBotPermissionOperator
()
set
(
newValue
)
{
if
(
new
!=
old
)
{
group
.
checkBotPermissionOperator
()
if
(
_groupCard
!=
newValue
)
{
launch
{
_groupCard
=
newValue
bot
.
network
.
run
{
launch
{
TroopManagement
.
EditGroupNametag
(
bot
.
network
.
run
{
bot
.
client
,
TroopManagement
.
EditGroupNametag
(
this
@MemberImpl
,
bot
.
client
,
new
this
@MemberImpl
,
).
sendWithoutExpect
()
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
var
specialTitle
:
String
by
Delegates
.
observable
(
initSpecialTitle
)
{
_
,
old
,
new
->
override
var
specialTitle
:
String
group
.
checkBotPermissionOperator
()
get
()
=
_specialTitle
if
(
new
!=
old
)
{
set
(
newValue
)
{
launch
{
group
.
checkBotPermissionOperator
()
bot
.
network
.
run
{
if
(
_specialTitle
!=
newValue
)
{
TroopManagement
.
EditSpecialTitle
(
_specialTitle
=
newValue
bot
.
client
,
launch
{
this
@MemberImpl
,
bot
.
network
.
run
{
new
TroopManagement
.
EditSpecialTitle
(
).
sendWithoutExpect
()
bot
.
client
,
this
@MemberImpl
,
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
val
bot
:
QQAndroidBot
get
()
=
qq
.
bot
override
val
bot
:
QQAndroidBot
get
()
=
qq
.
bot
...
@@ -233,100 +237,119 @@ internal class GroupImpl(
...
@@ -233,100 +237,119 @@ internal class GroupImpl(
bot
:
QQAndroidBot
,
override
val
coroutineContext
:
CoroutineContext
,
bot
:
QQAndroidBot
,
override
val
coroutineContext
:
CoroutineContext
,
override
val
id
:
Long
,
override
val
id
:
Long
,
val
uin
:
Long
,
val
uin
:
Long
,
initN
ame
:
String
,
var
_n
ame
:
String
,
initA
nnouncement
:
String
,
var
_a
nnouncement
:
String
,
initA
llowMemberInvite
:
Boolean
,
var
_a
llowMemberInvite
:
Boolean
,
initC
onfessTalk
:
Boolean
,
var
_c
onfessTalk
:
Boolean
,
initM
uteAll
:
Boolean
,
var
_m
uteAll
:
Boolean
,
initA
utoApprove
:
Boolean
,
var
_a
utoApprove
:
Boolean
,
initA
nonymousChat
:
Boolean
,
var
_a
nonymousChat
:
Boolean
,
override
val
members
:
ContactList
<
Member
>
override
val
members
:
ContactList
<
Member
>
)
:
ContactImpl
(),
Group
{
)
:
ContactImpl
(),
Group
{
override
var
name
by
Delegates
.
observable
(
initName
)
{
_
,
oldValue
,
newValue
->
override
var
name
:
String
this
.
checkBotPermissionOperator
()
get
()
=
_name
if
(
oldValue
!=
newValue
)
{
set
(
newValue
)
{
launch
{
this
.
checkBotPermissionOperator
()
bot
.
network
.
run
{
if
(
_name
!=
newValue
)
{
TroopManagement
.
GroupOperation
.
name
(
_name
=
newValue
client
=
bot
.
client
,
launch
{
groupCode
=
id
,
bot
.
network
.
run
{
newName
=
newValue
TroopManagement
.
GroupOperation
.
name
(
).
sendWithoutExpect
()
client
=
bot
.
client
,
groupCode
=
id
,
newName
=
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
var
announcement
:
String
by
Delegates
.
observable
(
initAnnouncement
)
{
_
,
oldValue
,
newValue
->
override
var
announcement
:
String
this
.
checkBotPermissionOperator
()
get
()
=
_announcement
if
(
oldValue
!=
newValue
)
{
set
(
newValue
)
{
launch
{
this
.
checkBotPermissionOperator
()
bot
.
network
.
run
{
if
(
_announcement
!=
newValue
)
{
TroopManagement
.
GroupOperation
.
memo
(
_announcement
=
newValue
client
=
bot
.
client
,
launch
{
groupCode
=
id
,
bot
.
network
.
run
{
newMemo
=
newValue
TroopManagement
.
GroupOperation
.
memo
(
).
sendWithoutExpect
()
client
=
bot
.
client
,
groupCode
=
id
,
newMemo
=
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
var
allowMemberInvite
:
Boolean
by
Delegates
.
observable
(
initAllowMemberInvite
)
{
_
,
oldValue
,
newValue
->
override
var
allowMemberInvite
:
Boolean
this
.
checkBotPermissionOperator
()
get
()
=
_allowMemberInvite
if
(
oldValue
!=
newValue
)
{
set
(
newValue
)
{
launch
{
this
.
checkBotPermissionOperator
()
bot
.
network
.
run
{
if
(
_allowMemberInvite
!=
newValue
)
{
TroopManagement
.
GroupOperation
.
allowMemberInvite
(
_allowMemberInvite
=
newValue
client
=
bot
.
client
,
launch
{
groupCode
=
id
,
bot
.
network
.
run
{
switch
=
newValue
TroopManagement
.
GroupOperation
.
allowMemberInvite
(
).
sendWithoutExpect
()
client
=
bot
.
client
,
groupCode
=
id
,
switch
=
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
var
autoApprove
:
Boolean
by
Delegates
.
observable
(
initAutoApprove
)
{
_
,
oldValue
,
newValue
->
override
var
autoApprove
:
Boolean
TODO
(
"Group.autoApprove implementation"
)
get
()
=
_autoApprove
}
set
(
newValue
)
{
TODO
()
}
override
val
anonymousChat
:
Boolean
by
Delegates
.
observable
(
initAnonymousChat
)
{
_
,
oldValue
,
newValue
->
override
var
anonymousChat
:
Boolean
TODO
(
"Group.anonymousChat implementation"
)
get
()
=
_anonymousChat
}
set
(
newValue
)
{
TODO
()
}
override
var
confessTalk
:
Boolean
by
Delegates
.
observable
(
initConfessTalk
)
{
_
,
oldValue
,
newValue
->
override
var
confessTalk
:
Boolean
this
.
checkBotPermissionOperator
()
get
()
=
_confessTalk
if
(
oldValue
!=
newValue
)
{
set
(
newValue
)
{
launch
{
this
.
checkBotPermissionOperator
()
bot
.
network
.
run
{
if
(
_confessTalk
!=
newValue
)
{
TroopManagement
.
GroupOperation
.
confessTalk
(
_confessTalk
=
newValue
client
=
bot
.
client
,
launch
{
groupCode
=
id
,
bot
.
network
.
run
{
switch
=
newValue
TroopManagement
.
GroupOperation
.
confessTalk
(
).
sendWithoutExpect
()
client
=
bot
.
client
,
groupCode
=
id
,
switch
=
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
var
muteAll
:
Boolean
by
Delegates
.
observable
(
initMuteAll
)
{
_
,
oldValue
,
newValue
->
override
var
muteAll
:
Boolean
this
.
checkBotPermissionOperator
()
get
()
=
_muteAll
if
(
oldValue
!=
newValue
)
{
set
(
newValue
)
{
launch
{
this
.
checkBotPermissionOperator
()
bot
.
network
.
run
{
if
(
_muteAll
!=
newValue
)
{
TroopManagement
.
GroupOperation
.
muteAll
(
_muteAll
=
newValue
client
=
bot
.
client
,
launch
{
groupCode
=
id
,
bot
.
network
.
run
{
switch
=
newValue
TroopManagement
.
GroupOperation
.
muteAll
(
).
sendWithoutExpect
()
client
=
bot
.
client
,
groupCode
=
id
,
switch
=
newValue
).
sendWithoutExpect
()
}
}
}
}
}
}
}
}
override
lateinit
var
owner
:
Member
override
lateinit
var
owner
:
Member
...
@@ -340,7 +363,7 @@ internal class GroupImpl(
...
@@ -340,7 +363,7 @@ internal class GroupImpl(
override
operator
fun
get
(
id
:
Long
):
Member
{
override
operator
fun
get
(
id
:
Long
):
Member
{
return
members
.
delegate
.
filteringGetOrNull
{
it
.
id
==
id
}
?:
throw
NoSuchElementException
(
"
for group id $id
"
)
return
members
.
delegate
.
filteringGetOrNull
{
it
.
id
==
id
}
?:
throw
NoSuchElementException
(
"
member $id not found in group $uin
"
)
}
}
override
fun
contains
(
id
:
Long
):
Boolean
{
override
fun
contains
(
id
:
Long
):
Boolean
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
View file @
96c3e775
...
@@ -390,10 +390,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -390,10 +390,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
override
fun
decodeTaggedNotNullMark
(
tag
:
Int
):
Boolean
{
override
fun
decodeTaggedNotNullMark
(
tag
:
Int
):
Boolean
{
return
!
isTag
Optional
(
tag
)
return
!
isTag
Missing
(
tag
)
}
}
fun
isTag
Optional
(
tag
:
Int
):
Boolean
{
fun
isTag
Missing
(
tag
:
Int
):
Boolean
{
val
head
=
input
.
peakHeadOrNull
()
val
head
=
input
.
peakHeadOrNull
()
return
input
.
isEndOfInput
||
head
==
null
||
head
.
tag
>
tag
return
input
.
isEndOfInput
||
head
==
null
||
head
.
tag
>
tag
}
}
...
@@ -405,10 +405,15 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -405,10 +405,15 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
if
(
deserializer
is
NullReader
)
{
if
(
deserializer
is
NullReader
)
{
return
null
return
null
}
}
currentTagOrNull
?.
let
{
if
(
this
.
isTagMissing
(
it
))
{
return
null
}
}
when
(
deserializer
.
descriptor
)
{
when
(
deserializer
.
descriptor
)
{
ByteArraySerializer
.
descriptor
->
{
ByteArraySerializer
.
descriptor
->
{
val
tag
=
popTag
()
val
tag
=
popTag
()
return
if
(
isTag
Optional
(
tag
))
input
.
readByteArrayOrNull
(
tag
)
as
?
T
return
if
(
isTag
Missing
(
tag
))
input
.
readByteArrayOrNull
(
tag
)
as
?
T
else
input
.
readByteArray
(
tag
)
as
T
else
input
.
readByteArray
(
tag
)
as
T
}
}
is
ListLikeDescriptor
->
{
is
ListLikeDescriptor
->
{
...
@@ -417,14 +422,14 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -417,14 +422,14 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
&&
(
deserializer
as
ListLikeSerializer
<
Any
?
,
T
,
Any
?
>).
typeParams
[
0
]
is
ByteSerializer
&&
(
deserializer
as
ListLikeSerializer
<
Any
?
,
T
,
Any
?
>).
typeParams
[
0
]
is
ByteSerializer
)
{
)
{
val
tag
=
popTag
()
val
tag
=
popTag
()
return
if
(
isTag
Optional
(
tag
))
input
.
readByteArrayOrNull
(
tag
)
?.
toTypedArray
()
as
?
T
return
if
(
isTag
Missing
(
tag
))
input
.
readByteArrayOrNull
(
tag
)
?.
toTypedArray
()
as
?
T
else
input
.
readByteArray
(
tag
).
toTypedArray
()
as
T
else
input
.
readByteArray
(
tag
).
toTypedArray
()
as
T
}
else
if
(
deserializer
is
ArrayListSerializer
<
*
>
}
else
if
(
deserializer
is
ArrayListSerializer
<
*
>
&&
(
deserializer
as
ArrayListSerializer
<
*
>).
typeParams
.
isNotEmpty
()
&&
(
deserializer
as
ArrayListSerializer
<
*
>).
typeParams
.
isNotEmpty
()
&&
(
deserializer
as
ArrayListSerializer
<
*
>).
typeParams
[
0
]
is
ByteSerializer
&&
(
deserializer
as
ArrayListSerializer
<
*
>).
typeParams
[
0
]
is
ByteSerializer
)
{
)
{
val
tag
=
popTag
()
val
tag
=
popTag
()
return
if
(
isTag
Optional
(
tag
))
input
.
readByteArrayOrNull
(
tag
)
?.
toMutableList
()
as
?
T
return
if
(
isTag
Missing
(
tag
))
input
.
readByteArrayOrNull
(
tag
)
?.
toMutableList
()
as
?
T
else
input
.
readByteArray
(
tag
).
toMutableList
()
as
T
else
input
.
readByteArray
(
tag
).
toMutableList
()
as
T
}
}
val
tag
=
currentTag
val
tag
=
currentTag
...
@@ -433,7 +438,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -433,7 +438,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
if
(
input
.
skipToTagOrNull
(
tag
)
{
if
(
input
.
skipToTagOrNull
(
tag
)
{
return
deserializer
.
deserialize
(
JceListReader
(
input
.
readInt
(
0
),
input
))
return
deserializer
.
deserialize
(
JceListReader
(
input
.
readInt
(
0
),
input
))
}
==
null
)
{
}
==
null
)
{
if
(
isTag
Optional
(
tag
))
{
if
(
isTag
Missing
(
tag
))
{
return
null
return
null
}
else
error
(
"property is notnull but cannot find tag $tag"
)
}
else
error
(
"property is notnull but cannot find tag $tag"
)
}
}
...
@@ -442,15 +447,15 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -442,15 +447,15 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
is
MapLikeDescriptor
->
{
is
MapLikeDescriptor
->
{
val
tag
=
popTag
()
val
tag
=
popTag
()
@Suppress
(
"SENSELESS_COMPARISON"
)
@Suppress
(
"SENSELESS_COMPARISON"
)
if
(
input
.
skipToTagOrNull
(
tag
)
{
if
(
input
.
skipToTagOrNull
(
tag
)
{
head
->
check
(
it
.
type
==
MAP
)
{
"type mismatch: ${it
.type}"
}
check
(
head
.
type
==
MAP
)
{
"type mismatch: ${head
.type}"
}
// 将 mapOf(k1 to v1, k2 to v2, ...) 转换为 listOf(k1, v1, k2, v2, ...) 以便于写入.
// 将 mapOf(k1 to v1, k2 to v2, ...) 转换为 listOf(k1, v1, k2, v2, ...) 以便于写入.
val
serializer
=
(
deserializer
as
MapLikeSerializer
<
Any
?
,
Any
?
,
T
,
*
>)
val
serializer
=
(
deserializer
as
MapLikeSerializer
<
Any
?
,
Any
?
,
T
,
*
>)
val
mapEntrySerial
=
MapEntrySerializer
(
serializer
.
keySerializer
,
serializer
.
valueSerializer
)
val
mapEntrySerial
=
MapEntrySerializer
(
serializer
.
keySerializer
,
serializer
.
valueSerializer
)
val
setOfEntries
=
HashSetSerializer
(
mapEntrySerial
).
deserialize
(
JceMapReader
(
input
.
readInt
(
0
),
input
))
val
setOfEntries
=
HashSetSerializer
(
mapEntrySerial
).
deserialize
(
JceMapReader
(
input
.
readInt
(
0
),
input
))
return
setOfEntries
.
associateBy
({
it
.
key
},
{
it
.
value
})
as
T
return
setOfEntries
.
associateBy
({
it
.
key
},
{
it
.
value
})
as
T
}
==
null
)
{
}
==
null
)
{
if
(
isTag
Optional
(
tag
))
{
if
(
isTag
Missing
(
tag
))
{
return
null
return
null
}
else
error
(
"property is notnull but cannot find tag $tag"
)
}
else
error
(
"property is notnull but cannot find tag $tag"
)
}
}
...
@@ -471,7 +476,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -471,7 +476,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
input
.
readHeadOrNull
()
input
.
readHeadOrNull
()
}
}
}
==
null
&&
isTag
Optional
(
tag
))
{
}
==
null
&&
isTag
Missing
(
tag
))
{
return
null
return
null
}
else
error
(
"cannot find tag $tag"
)
}
else
error
(
"cannot find tag $tag"
)
}
}
...
@@ -480,8 +485,13 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -480,8 +485,13 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
val
tag
=
currentTagOrNull
?:
return
deserializer
.
deserialize
(
JceDecoder
(
this
.
input
))
val
tag
=
currentTagOrNull
?:
return
deserializer
.
deserialize
(
JceDecoder
(
this
.
input
))
return
if
(
this
.
decodeTaggedNotNullMark
(
tag
))
{
return
if
(!
this
.
isTagMissing
(
tag
))
{
deserializer
.
deserialize
(
this
)
try
{
deserializer
.
deserialize
(
this
)
}
catch
(
e
:
Exception
)
{
println
(
"exception when tag=$tag"
)
throw
e
}
}
else
{
}
else
{
// popTag()
// popTag()
null
null
...
@@ -502,7 +512,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -502,7 +512,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
internal
val
input
:
ByteReadPacket
,
internal
val
input
:
ByteReadPacket
,
maxReadSize
:
Long
=
input
.
remaining
maxReadSize
:
Long
=
input
.
remaining
)
:
Closeable
{
)
:
Closeable
{
internal
val
leastRemaining
=
input
.
remaining
-
maxReadSize
private
val
leastRemaining
=
input
.
remaining
-
maxReadSize
internal
val
isEndOfInput
:
Boolean
get
()
=
input
.
remaining
<=
leastRemaining
internal
val
isEndOfInput
:
Boolean
get
()
=
input
.
remaining
<=
leastRemaining
internal
var
currentJceHead
:
JceHead
?
=
input
.
doReadHead
()
internal
var
currentJceHead
:
JceHead
?
=
input
.
doReadHead
()
...
@@ -510,7 +520,6 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -510,7 +520,6 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
override
fun
close
()
=
input
.
close
()
override
fun
close
()
=
input
.
close
()
internal
fun
peakHeadOrNull
():
JceHead
?
=
currentJceHead
?:
readHeadOrNull
()
internal
fun
peakHeadOrNull
():
JceHead
?
=
currentJceHead
?:
readHeadOrNull
()
internal
fun
peakHead
():
JceHead
=
peakHeadOrNull
()
?:
error
(
"no enough data to read head"
)
@PublishedApi
@PublishedApi
internal
fun
readHead
():
JceHead
=
readHeadOrNull
()
?:
error
(
"no enough data to read head"
)
internal
fun
readHead
():
JceHead
=
readHeadOrNull
()
?:
error
(
"no enough data to read head"
)
...
@@ -554,43 +563,6 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -554,43 +563,6 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
fun
readString
(
tag
:
Int
):
String
=
readStringOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readString
(
tag
:
Int
):
String
=
readStringOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readByteArray
(
tag
:
Int
):
ByteArray
=
readByteArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readByteArray
(
tag
:
Int
):
ByteArray
=
readByteArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readShortArray
(
tag
:
Int
):
ShortArray
=
readShortArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readLongArray
(
tag
:
Int
):
LongArray
=
readLongArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readFloatArray
(
tag
:
Int
):
FloatArray
=
readFloatArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readDoubleArray
(
tag
:
Int
):
DoubleArray
=
readDoubleArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readIntArray
(
tag
:
Int
):
IntArray
=
readIntArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readBooleanArray
(
tag
:
Int
):
BooleanArray
=
readBooleanArrayOrNull
(
tag
)
?:
error
(
"cannot find tag $tag, currentJceHead=$currentJceHead"
)
fun
readShortArrayOrNull
(
tag
:
Int
):
ShortArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch, expected=9(List), got=${it.type}"
}
ShortArray
(
readInt
(
0
))
{
readShort
(
0
)
}
}
fun
readDoubleArrayOrNull
(
tag
:
Int
):
DoubleArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch, expected=9(List), got=${it.type}"
}
DoubleArray
(
readInt
(
0
))
{
readDouble
(
0
)
}
}
fun
readFloatArrayOrNull
(
tag
:
Int
):
FloatArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch, expected=9(List), got=${it.type}"
}
FloatArray
(
readInt
(
0
))
{
readFloat
(
0
)
}
}
fun
readIntArrayOrNull
(
tag
:
Int
):
IntArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch, expected=9(List), got=${it.type}"
}
IntArray
(
readInt
(
0
))
{
readInt
(
0
)
}
}
fun
readLongArrayOrNull
(
tag
:
Int
):
LongArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch, expected=9(List), got=${it.type}"
}
LongArray
(
readInt
(
0
))
{
readLong
(
0
)
}
}
fun
readBooleanArrayOrNull
(
tag
:
Int
):
BooleanArray
?
=
skipToTagOrNull
(
tag
)
{
require
(
it
.
type
.
toInt
()
==
9
)
{
"type mismatch, expected=9(List), got=${it.type}"
}
BooleanArray
(
readInt
(
0
))
{
readBoolean
(
0
)
}
}
fun
readByteArrayOrNull
(
tag
:
Int
):
ByteArray
?
=
skipToTagOrNull
(
tag
)
{
fun
readByteArrayOrNull
(
tag
:
Int
):
ByteArray
?
=
skipToTagOrNull
(
tag
)
{
when
(
it
.
type
)
{
when
(
it
.
type
)
{
...
@@ -605,20 +577,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -605,20 +577,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
@Suppress
(
"IMPLICIT_CAST_TO_ANY"
,
"UNCHECKED_CAST"
)
private
fun
readStringOrNull
(
tag
:
Int
):
String
?
=
skipToTagOrNull
(
tag
)
{
head
->
fun
<
T
>
readObject
(
default
:
T
,
tag
:
Int
):
T
=
when
(
default
)
{
is
Byte
->
readByte
(
tag
)
is
Boolean
->
readBoolean
(
tag
)
is
Short
->
readShort
(
tag
)
is
Int
->
readInt
(
tag
)
is
Long
->
readLong
(
tag
)
is
Float
->
readFloat
(
tag
)
is
Double
->
readDouble
(
tag
)
is
String
->
readString
(
tag
)
else
->
error
(
"unsupported type: ${default.getClassName()}"
)
}
as
T
fun
readStringOrNull
(
tag
:
Int
):
String
?
=
skipToTagOrNull
(
tag
)
{
head
->
return
when
(
head
.
type
)
{
return
when
(
head
.
type
)
{
STRING1
->
input
.
readString
(
input
.
readUByte
().
toInt
(),
charset
=
charset
.
kotlinCharset
)
STRING1
->
input
.
readString
(
input
.
readUByte
().
toInt
(),
charset
=
charset
.
kotlinCharset
)
STRING4
->
input
.
readString
(
STRING4
->
input
.
readString
(
...
@@ -629,7 +588,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -629,7 +588,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readLongOrNull
(
tag
:
Int
):
Long
?
=
skipToTagOrNull
(
tag
)
{
private
fun
readLongOrNull
(
tag
:
Int
):
Long
?
=
skipToTagOrNull
(
tag
)
{
return
when
(
it
.
type
)
{
return
when
(
it
.
type
)
{
ZERO_TYPE
->
0
ZERO_TYPE
->
0
BYTE
->
input
.
readByte
().
toLong
()
BYTE
->
input
.
readByte
().
toLong
()
...
@@ -640,7 +599,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -640,7 +599,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readShortOrNull
(
tag
:
Int
):
Short
?
=
skipToTagOrNull
(
tag
)
{
private
fun
readShortOrNull
(
tag
:
Int
):
Short
?
=
skipToTagOrNull
(
tag
)
{
return
when
(
it
.
type
.
toInt
())
{
return
when
(
it
.
type
.
toInt
())
{
12
->
0
12
->
0
0
->
input
.
readByte
().
toShort
()
0
->
input
.
readByte
().
toShort
()
...
@@ -649,7 +608,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -649,7 +608,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readIntOrNull
(
tag
:
Int
):
Int
?
=
skipToTagOrNull
(
tag
)
{
private
fun
readIntOrNull
(
tag
:
Int
):
Int
?
=
skipToTagOrNull
(
tag
)
{
return
when
(
it
.
type
.
toInt
())
{
return
when
(
it
.
type
.
toInt
())
{
12
->
0
12
->
0
0
->
input
.
readByte
().
toInt
()
0
->
input
.
readByte
().
toInt
()
...
@@ -659,7 +618,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -659,7 +618,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readByteOrNull
(
tag
:
Int
):
Byte
?
=
skipToTagOrNull
(
tag
)
{
private
fun
readByteOrNull
(
tag
:
Int
):
Byte
?
=
skipToTagOrNull
(
tag
)
{
return
when
(
it
.
type
.
toInt
())
{
return
when
(
it
.
type
.
toInt
())
{
12
->
0
12
->
0
0
->
input
.
readByte
()
0
->
input
.
readByte
()
...
@@ -667,7 +626,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -667,7 +626,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readFloatOrNull
(
tag
:
Int
):
Float
?
=
skipToTagOrNull
(
tag
)
{
private
fun
readFloatOrNull
(
tag
:
Int
):
Float
?
=
skipToTagOrNull
(
tag
)
{
return
when
(
it
.
type
.
toInt
())
{
return
when
(
it
.
type
.
toInt
())
{
12
->
0f
12
->
0f
4
->
input
.
readFloat
()
4
->
input
.
readFloat
()
...
@@ -675,7 +634,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -675,7 +634,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readDoubleOrNull
(
tag
:
Int
):
Double
?
=
skipToTagOrNull
(
tag
)
{
private
fun
readDoubleOrNull
(
tag
:
Int
):
Double
?
=
skipToTagOrNull
(
tag
)
{
return
when
(
it
.
type
.
toInt
())
{
return
when
(
it
.
type
.
toInt
())
{
12
->
0.0
12
->
0.0
4
->
input
.
readFloat
().
toDouble
()
4
->
input
.
readFloat
().
toDouble
()
...
@@ -684,7 +643,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -684,7 +643,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
}
}
fun
readBooleanOrNull
(
tag
:
Int
):
Boolean
?
=
this
.
readByteOrNull
(
tag
)
?.
let
{
it
.
toInt
()
!=
0
}
private
fun
readBooleanOrNull
(
tag
:
Int
):
Boolean
?
=
this
.
readByteOrNull
(
tag
)
?.
let
{
it
.
toInt
()
!=
0
}
private
fun
skipField
()
{
private
fun
skipField
()
{
...
@@ -734,6 +693,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -734,6 +693,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
@Suppress
(
"MemberVisibilityCanBePrivate"
)
companion
object
{
companion
object
{
val
UTF8
=
Jce
(
JceCharset
.
UTF8
)
val
UTF8
=
Jce
(
JceCharset
.
UTF8
)
val
GBK
=
Jce
(
JceCharset
.
GBK
)
val
GBK
=
Jce
(
JceCharset
.
GBK
)
...
@@ -816,9 +776,9 @@ internal inline fun <R> Jce.JceInput.skipToTagOrNull(tag: Int, block: (JceHead)
...
@@ -816,9 +776,9 @@ internal inline fun <R> Jce.JceInput.skipToTagOrNull(tag: Int, block: (JceHead)
currentJceHead
=
null
currentJceHead
=
null
// println("skipping to $tag: run block")
// println("skipping to $tag: run block")
return
block
(
head
)
return
block
(
head
)
}
else
{
// println("skipping to $tag: tag not matching")
}
}
// println("skipping to $tag: tag not matching")
// println("skipping to $tag: skipField")
// println("skipping to $tag: skipField")
this
.
skipField
(
head
.
type
)
this
.
skipField
(
head
.
type
)
currentJceHead
=
readHeadOrNull
()
currentJceHead
=
readHeadOrNull
()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
96c3e775
...
@@ -185,13 +185,13 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -185,13 +185,13 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
coroutineContext
=
bot
.
coroutineContext
,
coroutineContext
=
bot
.
coroutineContext
,
id
=
troopNum
.
groupCode
,
id
=
troopNum
.
groupCode
,
uin
=
troopNum
.
groupUin
,
uin
=
troopNum
.
groupUin
,
initN
ame
=
troopNum
.
groupName
,
_n
ame
=
troopNum
.
groupName
,
initA
nnouncement
=
troopNum
.
groupMemo
,
_a
nnouncement
=
troopNum
.
groupMemo
,
initA
llowMemberInvite
=
groupInfoResponse
.
allowMemberInvite
,
_a
llowMemberInvite
=
groupInfoResponse
.
allowMemberInvite
,
initC
onfessTalk
=
groupInfoResponse
.
confessTalk
,
_c
onfessTalk
=
groupInfoResponse
.
confessTalk
,
initM
uteAll
=
troopNum
.
dwShutUpTimestamp
!=
0L
,
_m
uteAll
=
troopNum
.
dwShutUpTimestamp
!=
0L
,
initA
utoApprove
=
groupInfoResponse
.
autoApprove
,
_a
utoApprove
=
groupInfoResponse
.
autoApprove
,
initA
nonymousChat
=
groupInfoResponse
.
allowAnonymousChat
,
_a
nonymousChat
=
groupInfoResponse
.
allowAnonymousChat
,
members
=
contactList
members
=
contactList
)
)
toGet
[
group
]
=
contactList
toGet
[
group
]
=
contactList
...
@@ -260,8 +260,8 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -260,8 +260,8 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
data
.
members
.
forEach
{
data
.
members
.
forEach
{
val
member
=
MemberImpl
(
val
member
=
MemberImpl
(
qq
=
bot
.
QQ
(
it
.
memberUin
)
as
QQImpl
,
qq
=
bot
.
QQ
(
it
.
memberUin
)
as
QQImpl
,
initG
roupCard
=
it
.
autoRemark
?:
it
.
nick
,
_g
roupCard
=
it
.
autoRemark
?:
it
.
nick
,
initS
pecialTitle
=
it
.
sSpecialTitle
?:
""
,
_s
pecialTitle
=
it
.
sSpecialTitle
?:
""
,
group
=
group
,
group
=
group
,
coroutineContext
=
group
.
coroutineContext
,
coroutineContext
=
group
.
coroutineContext
,
permission
=
when
{
permission
=
when
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/PushNotifyPack.kt
View file @
96c3e775
...
@@ -26,7 +26,7 @@ internal data class RequestPushNotify(
...
@@ -26,7 +26,7 @@ internal data class RequestPushNotify(
)
:
JceStruct
,
Packet
)
:
JceStruct
,
Packet
@Serializable
@Serializable
internal
data
class
MsgInfo
(
internal
class
MsgInfo
(
@SerialId
(
0
)
val
lFromUin
:
Long
?
=
0L
,
@SerialId
(
0
)
val
lFromUin
:
Long
?
=
0L
,
@SerialId
(
1
)
val
uMsgTime
:
Long
?
=
0L
,
@SerialId
(
1
)
val
uMsgTime
:
Long
?
=
0L
,
@SerialId
(
2
)
val
shMsgType
:
Short
,
@SerialId
(
2
)
val
shMsgType
:
Short
,
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/GentleImage.kt
View file @
96c3e775
...
@@ -33,7 +33,7 @@ class GentleImage(val contact: Contact, val keyword: String) {
...
@@ -33,7 +33,7 @@ class GentleImage(val contact: Contact, val keyword: String) {
)
)
val
result
=
val
result
=
Json
.
plain
.
parse
(
Json
.
nonstrict
.
parse
(
Result
.
serializer
(),
Result
.
serializer
(),
Jsoup
.
connect
(
"https://api.lolicon.app/setu/?r18=$r18"
+
if
(
keyword
.
isNotBlank
())
"&keyword=$keyword&num=10"
else
""
)
Jsoup
.
connect
(
"https://api.lolicon.app/setu/?r18=$r18"
+
if
(
keyword
.
isNotBlank
())
"&keyword=$keyword&num=10"
else
""
)
.
ignoreContentType
(
true
)
.
ignoreContentType
(
true
)
...
...
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