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
33b97c21
Commit
33b97c21
authored
Nov 25, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark Contacts as data class
parent
aeeb3a26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/QQ.kt
...-core/src/commonMain/kotlin/net.mamoe.mirai/contact/QQ.kt
+3
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/internal/ContactImpl.kt
...in/kotlin/net.mamoe.mirai/contact/internal/ContactImpl.kt
+3
-7
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/QQ.kt
View file @
33b97c21
...
...
@@ -2,6 +2,7 @@
package
net.mamoe.mirai.contact
import
kotlinx.coroutines.CompletableDeferred
import
kotlinx.coroutines.Deferred
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.contact.data.Profile
...
...
@@ -22,6 +23,8 @@ import net.mamoe.mirai.network.BotSession
interface
QQ
:
Contact
{
/**
* 用户资料.
* 第一次获取时将会向服务器查询.
* 第一次以后则是直接得到一个用 [CompletableDeferred] 包装的值
*/
val
profile
:
Deferred
<
Profile
>
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/internal/ContactImpl.kt
View file @
33b97c21
...
...
@@ -29,7 +29,7 @@ internal sealed class ContactImpl : Contact {
}
@Suppress
(
"MemberVisibilityCanBePrivate"
,
"CanBeParameter"
)
internal
class
GroupImpl
internal
constructor
(
override
val
bot
:
Bot
,
val
groupId
:
GroupId
)
:
ContactImpl
(),
Group
{
internal
data
class
GroupImpl
internal
constructor
(
override
val
bot
:
Bot
,
val
groupId
:
GroupId
)
:
ContactImpl
(),
Group
{
override
val
id
:
UInt
get
()
=
groupId
.
value
override
val
internalId
=
GroupId
(
id
).
toInternalId
()
...
...
@@ -50,7 +50,7 @@ internal class GroupImpl internal constructor(override val bot: Bot, val groupId
override
fun
toString
():
String
=
"Group(${this.id})"
}
internal
class
QQImpl
internal
constructor
(
override
val
bot
:
Bot
,
override
val
id
:
UInt
)
:
ContactImpl
(),
QQ
{
internal
data
class
QQImpl
internal
constructor
(
override
val
bot
:
Bot
,
override
val
id
:
UInt
)
:
ContactImpl
(),
QQ
{
private
var
_profile
:
Profile
?
=
null
private
val
_initialProfile
by
bot
.
network
.
SuspendLazy
{
updateProfile
()
}
...
...
@@ -59,10 +59,6 @@ internal class QQImpl internal constructor(override val bot: Bot, override val i
override
suspend
fun
sendMessage
(
message
:
MessageChain
)
=
bot
.
sendPacket
(
SendFriendMessagePacket
(
bot
.
qqAccount
,
id
,
bot
.
sessionKey
,
message
))
/**
* 更新个人资料.
* 将会同步更新 property [profile]
*/
override
suspend
fun
updateProfile
():
Profile
=
bot
.
withSession
{
_profile
=
RequestProfileDetailsPacket
(
bot
.
qqAccount
,
id
,
sessionKey
)
.
sendAndExpect
<
RequestProfileDetailsResponse
,
Profile
>
{
it
.
profile
}
...
...
@@ -76,7 +72,7 @@ internal class QQImpl internal constructor(override val bot: Bot, override val i
/**
* 群成员
*/
internal
class
MemberImpl
(
override
val
bot
:
Bot
,
private
val
delegate
:
QQ
,
override
val
group
:
Group
)
:
Member
,
ContactImpl
()
{
internal
data
class
MemberImpl
(
override
val
bot
:
Bot
,
private
val
delegate
:
QQ
,
override
val
group
:
Group
)
:
Member
,
ContactImpl
()
{
override
val
profile
:
Deferred
<
Profile
>
get
()
=
delegate
.
profile
override
val
id
:
UInt
get
()
=
delegate
.
id
...
...
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