Troop management - Mute member

This commit is contained in:
jiahua.liu 2020-02-03 22:00:14 +08:00
parent 3d8c60cbd4
commit df24d101bc
2 changed files with 59 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import net.mamoe.mirai.qqandroid.event.ForceOfflineEvent
import net.mamoe.mirai.qqandroid.event.PacketReceivedEvent
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgSvc
import net.mamoe.mirai.qqandroid.network.protocol.packet.*
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket
@ -266,6 +267,15 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
return list
}
suspend fun mute(member: Member, time: Int) {
bot.logger.info("mute..")
val data = TroopManagement.Mute(
client = bot.client,
member = member,
timeInSecond = time
).sendAndExpect<TroopManagement.Mute.Response>()
}
/**
* 缓存超时处理的 [Job]. 超时后将清空缓存, 以免阻碍后续包的处理
*/

View File

@ -1,18 +1,63 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat
import kotlinx.io.core.ByteReadPacket
import kotlinx.io.core.*
import net.mamoe.mirai.contact.Member
import net.mamoe.mirai.data.Packet
import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.io.serialization.writeProtoBuf
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.OidbSso
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacketFactory
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket
import net.mamoe.mirai.utils.io.debugPrintThis
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.TroopManagement.Mute as Mute
internal class TroopManagement {
internal object Mute : OutgoingPacketFactory<LoginPacket.LoginPacketResponse>("OidbSvc.0x570_8") {
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacket.LoginPacketResponse {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
internal object Mute : OutgoingPacketFactory<Mute.Response>("OidbSvc.0x570_8") {
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Mute.Response {
this.debugPrintThis()
return Response()
}
operator fun invoke(
client: QQAndroidClient,
member: Member,
timeInSecond: Int
): OutgoingPacket {
return buildOutgoingUniPacket(client) {
writeProtoBuf(
OidbSso.OIDBSSOPkg.serializer(),
OidbSso.OIDBSSOPkg(
command = 1392,
serviceType = 8,
result = 0,
bodybuffer = buildPacket {
writeInt(member.group.id.toInt())//id or UIN?
writeByte(32)
writeShort(1)
writeInt(member.id.toInt())
writeInt(timeInSecond)
}.readBytes()
)
)
}
}
fun unmute(
client: QQAndroidClient,
member: Member
): OutgoingPacket {
return invoke(client, member, 0)
}
internal class Response() : Packet
}
internal object MuteAll : OutgoingPacketFactory<LoginPacket.LoginPacketResponse>("OidbSvc.0x89a_0") {
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacket.LoginPacketResponse {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.