mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-28 17:40:09 +08:00
Support for switching anonymousChat settings (#1522)
* Support for switching anonymousChat settings * apiDump * Applied suggestion from him188
This commit is contained in:
parent
66766dd4da
commit
c09f8ab192
@ -392,6 +392,7 @@ public abstract interface class net/mamoe/mirai/contact/GroupSettings {
|
||||
public abstract fun isAutoApproveEnabled ()Z
|
||||
public abstract fun isMuteAll ()Z
|
||||
public abstract fun setAllowMemberInvite (Z)V
|
||||
public abstract fun setAnonymousChatEnabled (Z)V
|
||||
public abstract fun setEntranceAnnouncement (Ljava/lang/String;)V
|
||||
public abstract fun setMuteAll (Z)V
|
||||
}
|
||||
|
@ -392,6 +392,7 @@ public abstract interface class net/mamoe/mirai/contact/GroupSettings {
|
||||
public abstract fun isAutoApproveEnabled ()Z
|
||||
public abstract fun isMuteAll ()Z
|
||||
public abstract fun setAllowMemberInvite (Z)V
|
||||
public abstract fun setAnonymousChatEnabled (Z)V
|
||||
public abstract fun setEntranceAnnouncement (Ljava/lang/String;)V
|
||||
public abstract fun setMuteAll (Z)V
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public interface GroupSettings {
|
||||
/**
|
||||
* 匿名聊天
|
||||
*/
|
||||
public val isAnonymousChatEnabled: Boolean
|
||||
public var isAnonymousChatEnabled: Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,8 @@ import net.mamoe.mirai.event.events.GroupNameChangeEvent
|
||||
import net.mamoe.mirai.internal.network.QQAndroidClient
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.TroopManagement.GroupOperation
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.TroopManagement.SwitchAnonymousChat
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.sendAndExpect
|
||||
|
||||
@Suppress("SetterBackingFieldAssignment")
|
||||
internal class GroupSettingsImpl(
|
||||
@ -91,9 +93,14 @@ internal class GroupSettingsImpl(
|
||||
@Deprecated("Don't use public var internally", level = DeprecationLevel.HIDDEN)
|
||||
override var isAnonymousChatEnabled: Boolean
|
||||
get() = isAnonymousChatEnabledField
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
set(newValue) {
|
||||
throw UnsupportedOperationException()
|
||||
group.run {
|
||||
checkBotPermission(MemberPermission.ADMINISTRATOR)
|
||||
launch {
|
||||
//Handle it in NoticePipelineContext#processAllowAnonymousChat
|
||||
SwitchAnonymousChat(bot.client, id, newValue).sendAndExpect(bot.network)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Don't use public var internally", level = DeprecationLevel.HIDDEN)
|
||||
|
@ -35,7 +35,7 @@ internal data class GroupInfoImpl(
|
||||
memo = stTroopNum.groupMemo,
|
||||
name = stTroopNum.groupName,
|
||||
allowMemberInvite = stTroopNum.dwGroupFlagExt?.and(0x000000c0) != 0L,
|
||||
allowAnonymousChat = stTroopNum.dwGroupFlagExt?.and(0x40000000) == 0L,
|
||||
allowAnonymousChat = stTroopNum.dwGroupFlagExt?.and(0x40000000) != 0L,
|
||||
autoApprove = stTroopNum.dwGroupFlagExt3?.and(0x00100000) == 0L,
|
||||
confessTalk = stTroopNum.dwGroupFlagExt3?.and(0x00002000) == 0L,
|
||||
muteAll = stTroopNum.dwShutUpTimestamp != 0L,
|
||||
|
@ -154,6 +154,7 @@ internal object KnownPacketFactories {
|
||||
// TroopManagement.GetGroupInfo,
|
||||
TroopManagement.EditGroupNametag,
|
||||
TroopManagement.Kick,
|
||||
TroopManagement.SwitchAnonymousChat,
|
||||
TroopEssenceMsgManager.SetEssence,
|
||||
NudgePacket,
|
||||
Heartbeat.Alive,
|
||||
|
@ -218,6 +218,46 @@ internal class TroopManagement {
|
||||
|
||||
}
|
||||
|
||||
internal object SwitchAnonymousChat : OutgoingPacketFactory<SwitchAnonymousChat.Response>("OidbSvc.0x568_22") {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
||||
val ret = this.readBytes()
|
||||
.loadAs(OidbSso.OIDBSSOPkg.serializer()).result
|
||||
return Response(
|
||||
ret == 0
|
||||
)
|
||||
}
|
||||
|
||||
class Response(
|
||||
val success: Boolean
|
||||
) : Packet {
|
||||
override fun toString(): String = "TroopManagement.SwitchAnonymousChat.Response($success)"
|
||||
}
|
||||
|
||||
operator fun invoke(
|
||||
client: QQAndroidClient,
|
||||
groupCode: Long,
|
||||
switch: Boolean
|
||||
) = buildOutgoingUniPacket(client) {
|
||||
writeProtoBuf(
|
||||
OidbSso.OIDBSSOPkg.serializer(),
|
||||
OidbSso.OIDBSSOPkg(
|
||||
command = 1384,
|
||||
serviceType = 22,
|
||||
result = 0,
|
||||
bodybuffer = buildPacket {
|
||||
writeInt(groupCode.toInt())
|
||||
if (switch) {
|
||||
writeByte(1)
|
||||
} else {
|
||||
writeByte(0)
|
||||
}
|
||||
}.readBytes()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal object GroupOperation : OutgoingPacketFactory<GroupOperation.Response>("OidbSvc.0x89a_0") {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response = Response
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user