mirror of
https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
synced 2024-12-22 16:47:16 +00:00
update arguments in activateAdminsChangesListening
This commit is contained in:
parent
18fc3fd1dd
commit
bb7fb985e3
@ -1,15 +1,23 @@
|
|||||||
package dev.inmo.tgbotapi.libraries.cache.admins
|
package dev.inmo.tgbotapi.libraries.cache.admins
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ChatMemberUpdatedFilterByChat
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatMemberUpdated
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChatMemberUpdated
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatMemberUpdatedMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
|
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
|
||||||
|
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
suspend fun BehaviourContext.activateAdminsChangesListening(
|
suspend fun BehaviourContext.activateAdminsChangesListening(
|
||||||
repo: DefaultAdminsCacheAPIRepo
|
repo: DefaultAdminsCacheAPIRepo,
|
||||||
|
initialFilter: SimpleFilter<ChatMemberUpdated>? = null,
|
||||||
|
markerFactory: MarkerFactory<ChatMemberUpdated, Any> = ByChatChatMemberUpdatedMarkerFactory
|
||||||
) {
|
) {
|
||||||
val me = getMe()
|
val me = getMe()
|
||||||
onChatMemberUpdated {
|
onChatMemberUpdated(initialFilter, markerFactory = markerFactory) {
|
||||||
when {
|
when {
|
||||||
it.oldChatMemberState is AdministratorChatMember && it.newChatMemberState !is AdministratorChatMember ||
|
it.oldChatMemberState is AdministratorChatMember && it.newChatMemberState !is AdministratorChatMember ||
|
||||||
it.newChatMemberState is AdministratorChatMember && it.oldChatMemberState !is AdministratorChatMember -> {
|
it.newChatMemberState is AdministratorChatMember && it.oldChatMemberState !is AdministratorChatMember -> {
|
||||||
|
@ -36,9 +36,9 @@ class DefaultAdminsCacheAPI(
|
|||||||
settings == null -> null
|
settings == null -> null
|
||||||
settings.refreshOnRequests &&
|
settings.refreshOnRequests &&
|
||||||
(lastUpdate == null || (DateTime.now() - lastUpdate).seconds > settings.refreshSeconds) -> {
|
(lastUpdate == null || (DateTime.now() - lastUpdate).seconds > settings.refreshSeconds) -> {
|
||||||
triggerUpdate(chatId)
|
bot.updateAdmins(chatId, repo, getBotInfo())
|
||||||
}
|
}
|
||||||
else -> repo.getChatAdmins(chatId) ?: triggerUpdate(chatId)
|
else -> repo.getChatAdmins(chatId) ?: bot.updateAdmins(chatId, repo, getBotInfo())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user