mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-22 01:49:12 +08:00
bot permissions
This commit is contained in:
parent
9b75902402
commit
cdb0a89fa8
@ -79,7 +79,7 @@ internal class MemberImpl(
|
||||
return false
|
||||
}
|
||||
//判断有无禁言权限
|
||||
val myPermission = group[bot.uin].permission
|
||||
val myPermission = group.botPermission
|
||||
val targetPermission = this.permission
|
||||
if (myPermission != MemberPermission.OWNER) {
|
||||
if (targetPermission == MemberPermission.OWNER || targetPermission == MemberPermission.ADMINISTRATOR) {
|
||||
@ -103,8 +103,8 @@ internal class MemberImpl(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun unmute() {
|
||||
TODO("not implemented")
|
||||
override suspend fun unmute(): Boolean {
|
||||
return mute(0)
|
||||
}
|
||||
|
||||
}
|
||||
@ -120,6 +120,7 @@ internal class GroupImpl(
|
||||
override var members: ContactList<Member>
|
||||
) : ContactImpl(), Group {
|
||||
override lateinit var owner: Member
|
||||
override var botPermission: MemberPermission = MemberPermission.MEMBER
|
||||
|
||||
override suspend fun quit(): Boolean {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
|
@ -178,6 +178,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
coroutineContext = group.coroutineContext,
|
||||
permission = MemberPermission.OWNER
|
||||
)
|
||||
if (it.dwGroupOwnerUin == bot.uin) {
|
||||
group.botPermission == MemberPermission.OWNER
|
||||
}
|
||||
toGet[group] = contactList
|
||||
bot.groups.delegate.addLast(group)
|
||||
}
|
||||
@ -217,9 +220,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
bot.logger.info("加入群组: ${fillUntil9(bot.groups.size)}\t\t\t 加载时间: ${currentTimeMillis - friendLoadFinish}ms")
|
||||
groupInfo.forEach {
|
||||
if (it.value == -1) {
|
||||
bot.logger.error("群组号码: ${fillUntil9(it.key)}\t\t\t 成员数量加载失败")
|
||||
bot.logger.error("群组号码: ${fillUntil9(it.key)}\t 成员数量加载失败\t BOT权限: " + bot.groups[it.key].botPermission.toString())
|
||||
} else {
|
||||
bot.logger.info("群组号码: ${fillUntil9(it.key)}\t\t\t 成员数量: ${it.value}")
|
||||
bot.logger.info("群组号码: ${fillUntil9(it.key)}\t 成员数量: ${it.value}\t")
|
||||
}
|
||||
}
|
||||
bot.logger.info("====================Mirai Bot List初始化完毕====================")
|
||||
@ -247,7 +250,11 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
coroutineContext = group.coroutineContext,
|
||||
permission = when {
|
||||
it.memberUin == owner -> MemberPermission.OWNER
|
||||
it.dwFlag == 1L -> MemberPermission.ADMINISTRATOR
|
||||
it.dwFlag == 1L -> MemberPermission.ADMINISTRATOR.apply {
|
||||
if (it.memberUin == bot.uin) {
|
||||
group.botPermission = MemberPermission.ADMINISTRATOR
|
||||
}
|
||||
}
|
||||
else -> MemberPermission.MEMBER
|
||||
}
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ internal object TroopManagement {
|
||||
|
||||
internal object Mute : OutgoingPacketFactory<Mute.Response>("OidbSvc.0x570_8") {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
||||
// this.debugPrintThis()
|
||||
//屁用没有
|
||||
return Response
|
||||
}
|
||||
|
||||
@ -47,16 +47,9 @@ internal object TroopManagement {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
object Response : Packet
|
||||
}
|
||||
|
||||
fun Unmute(
|
||||
client: QQAndroidClient,
|
||||
groupCode: Long,
|
||||
memberUin: Long
|
||||
): OutgoingPacket = Mute.invoke(client, groupCode, memberUin, 0)
|
||||
|
||||
|
||||
internal object MuteAll : OutgoingPacketFactory<LoginPacket.LoginPacketResponse>("OidbSvc.0x89a_0") {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacket.LoginPacketResponse {
|
||||
|
@ -19,6 +19,9 @@ interface Group : Contact, CoroutineScope {
|
||||
*/
|
||||
val owner: Member
|
||||
|
||||
|
||||
val botPermission: MemberPermission
|
||||
|
||||
/**
|
||||
* 群名称 (同步事件更新)
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ interface Member : QQ, Contact {
|
||||
/**
|
||||
* 解除禁言
|
||||
*/
|
||||
suspend fun unmute()
|
||||
suspend fun unmute(): Boolean
|
||||
}
|
||||
|
||||
@ExperimentalTime
|
||||
|
Loading…
Reference in New Issue
Block a user