mirror of
https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
synced 2024-06-13 20:35:12 +00:00
22 lines
729 B
Kotlin
22 lines
729 B
Kotlin
|
package dev.inmo.tgbotapi.libraries.cache.admins
|
||
|
|
||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||
|
import dev.inmo.tgbotapi.extensions.api.chat.get.getChatAdministrators
|
||
|
import dev.inmo.tgbotapi.types.ChatId
|
||
|
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||
|
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
|
||
|
|
||
|
internal suspend fun TelegramBot.updateAdmins(
|
||
|
chatId: ChatId,
|
||
|
repo: DefaultAdminsCacheAPIRepo,
|
||
|
botInfo: ExtendedBot? = null
|
||
|
): List<AdministratorChatMember> {
|
||
|
val botInfo = botInfo ?: getMe()
|
||
|
val admins = getChatAdministrators(chatId).filter {
|
||
|
botInfo.id != it.user.id
|
||
|
}
|
||
|
repo.setChatAdmins(chatId, admins)
|
||
|
return admins
|
||
|
}
|