mirror of
https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git
synced 2024-11-17 13:53:50 +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)
|
||||
}.onFailure {
|
||||
simpleMessageContentCache.remove(key)
|
||||
}.onSuccess {
|
||||
with(mediaFileActualityChecker) {
|
||||
bot.saved(content)
|
||||
}
|
||||
}
|
||||
|
||||
return key
|
||||
|
@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
fun interface MediaFileActualityChecker {
|
||||
suspend fun TelegramBot.isActual(mediaContent: MediaContent): Boolean
|
||||
suspend fun TelegramBot.saved(mediaContent: MediaContent) {}
|
||||
|
||||
class Default(
|
||||
private val checkingChatId: ChatId
|
||||
@ -46,5 +47,9 @@ fun interface MediaFileActualityChecker {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun TelegramBot.saved(mediaContent: MediaContent) {
|
||||
fileIdChecksMap[mediaContent.media.fileId] = DateTime.now()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user