Skip to content

Commit

Permalink
add: check bot permission
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Aug 12, 2023
1 parent b7e2ddf commit c38cdc2
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package net.mamoe.mirai.internal.contact.todo

import net.mamoe.mirai.contact.MemberPermission
import net.mamoe.mirai.contact.checkBotPermission
import net.mamoe.mirai.contact.todo.GroupTodo
import net.mamoe.mirai.contact.todo.GroupTodoRecord
import net.mamoe.mirai.contact.todo.GroupTodoStatus
Expand Down Expand Up @@ -81,6 +83,7 @@ internal class GroupTodoImpl(
}

override suspend fun set(source: MessageSource): GroupTodoRecord {
group.checkBotPermission(MemberPermission.ADMINISTRATOR)
val result = group.bot.network.sendAndExpect(
TroopTodoManager.SetTodo(
group.bot.client,
Expand All @@ -96,6 +99,7 @@ internal class GroupTodoImpl(
}

override suspend fun recall(source: MessageSource) {
group.checkBotPermission(MemberPermission.ADMINISTRATOR)
val result = group.bot.network.sendAndExpect(
TroopTodoManager.RecallTodo(
group.bot.client,
Expand All @@ -108,6 +112,7 @@ internal class GroupTodoImpl(
}

override suspend fun recall(record: GroupTodoRecord) {
group.checkBotPermission(MemberPermission.ADMINISTRATOR)
val result = group.bot.network.sendAndExpect(
TroopTodoManager.RecallTodo(
group.bot.client,
Expand Down Expand Up @@ -144,6 +149,7 @@ internal class GroupTodoImpl(
}

override suspend fun close(source: MessageSource) {
group.checkBotPermission(MemberPermission.ADMINISTRATOR)
val result = group.bot.network.sendAndExpect(
TroopTodoManager.CloseTodo(
group.bot.client,
Expand All @@ -156,6 +162,7 @@ internal class GroupTodoImpl(
}

override suspend fun close(record: GroupTodoRecord) {
group.checkBotPermission(MemberPermission.ADMINISTRATOR)
val result = group.bot.network.sendAndExpect(
TroopTodoManager.CloseTodo(
group.bot.client,
Expand Down

0 comments on commit c38cdc2

Please sign in to comment.