mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-29 01:01:19 +08:00
Introduce _ vars
This commit is contained in:
parent
ca43cf689c
commit
68d86a924f
@ -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
|
|||||||
) { "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
|
|||||||
|
|
||||||
internal class MemberImpl(
|
internal class MemberImpl(
|
||||||
qq: QQImpl,
|
qq: QQImpl,
|
||||||
initGroupCard: String,
|
var _groupCard: String,
|
||||||
initSpecialTitle: String,
|
var _specialTitle: 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(
|
|||||||
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(
|
|||||||
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,
|
||||||
initName: String,
|
var _name: String,
|
||||||
initAnnouncement: String,
|
var _announcement: String,
|
||||||
initAllowMemberInvite: Boolean,
|
var _allowMemberInvite: Boolean,
|
||||||
initConfessTalk: Boolean,
|
var _confessTalk: Boolean,
|
||||||
initMuteAll: Boolean,
|
var _muteAll: Boolean,
|
||||||
initAutoApprove: Boolean,
|
var _autoApprove: Boolean,
|
||||||
initAnonymousChat: Boolean,
|
var _anonymousChat: 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
|
||||||
|
Loading…
Reference in New Issue
Block a user