mirror of
https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
synced 2025-01-03 06:20:02 +00:00
add MediaFileActualityChecker
This commit is contained in:
parent
570568cd26
commit
d5ae880e77
@ -52,6 +52,10 @@ class DefaultMessageContentCache<K>(
|
|||||||
messagesFilesCache.set(key, filename, inputAllocator)
|
messagesFilesCache.set(key, filename, inputAllocator)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
simpleMessageContentCache.remove(key)
|
simpleMessageContentCache.remove(key)
|
||||||
|
}.onSuccess {
|
||||||
|
with(mediaFileActualityChecker) {
|
||||||
|
bot.saved(content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return key
|
return key
|
||||||
|
@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
|||||||
|
|
||||||
fun interface MediaFileActualityChecker {
|
fun interface MediaFileActualityChecker {
|
||||||
suspend fun TelegramBot.isActual(mediaContent: MediaContent): Boolean
|
suspend fun TelegramBot.isActual(mediaContent: MediaContent): Boolean
|
||||||
|
suspend fun TelegramBot.saved(mediaContent: MediaContent) {}
|
||||||
|
|
||||||
class Default(
|
class Default(
|
||||||
private val checkingChatId: ChatId
|
private val checkingChatId: ChatId
|
||||||
@ -46,5 +47,9 @@ fun interface MediaFileActualityChecker {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun TelegramBot.saved(mediaContent: MediaContent) {
|
||||||
|
fileIdChecksMap[mediaContent.media.fileId] = DateTime.now()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user