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
eb1da6a3
Commit
eb1da6a3
authored
Nov 15, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add qAge and personalStatement for Profile
parent
c271e340
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
11 deletions
+28
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
.../src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
+4
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/action/Profile.kt
...mamoe.mirai/network/protocol/tim/packet/action/Profile.kt
+6
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/InputUtils.kt
.../commonMain/kotlin/net.mamoe.mirai/utils/io/InputUtils.kt
+6
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/TypeConvertion.kt
...monMain/kotlin/net.mamoe.mirai/utils/io/TypeConvertion.kt
+4
-1
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
...rai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
+8
-6
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
View file @
eb1da6a3
...
...
@@ -193,11 +193,14 @@ enum class MemberPermission {
data class
Profile
(
val
qq
:
UInt
,
val
nickname
:
String
,
val
englishName
:
String
?,
val
chineseName
:
String
?,
val
qAge
:
Int
?,
// q 龄
val
zipCode
:
String
?,
val
phone
:
String
?,
val
gender
:
Gender
,
val
birthday
:
Date
?,
val
personalStat
us
:
String
?,
val
personalStat
ement
:
String
?,
// 个人说明
val
school
:
String
?,
val
homepage
:
String
?,
val
email
:
String
?,
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/action/Profile.kt
View file @
eb1da6a3
...
...
@@ -60,9 +60,14 @@ object RequestProfileDetailsPacket : SessionPacketFactory<RequestProfileDetailsR
val
qq
=
readUInt
()
discardExact
(
6
)
val
map
=
readTLVMap
(
tagSize
=
2
,
expectingEOF
=
true
)
map
.
printTLVMap
(
"Profile(qq=$qq) raw="
)
map
.
mapValues
{
it
.
value
.
encodeToString
()
}.
printTLVMap
(
"Profile(qq=$qq) str="
)
val
profile
=
Profile
(
qq
=
qq
,
nickname
=
map
[
0
x4E22u
]
?.
encodeToString
()
?:
""
,
//error("Cannot determine nickname")
englishName
=
map
[
0
x4E54u
]
?.
encodeToString
(),
chineseName
=
map
[
0
x4E2Au
]
?.
encodeToString
(),
qAge
=
map
[
0
x6597u
]
?.
toUInt
()
?.
toInt
(),
zipCode
=
map
[
0
x4E25u
]
?.
encodeToString
(),
phone
=
map
[
0
x4E27u
]
?.
encodeToString
(),
gender
=
when
(
map
[
0
x4E29u
]
?.
let
{
it
[
0
]
}
?.
toUInt
())
{
...
...
@@ -73,7 +78,7 @@ object RequestProfileDetailsPacket : SessionPacketFactory<RequestProfileDetailsR
//else -> error("Cannot determine gender, bad value of 0x4E29u: ${map[0x4729u]!![0].toUHexString()}")
},
birthday
=
map
[
0
x4E3Fu
]
?.
let
{
Date
(
it
.
toUInt
().
toInt
())
},
personalStat
us
=
map
[
0
x4E33u
]
?.
encodeToString
(),
personalStat
ement
=
map
[
0
x4E33u
]
?.
encodeToString
(),
homepage
=
map
[
0
x4E2Du
]
?.
encodeToString
(),
company
=
map
[
0
x5DC8u
]
?.
encodeToString
(),
school
=
map
[
0
x4E35u
]
?.
encodeToString
(),
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/InputUtils.kt
View file @
eb1da6a3
...
...
@@ -66,8 +66,12 @@ fun Input.readTLVMap(expectingEOF: Boolean = false, tagSize: Int = 1): MutableMa
return
map
}
fun
Map
<*,
ByteArray
>.
printTLVMap
(
name
:
String
)
=
debugPrintln
(
"TLVMap $name= "
+
this
.
mapValues
{
(
_
,
value
)
->
value
.
toUHexString
()
})
fun
Map
<
UInt
,
ByteArray
>.
printTLVMap
(
name
:
String
)
=
debugPrintln
(
"TLVMap $name= "
+
this
.
mapValues
{
(
_
,
value
)
->
value
.
toUHexString
()
}.
mapKeys
{
it
.
key
.
toInt
().
toUShort
().
toUHexString
()
})
@JvmName
(
"printTLVStringMap"
)
fun
Map
<
UInt
,
String
>.
printTLVMap
(
name
:
String
)
=
debugPrintln
(
"TLVMap $name= "
+
this
.
mapKeys
{
it
.
key
.
toInt
().
toUShort
().
toUHexString
()
})
fun
Input
.
readString
(
length
:
Int
):
String
=
String
(
this
.
readBytes
(
length
))
fun
Input
.
readString
(
length
:
Long
):
String
=
String
(
this
.
readBytes
(
length
.
toInt
()))
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/TypeConvertion.kt
View file @
eb1da6a3
...
...
@@ -120,7 +120,10 @@ fun getRandomString(length: Int, vararg charRanges: CharRange): String =
* 本函数将 4 个 [Byte] 的 bits 连接得到 [Int]
*/
fun
ByteArray
.
toUInt
():
UInt
=
this
[
0
].
toUInt
().
and
(
255
u
).
shl
(
24
)
+
this
[
1
].
toUInt
().
and
(
255
u
).
shl
(
16
)
+
this
[
2
].
toUInt
().
and
(
255
u
).
shl
(
8
)
+
this
[
3
].
toUInt
().
and
(
255
u
).
shl
(
0
)
(
this
[
0
].
toUInt
().
and
(
255
u
)
shl
24
)
+
(
this
[
1
].
toUInt
().
and
(
255
u
)
shl
16
)
+
(
this
[
2
].
toUInt
().
and
(
255
u
)
shl
8
)
+
(
this
[
3
].
toUInt
().
and
(
255
u
)
shl
0
)
fun
ByteArray
.
toUShort
():
UShort
=
((
this
[
0
].
toUInt
().
and
(
255
u
)
shl
8
)
+
(
this
[
1
].
toUInt
().
and
(
255
u
)
shl
0
)).
toUShort
()
/**
* 从 [IoBuffer.Pool] [borrow][ObjectPool.borrow] 一个 [IoBuffer] 然后将 [this] 写入.
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
View file @
eb1da6a3
...
...
@@ -7,13 +7,10 @@ import kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.BotAccount
import
net.mamoe.mirai.addFriend
import
net.mamoe.mirai.*
import
net.mamoe.mirai.event.Subscribable
import
net.mamoe.mirai.event.subscribeAlways
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.login
import
net.mamoe.mirai.message.Image
import
net.mamoe.mirai.network.protocol.tim.packet.action.downloadAsByteArray
import
net.mamoe.mirai.network.protocol.tim.packet.event.FriendMessage
...
...
@@ -55,8 +52,13 @@ suspend fun main() {
bot
.
subscribeMessages
{
"你好"
reply
"你好!"
"profile"
reply
{
sender
.
profile
.
await
().
toString
()
startsWith
(
"profile"
,
removePrefix
=
true
)
{
val
account
=
it
.
trim
()
if
(
account
.
isNotEmpty
())
{
bot
.
getQQ
(
account
.
toUInt
())
}
else
{
sender
}.
profile
.
await
().
toString
()
}
has
<
Image
>
{
...
...
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