Commit ad04b0ae authored by Him188's avatar Him188

Unmodifiable properties

parent c6eef97c
...@@ -118,6 +118,7 @@ inline fun <R> Contact.withSession(block: BotSession.() -> R): R = bot.withSessi ...@@ -118,6 +118,7 @@ inline fun <R> Contact.withSession(block: BotSession.() -> R): R = bot.withSessi
* @author Him188moe * @author Him188moe
*/ */
open class QQ internal constructor(bot: Bot, id: UInt) : Contact(bot, id) { open class QQ internal constructor(bot: Bot, id: UInt) : Contact(bot, id) {
// TODO: 2019/11/8 should be suspend val if kotlin supports
val profile: Deferred<Profile> by bot.network.SuspendLazy { updateProfile() } val profile: Deferred<Profile> by bot.network.SuspendLazy { updateProfile() }
override suspend fun sendMessage(message: MessageChain) { override suspend fun sendMessage(message: MessageChain) {
...@@ -190,27 +191,29 @@ enum class MemberPermission { ...@@ -190,27 +191,29 @@ enum class MemberPermission {
/** /**
* 个人资料 * 个人资料
*/ */
class Profile// inline class Date // FIXME: 2019/11/8 should be `data class Profile`
(qq: UInt, nickname: String, zipCode: String?, phone: String?, gender: Gender, var birthday: Date?) { @Suppress("PropertyName")
class Profile(qq: UInt, nickname: String, zipCode: String?, phone: String?, gender: Gender, var birthday: Date?) {
var qq: UInt = qq
internal set internal var _qq: UInt = qq
var nickname: String = nickname internal var _nickname: String = nickname
internal set internal var _zipCode: String? = zipCode
var zipCode: String? = zipCode internal var _phone: String? = phone
internal set internal var _gender: Gender = gender
var phone: String? = phone
internal set val qq: UInt = _qq
var gender: Gender = gender val nickname: String = _nickname
internal set val zipCode: String? = _zipCode
val phone: String? = _phone
val gender: Gender = _gender
} }
fun Profile.copyFrom(another: Profile) { fun Profile.copyFrom(another: Profile) {
this.qq = another.qq this._qq = another.qq
this.nickname = another.nickname this._nickname = another.nickname
this.zipCode = another.zipCode this._zipCode = another.zipCode
this.phone = another.phone this._phone = another.phone
this.gender = another.gender this._gender = another.gender
} }
/** /**
......
...@@ -44,6 +44,7 @@ suspend fun main() { ...@@ -44,6 +44,7 @@ suspend fun main() {
subscribeAlways<Subscribable> { subscribeAlways<Subscribable> {
//bot.logger.verbose("收到了一个事件: ${it::class.simpleName}") //bot.logger.verbose("收到了一个事件: ${it::class.simpleName}")
} }
bot.subscribeMessages { bot.subscribeMessages {
"你好" reply "你好!" "你好" reply "你好!"
"profile" reply { "profile" reply {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment